Class: Ibex::Watch::SourceSnapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/watch/source_snapshot.rb

Overview

Stable metadata and content fingerprints for watched source paths.

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path(path) }.uniq.sort.freeze
  @entries = @paths.to_h { |path| [path, fingerprint(path)] }.freeze #: Hash[String, Hash[Symbol, untyped]]
  freeze
end

Instance Attribute Details

#entriesObject (readonly, protected)

: Hash[String, Hash[Symbol, untyped]]



34
35
36
# File 'lib/ibex/watch/source_snapshot.rb', line 34

def entries
  @entries
end

#pathsObject (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.

Returns:

  • (Boolean)


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