class DeltaTest::DependenciesTable

Constants

DEFAULT_PROC

Public Class Methods

load(file) click to toggle source

Restore a table object from a file

@params {String|Pathname} file

# File lib/delta_test/dependencies_table.rb, line 22
def self.load(file)
  begin
    data = File.binread(file)
    dt = Marshal.load(data)
    dt.default_proc = DEFAULT_PROC
    dt
  rescue
    self.new
  end
end
new() click to toggle source
Calls superclass method
# File lib/delta_test/dependencies_table.rb, line 11
def initialize
  super

  self.default_proc = DEFAULT_PROC
end

Public Instance Methods

add(spec_file, source_file) click to toggle source

Add a dependency for a spec file

@params {String} spec_file @params {String} source_file

# File lib/delta_test/dependencies_table.rb, line 39
def add(spec_file, source_file)
  source_file = Utils.regulate_filepath(source_file, DeltaTest.config.base_path)
  self[spec_file] << source_file if DeltaTest.config.filtered_files.include?(source_file)
end
cleanup!() click to toggle source

Cleanup empty sets from the table

# File lib/delta_test/dependencies_table.rb, line 78
def cleanup!
  self.reject! { |k, v| v.empty? }
end
dump(file) click to toggle source

Dump the table object to a file

@params {String|Pathname} file

# File lib/delta_test/dependencies_table.rb, line 87
def dump(file)
  without_default_proc do
    cleanup!
    data = Marshal.dump(self)
    FileUtils.mkdir_p(File.dirname(file))
    File.open(file, 'wb') { |f| f.write data }
  end
end
reverse_merge!(other) click to toggle source

Reverse merge other table

@params {DependenciesTable} other

# File lib/delta_test/dependencies_table.rb, line 49
def reverse_merge!(other)
  raise TypeError unless other.is_a?(self.class)

  other.each do |spec_file, source_files|
    self[spec_file] |= source_files
  end

  nil
end
without_default_proc() { || ... } click to toggle source

Temporary disable default_proc Because Marshal can't dump Hash with default_proc

@block

# File lib/delta_test/dependencies_table.rb, line 65
def without_default_proc
  self.default_proc = nil

  begin
    yield
  ensure
    self.default_proc = DEFAULT_PROC
  end
end