Class: Lookbook::Reloaders::Reloader
- Inherits:
-
Object
- Object
- Lookbook::Reloaders::Reloader
- Defined in:
- lib/lookbook/reloaders.rb
Instance Attribute Summary collapse
- #callback ⇒ Object readonly
- #directories ⇒ Object readonly
- #extensions ⇒ Object readonly
- #last_changes ⇒ Object
- #name ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(name, directories, extensions, &callback) ⇒ Reloader
constructor
A new instance of Reloader.
- #watching?(changes) ⇒ Boolean
Constructor Details
#initialize(name, directories, extensions, &callback) ⇒ Reloader
Returns a new instance of Reloader.
40 41 42 43 44 45 46 |
# File 'lib/lookbook/reloaders.rb', line 40 def initialize(name, directories, extensions, &callback) @name = name.to_sym @directories = directories @extensions = extensions @callback = callback @last_changes = nil end |
Instance Attribute Details
#callback ⇒ Object (readonly)
37 38 39 |
# File 'lib/lookbook/reloaders.rb', line 37 def callback @callback end |
#directories ⇒ Object (readonly)
37 38 39 |
# File 'lib/lookbook/reloaders.rb', line 37 def directories @directories end |
#extensions ⇒ Object (readonly)
37 38 39 |
# File 'lib/lookbook/reloaders.rb', line 37 def extensions @extensions end |
#last_changes ⇒ Object
38 39 40 |
# File 'lib/lookbook/reloaders.rb', line 38 def last_changes @last_changes end |
#name ⇒ Object (readonly)
37 38 39 |
# File 'lib/lookbook/reloaders.rb', line 37 def name @name end |
Instance Method Details
#watching?(changes) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/lookbook/reloaders.rb', line 48 def watching?(changes) file_paths = changes.to_h.values.flatten !!file_paths.find do |file_path| file_path = Pathname(file_path). directories.find do |dir_path| matcher = File.(File.join(dir_path, "**")) file_path.fnmatch?(matcher) end end end |