Class: ActiveMocker::Config
- Inherits:
-
Object
- Object
- ActiveMocker::Config
- Defined in:
- lib/active_mocker/config.rb
Class Attribute Summary collapse
-
.build_in_progress ⇒ Object
Returns the value of attribute build_in_progress.
-
.clear_log_on_build ⇒ Object
Returns the value of attribute clear_log_on_build.
-
.file_reader ⇒ Object
Returns the value of attribute file_reader.
-
.log_location ⇒ Object
Returns the value of attribute log_location.
-
.mock_dir ⇒ Object
Returns the value of attribute mock_dir.
-
.model_base_classes ⇒ Object
Returns the value of attribute model_base_classes.
-
.model_dir ⇒ Object
Returns the value of attribute model_dir.
-
.schema_file ⇒ Object
Returns the value of attribute schema_file.
Class Method Summary collapse
- .clear_log ⇒ Object
- .default_logger ⇒ Object
- .load_defaults ⇒ Object
- .logger ⇒ Object
- .rails_defaults ⇒ Object
- .reset_all ⇒ Object
- .set {|_self| ... } ⇒ Object
Class Attribute Details
.build_in_progress ⇒ Object
Returns the value of attribute build_in_progress.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def build_in_progress @build_in_progress end |
.clear_log_on_build ⇒ Object
Returns the value of attribute clear_log_on_build.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def clear_log_on_build @clear_log_on_build end |
.file_reader ⇒ Object
Returns the value of attribute file_reader.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def file_reader @file_reader end |
.log_location ⇒ Object
Returns the value of attribute log_location.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def log_location @log_location end |
.mock_dir ⇒ Object
Returns the value of attribute mock_dir.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def mock_dir @mock_dir end |
.model_base_classes ⇒ Object
Returns the value of attribute model_base_classes.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def model_base_classes @model_base_classes end |
.model_dir ⇒ Object
Returns the value of attribute model_dir.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def model_dir @model_dir end |
.schema_file ⇒ Object
Returns the value of attribute schema_file.
6 7 8 |
# File 'lib/active_mocker/config.rb', line 6 def schema_file @schema_file end |
Class Method Details
.clear_log ⇒ Object
62 63 64 65 66 |
# File 'lib/active_mocker/config.rb', line 62 def clear_log if @clear_log_on_build && File.exist?(@log_location) FileUtils.rm(@log_location) end end |
.default_logger ⇒ Object
51 52 53 54 |
# File 'lib/active_mocker/config.rb', line 51 def default_logger FileUtils.mkdir_p(File.dirname(@log_location)) unless File.directory?(File.dirname(@log_location)) ::Logger.new(@log_location) end |
.load_defaults ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/active_mocker/config.rb', line 24 def load_defaults @schema_file = nil unless @schema_file @model_dir = nil unless @model_dir @mock_dir = nil unless @mock_dir @model_base_classes = %w[ ActiveRecord::Base ] unless @model_base_classes @file_reader = FileReader unless @file_reader @log_location = 'log/active_mocker.log' unless @log_location @clear_log_on_build = true rails_defaults if Object.const_defined?('Rails') end |
.logger ⇒ Object
35 36 37 |
# File 'lib/active_mocker/config.rb', line 35 def logger default_logger end |
.rails_defaults ⇒ Object
56 57 58 59 60 |
# File 'lib/active_mocker/config.rb', line 56 def rails_defaults @schema_file = File.join(Rails.root, 'db/schema.rb') unless @schema_file @model_dir = File.join(Rails.root, 'app/models') unless @model_dir @mock_dir = File.join(Rails.root, 'spec/mocks') unless @mock_dir end |
.reset_all ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_mocker/config.rb', line 39 def reset_all [ :@schema_file, :@model_dir, :@mock_dir, :@model_base_classes, :@file_reader, :@logger, :@schema_file, :@model_dir, :@mock_dir].each{|ivar| instance_variable_set(ivar, nil)} end |
.set {|_self| ... } ⇒ Object
19 20 21 22 |
# File 'lib/active_mocker/config.rb', line 19 def set load_defaults yield self end |