Class: Mutiny::Mutants::Storage::FileStore
- Inherits:
-
Object
- Object
- Mutiny::Mutants::Storage::FileStore
- Defined in:
- lib/mutiny/mutants/storage/file_store.rb
Instance Attribute Summary collapse
-
#mutant_directory ⇒ Object
readonly
Returns the value of attribute mutant_directory.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
-
#initialize(mutant_directory: ".mutants") ⇒ FileStore
constructor
A new instance of FileStore.
- #load_all ⇒ Object
- #save_all(mutants) ⇒ Object
Constructor Details
#initialize(mutant_directory: ".mutants") ⇒ FileStore
Returns a new instance of FileStore.
9 10 11 12 |
# File 'lib/mutiny/mutants/storage/file_store.rb', line 9 def initialize(mutant_directory: ".mutants") @mutant_directory = mutant_directory @strategy = MutantFile.new(mutant_directory) end |
Instance Attribute Details
#mutant_directory ⇒ Object (readonly)
Returns the value of attribute mutant_directory.
7 8 9 |
# File 'lib/mutiny/mutants/storage/file_store.rb', line 7 def mutant_directory @mutant_directory end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
7 8 9 |
# File 'lib/mutiny/mutants/storage/file_store.rb', line 7 def strategy @strategy end |
Instance Method Details
#load_all ⇒ Object
20 21 22 23 |
# File 'lib/mutiny/mutants/storage/file_store.rb', line 20 def load_all absolute_paths = Dir.glob(File.join(mutant_directory, "**", "*.rb")) absolute_paths.sort.map { |path| strategy.load(path) } end |
#save_all(mutants) ⇒ Object
14 15 16 17 18 |
# File 'lib/mutiny/mutants/storage/file_store.rb', line 14 def save_all(mutants) mutants.ordered.each do |mutant| strategy.store(mutant) end end |