Class: Lookbook::EventedFileUpdateChecker::Core

Inherits:
ActiveSupport::EventedFileUpdateChecker::Core
  • Object
show all
Defined in:
lib/lookbook/support/evented_file_update_checker.rb

Instance Method Summary collapse

Instance Method Details

#changed(modified, added, removed) ⇒ Object



15
16
17
18
# File 'lib/lookbook/support/evented_file_update_checker.rb', line 15

def changed(modified, added, removed)
  super
  Engine.files_changed(modified, added, removed) if @updated
end

#watching?(file) ⇒ Boolean

Patched to handle regex-style extension matchers like ‘.html.*`

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lookbook/support/evented_file_update_checker.rb', line 22

def watching?(file)
  return true if super

  file = Pathname(file)
  name_parts = file.basename.to_s.split(".")
  ext = "." + name_parts.drop(1).join(".").to_s

  file.dirname.ascend do |dir|
    matching = @dirs.fetch(dir, []).map { |m| Regexp.new(m) }
    if matching.empty? || matching.find { |m| m.match?(ext) }
      break true
    elsif dir == @common_path || dir.root?
      break false
    end
  end
end