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, fingerprint].
-
#paths ⇒ Object
readonly
@rbs! type fingerprint_value = Symbol | String | Integer | nil | Hash[Symbol, fingerprint_value] type fingerprint = Hash[Symbol, fingerprint_value].
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.
17 18 19 20 21 |
# File 'lib/ibex/watch/source_snapshot.rb', line 17 def initialize(paths) @paths = paths.map { |path| File.(path) }.uniq.sort.freeze @entries = @paths.to_h { |path| [path, fingerprint(path)] }.freeze #: Hash[String, fingerprint] freeze end |
Instance Attribute Details
#entries ⇒ Object (readonly, protected)
: Hash[String, fingerprint]
38 39 40 |
# File 'lib/ibex/watch/source_snapshot.rb', line 38 def entries @entries end |
#paths ⇒ Object (readonly)
@rbs! type fingerprint_value = Symbol | String | Integer | nil | Hash[Symbol, fingerprint_value] type fingerprint = Hash[Symbol, fingerprint_value]
14 15 16 |
# File 'lib/ibex/watch/source_snapshot.rb', line 14 def paths @paths end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 |
# File 'lib/ibex/watch/source_snapshot.rb', line 24 def ==(other) @entries == other.__send__(:entries) end |
#entry(path) ⇒ Object (protected)
41 42 43 |
# File 'lib/ibex/watch/source_snapshot.rb', line 41 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.
30 31 32 33 34 |
# File 'lib/ibex/watch/source_snapshot.rb', line 30 def unchanged_since?(older) @paths.all? do |path| older.__send__(:entry, path) == @entries.fetch(path) end end |