class Mutiny::Mutants::Storage::MutantFile
Attributes
mutant_directory[R]
Public Class Methods
new(mutant_directory)
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 12 def initialize(mutant_directory) @mutant_directory = mutant_directory end
Public Instance Methods
load(absolute_path)
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 16 def load(absolute_path) path = Path.from_absolute(path: absolute_path, root: mutant_directory) deep_merge(deserialised_contents(path), deserialised_filename(path)) end
store(mutant)
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 21 def store(mutant) path = Path.from_relative(root: mutant_directory, path: filename.serialise(mutant)) FileUtils.mkdir_p(File.dirname(path.absolute)) File.open(path.absolute, 'w') { |f| f.write(contents.serialise(mutant)) } end
Private Instance Methods
contents()
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 45 def contents @contents ||= MutantFileContents.new end
deep_merge(hash1, hash2)
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 29 def deep_merge(hash1, hash2) hash1.merge(hash2) { |_, h1_member, h2_member| h1_member.merge(h2_member) } end
deserialised_contents(path)
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 37 def deserialised_contents(path) contents.deserialise(File.read(path.absolute)) end
deserialised_filename(path)
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 33 def deserialised_filename(path) filename.deserialise(path.relative) end
filename()
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file.rb, line 41 def filename @filename ||= MutantFileName.new end