class DeltaTest::Configuration

Constants

CONFIG_FILES

Public Class Methods

new() click to toggle source
# File lib/delta_test/configuration.rb, line 117
def initialize
  update(validate: false) do |c|
    c.base_path  = File.expand_path('.')
    c.stats_path = File.expand_path('tmp/delta_test_stats')
    c.stats_life = 1000  # commits

    c.files     = []

    c.full_test_patterns = []
    c.full_test_branches = []

    c.patterns           = []
    c.exclude_patterns   = []
    c.custom_mappings    = {}
  end
end

Public Instance Methods

auto_configure!() click to toggle source

Auto configuration

# File lib/delta_test/configuration.rb, line 191
def auto_configure!
  load_from_file!
  retrive_files_from_git_index!
  update
end
base_path=(path) click to toggle source

Override setters

# File lib/delta_test/configuration.rb, line 143
def base_path=(path)
  return unless path
  @base_path = Pathname.new(path)
end
load_from_file!() click to toggle source

Load configuration file And update `base_path` to the directory

# File lib/delta_test/configuration.rb, line 201
def load_from_file!
  config_file = Utils.find_file_upward(*CONFIG_FILES)

  unless config_file
    raise NoConfigurationFileFoundError
  end

  yaml = YAML.load_file(config_file)
  yaml_dir = File.dirname(config_file)

  _base_path = yaml.delete('base_path')
  self.base_path = _base_path ? File.absolute_path(_base_path, yaml_dir) : yaml_dir

  _stats_path = yaml.delete('stats_path')
  self.stats_path = File.absolute_path(_stats_path, yaml_dir) if _stats_path

  yaml.each do |k, v|
    if self.respond_to?("#{k}=")
      self.send("#{k}=", v)
    else
      raise InvalidOptionError.new(k)
    end
  end
end
precalculate!() click to toggle source

Precalculate some values

# File lib/delta_test/configuration.rb, line 176
def precalculate!
  filtered_files = self.files
    .map { |f| Utils.regulate_filepath(f, self.base_path) }
    .uniq
  @filtered_files = Utils.files_grep(filtered_files, self.patterns, self.exclude_patterns).to_set

  @stats_path = Pathname.new(File.absolute_path(self.stats_path, self.base_path))
end
retrive_files_from_git_index!() click to toggle source

Retrive files from git index And update `files`

# File lib/delta_test/configuration.rb, line 230
def retrive_files_from_git_index!
  self.files = Git.new(self.base_path).ls_files
end
stats_path=(path) click to toggle source

Store stats_path as Pathname

@params {String|Pathname} path @return {Pathname}

# File lib/delta_test/configuration.rb, line 154
def stats_path=(path)
  return unless path
  @stats_path = Pathname.new(path)
end
tmp_table_file() click to toggle source

Getters

# File lib/delta_test/configuration.rb, line 242
def tmp_table_file
  self.stats_path.join('tmp', DeltaTest.tester_id)
end
update(validate: true) { |self| ... } click to toggle source

Update

# File lib/delta_test/configuration.rb, line 167
def update(validate: true)
  yield self if block_given?
  validate! if validate
  precalculate!
end