Class: Minipack::FileChangeWatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/minipack/file_change_watcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(watched_paths, digest_store_path) ⇒ FileChangeWatcher

Returns a new instance of FileChangeWatcher.

Parameters:

  • watched_paths (Array<Pathname>)
  • digest_store_path (Pathname)


10
11
12
13
# File 'lib/minipack/file_change_watcher.rb', line 10

def initialize(watched_paths, digest_store_path)
  @watched_paths = watched_paths
  @digest_store_path = Pathname.new(digest_store_path)
end

Instance Method Details

#fresh?Boolean

Returns true if all watched files are up to date

Returns:

  • (Boolean)


16
17
18
# File 'lib/minipack/file_change_watcher.rb', line 16

def fresh?
  watched_files_digest == last_stored_digest
end

#record_digestObject



25
26
27
28
# File 'lib/minipack/file_change_watcher.rb', line 25

def record_digest
  @digest_store_path.dirname.mkpath
  @digest_store_path.write(watched_files_digest)
end

#stale?Boolean

Returns true if the watched files are out of date

Returns:

  • (Boolean)


21
22
23
# File 'lib/minipack/file_change_watcher.rb', line 21

def stale?
  !fresh?
end