Class: SixthSense::MutationCache
- Inherits:
-
Object
- Object
- SixthSense::MutationCache
- Defined in:
- lib/sixth_sense/mutation_cache.rb
Constant Summary collapse
- DEFAULT_ROOT =
".sixth_sense_cache/kill_matrix"
Instance Method Summary collapse
-
#initialize(root: DEFAULT_ROOT) ⇒ MutationCache
constructor
A new instance of MutationCache.
- #load(test_file) ⇒ Object
- #path_for(test_file_path) ⇒ Object
- #write(test_file, payload) ⇒ Object
Constructor Details
#initialize(root: DEFAULT_ROOT) ⇒ MutationCache
Returns a new instance of MutationCache.
14 15 16 |
# File 'lib/sixth_sense/mutation_cache.rb', line 14 def initialize(root: DEFAULT_ROOT) @root = root end |
Instance Method Details
#load(test_file) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/sixth_sense/mutation_cache.rb', line 18 def load(test_file) path = path_for(test_file.path) return nil unless File.file?(path) build_matrix(JSON.parse(File.read(path)), test_file) end |
#path_for(test_file_path) ⇒ Object
30 31 32 |
# File 'lib/sixth_sense/mutation_cache.rb', line 30 def path_for(test_file_path) File.join(@root, "#{test_file_path.gsub(%r{[^A-Za-z0-9]+}, "_").gsub(/\A_+|_+\z/, "")}.json") end |
#write(test_file, payload) ⇒ Object
25 26 27 28 |
# File 'lib/sixth_sense/mutation_cache.rb', line 25 def write(test_file, payload) FileUtils.mkdir_p(@root) File.write(path_for(test_file.path), JSON.pretty_generate(payload) + "\n") end |