Class: Mutiny::Mutants::Storage::FileStore

Inherits:
Object
  • Object
show all
Defined in:
lib/mutiny/mutants/storage/file_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_directoryObject (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

#strategyObject (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_allObject



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