Class: Ibex::Watch::SourceSnapshot
- Inherits:
-
Object
- Object
- Ibex::Watch::SourceSnapshot
- Defined in:
- lib/ibex/watch/source_snapshot.rb
Overview
Stable metadata and content fingerprints for watched source paths.
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
protected
: Hash[String, Hash[Symbol, untyped]].
-
#paths ⇒ Object
readonly
: Array.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #entry(path) ⇒ Object protected
-
#initialize(paths) ⇒ SourceSnapshot
constructor
A new instance of SourceSnapshot.
-
#unchanged_since?(older) ⇒ Boolean
Every path in this snapshot must have had the same value in the older snapshot.
Constructor Details
#initialize(paths) ⇒ SourceSnapshot
Returns a new instance of SourceSnapshot.
13 14 15 16 17 |
# File 'lib/ibex/watch/source_snapshot.rb', line 13 def initialize(paths) @paths = paths.map { |path| File.(path) }.uniq.sort.freeze @entries = @paths.to_h { |path| [path, fingerprint(path)] }.freeze #: Hash[String, Hash[Symbol, untyped]] freeze end |
Instance Attribute Details
#entries ⇒ Object (readonly, protected)
: Hash[String, Hash[Symbol, untyped]]
34 35 36 |
# File 'lib/ibex/watch/source_snapshot.rb', line 34 def entries @entries end |
#paths ⇒ Object (readonly)
: Array
10 11 12 |
# File 'lib/ibex/watch/source_snapshot.rb', line 10 def paths @paths end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 |
# File 'lib/ibex/watch/source_snapshot.rb', line 20 def ==(other) @entries == other.__send__(:entries) end |
#entry(path) ⇒ Object (protected)
37 38 39 |
# File 'lib/ibex/watch/source_snapshot.rb', line 37 def entry(path) @entries[path] end |
#unchanged_since?(older) ⇒ Boolean
Every path in this snapshot must have had the same value in the older snapshot.
26 27 28 29 30 |
# File 'lib/ibex/watch/source_snapshot.rb', line 26 def unchanged_since?(older) @paths.all? do |path| older.__send__(:entry, path) == @entries.fetch(path) end end |