Sha256: ce9dcb1d7e4a59790ccdb75e4f8a08ff751f901379aba589eb7179f8f0118218

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

module ActiveMocker
  class Config
    class << self

      attr_accessor :model_dir,
                    :mock_dir,
                    :single_model_path,
                    :progress_bar,
                    :error_verbosity,
                    :disable_modules_and_constants,
                    :mock_append_name

      def model_base_classes=(val)
        @model_base_classes = val
      end

      # @see ActiveMocker#configure
      def set
        load_defaults
        yield self
      end

      def load_defaults
        @error_verbosity               = 1
        @progress_bar                  = true
        @disable_modules_and_constants = false
        @model_dir                     = nil unless @model_dir
        @mock_dir                      = nil unless @mock_dir
        @mock_append_name              = "Mock"
        rails_defaults if Object.const_defined?('Rails')
      end

      def reset_all
        [:model_dir,
         :mock_dir,
         :log_location,
         :single_model_path,
         :progress_bar,
         :error_verbosity,
         :mock_append_name
        ].each { |ivar| instance_variable_set("@#{ivar}", nil) }
      end

      def rails_defaults
        @model_dir = File.join(Rails.root, 'app/models') unless @model_dir
        @mock_dir  = File.join(Rails.root, 'spec/mocks') unless @mock_dir
      end

      def progress_class
        @progress_bar ? Progress : NullProgress
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
active_mocker-2.1.3 lib/active_mocker/config.rb
active_mocker-2.1.2 lib/active_mocker/config.rb
active_mocker-2.1.1 lib/active_mocker/config.rb
active_mocker-2.1.0 lib/active_mocker/config.rb
active_mocker-2.0.0 lib/active_mocker/config.rb
active_mocker-2.0.0.rc1 lib/active_mocker/config.rb
active_mocker-2.0.0.pre1 lib/active_mocker/config.rb