Sha256: 437171c87b6501f5db84689ae1f8d8058467e3c89f2d14a07671e79842e6ef6b

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'singleton'
# TestDiff module
module TestDiff
  # Holds all the configuration details
  class Config
    include Singleton
    attr_accessor :working_directory, :map_subfolder,
                  :current_tracking_filename, :test_pattern

    attr_writer :test_runner, :version_control, :storage

    def initialize
      self.working_directory = '.'
      self.map_subfolder = 'test_diff_coverage'
      self.current_tracking_filename = 'sha'
      self.test_pattern = /spec.rb\z/
    end

    def version_control
      @version_control ||= VersionControl::Git.new(working_directory,
                                                   File.read(current_tracking_file))
    end

    def storage
      @storage ||= Storage.new(map_folder)
    end

    def test_runner
      @test_runner ||= TestRunner::Rspec.new
    end

    def map_folder
      "#{working_directory}/#{map_subfolder}"
    end

    def current_tracking_file
      "#{map_folder}/#{current_tracking_filename}"
    end

    def self.method_missing(method, *args)
      if instance.respond_to?(method)
        instance.send(method, *args)
      else
        super
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
test_diff-0.3.4 lib/test_diff/config.rb
test_diff-0.3.3 lib/test_diff/config.rb
test_diff-0.3.2 lib/test_diff/config.rb
test_diff-0.3.1 lib/test_diff/config.rb
test_diff-0.3.0 lib/test_diff/config.rb