Class: Massimo::Watcher
- Inherits:
-
Object
- Object
- Massimo::Watcher
- Defined in:
- lib/massimo/watcher.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#changed? ⇒ Boolean
Determine if any of the Site’s files have changed.
-
#config_changed? ⇒ Boolean
Determine if the Site’s config file has chanaged.
-
#initialize(site) ⇒ Watcher
constructor
A new instance of Watcher.
-
#process ⇒ Object
Processes the Site if any of the files have changed.
-
#run ⇒ Object
Runs a loop, processing the Site whenever files have changed.
Constructor Details
#initialize(site) ⇒ Watcher
Returns a new instance of Watcher.
10 11 12 13 14 |
# File 'lib/massimo/watcher.rb', line 10 def initialize(site) @site = site @previous_files = [] check_config end |
Class Method Details
Instance Method Details
#changed? ⇒ Boolean
Determine if any of the Site’s files have changed.
43 44 45 |
# File 'lib/massimo/watcher.rb', line 43 def changed? @previous_files != check_files end |
#config_changed? ⇒ Boolean
Determine if the Site’s config file has chanaged.
48 49 50 |
# File 'lib/massimo/watcher.rb', line 48 def config_changed? @previous_config != check_config end |
#process ⇒ Object
Processes the Site if any of the files have changed.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/massimo/watcher.rb', line 29 def process if config_changed? Massimo::UI.say 'massimo is reloading your site' @site.reload @site.process Massimo::UI.say 'massimo has built your site', :growl => true elsif changed? Massimo::UI.say 'massimo has noticed a change' @site.process Massimo::UI.say 'massimo has built your site', :growl => true end end |
#run ⇒ Object
Runs a loop, processing the Site whenever files have changed.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/massimo/watcher.rb', line 17 def run begin loop do Massimo::UI.report_errors { process } sleep 0.5 end rescue Interrupt exit end end |