Class: ActiveMutator::AcceptedLedger
- Inherits:
-
Object
- Object
- ActiveMutator::AcceptedLedger
- Defined in:
- lib/active_mutator/accepted_ledger.rb
Overview
Committed, repo-root ledger of accepted (equivalent) survivors. Deliberately NOT inside .active_mutator/ — that dir is gitignored and disposable, while acceptance decisions are durable team/CI state.
Constant Summary collapse
- FILENAME =
".active_mutator_accepted.json"
Class Method Summary collapse
Instance Method Summary collapse
-
#accept!(new_fingerprints, all_current_fingerprints) ⇒ Object
Union new acceptances in, prune anything no longer matching a current mutant, write atomically.
- #accepted?(fingerprint) ⇒ Boolean
-
#initialize(path, entries) ⇒ AcceptedLedger
constructor
A new instance of AcceptedLedger.
- #stale_entries(all_current_fingerprints) ⇒ Object
Constructor Details
#initialize(path, entries) ⇒ AcceptedLedger
Returns a new instance of AcceptedLedger.
24 25 26 27 |
# File 'lib/active_mutator/accepted_ledger.rb', line 24 def initialize(path, entries) @path = path @entries = entries end |
Class Method Details
.from_hash(hash) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/active_mutator/accepted_ledger.rb', line 17 def self.from_hash(hash) Fingerprint.new(file: hash.fetch("file"), subject: hash.fetch("subject"), description: hash.fetch("description"), original_snippet: hash.fetch("original_snippet"), ordinal: hash.fetch("ordinal")) end |
Instance Method Details
#accept!(new_fingerprints, all_current_fingerprints) ⇒ Object
Union new acceptances in, prune anything no longer matching a current mutant, write atomically.
38 39 40 41 42 43 |
# File 'lib/active_mutator/accepted_ledger.rb', line 38 def accept!(new_fingerprints, all_current_fingerprints) current = all_current_fingerprints.to_set @entries = (@entries + new_fingerprints).uniq.select { |e| current.include?(e) } AtomicFile.write(@path, JSON.pretty_generate(@entries.map(&:to_h))) nil end |
#accepted?(fingerprint) ⇒ Boolean
29 |
# File 'lib/active_mutator/accepted_ledger.rb', line 29 def accepted?(fingerprint) = @entries.include?(fingerprint) |
#stale_entries(all_current_fingerprints) ⇒ Object
31 32 33 34 |
# File 'lib/active_mutator/accepted_ledger.rb', line 31 def stale_entries(all_current_fingerprints) current = all_current_fingerprints.to_set @entries.reject { |e| current.include?(e) } end |