Class: Mutiny::Mutants::Storage::MutantFile
- Inherits:
-
Object
- Object
- Mutiny::Mutants::Storage::MutantFile
- Defined in:
- lib/mutiny/mutants/storage/mutant_file.rb
Instance Attribute Summary collapse
-
#mutant_directory ⇒ Object
readonly
Returns the value of attribute mutant_directory.
Instance Method Summary collapse
-
#initialize(mutant_directory) ⇒ MutantFile
constructor
A new instance of MutantFile.
- #load(absolute_path) ⇒ Object
- #store(mutant) ⇒ Object
Constructor Details
#initialize(mutant_directory) ⇒ MutantFile
Returns a new instance of MutantFile.
12 13 14 |
# File 'lib/mutiny/mutants/storage/mutant_file.rb', line 12 def initialize(mutant_directory) @mutant_directory = mutant_directory end |
Instance Attribute Details
#mutant_directory ⇒ Object (readonly)
Returns the value of attribute mutant_directory.
10 11 12 |
# File 'lib/mutiny/mutants/storage/mutant_file.rb', line 10 def mutant_directory @mutant_directory end |
Instance Method Details
#load(absolute_path) ⇒ Object
16 17 18 19 |
# 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) ⇒ Object
21 22 23 24 25 |
# 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 |