Class: Guard::Staticise
- Defined in:
- lib/guard/staticise.rb,
lib/guard/staticise/notifier.rb
Defined Under Namespace
Classes: Notifier
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :output => 'public', :input => 'app', :all_on_start => true }
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Staticise
constructor
A new instance of Staticise.
- #reload ⇒ Object
- #run_all ⇒ Object
- #run_on_changes(paths) ⇒ Object
- #run_on_removals(paths) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Staticise
Returns a new instance of Staticise.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/guard/staticise.rb', line 17 def initialize(watchers =[], = {}) watchers = [] if !watchers ::Guard::UI.info("staticise watcher #{ watchers }") defaults = DEFAULT_OPTIONS.clone.merge() watchers << ::Guard::Watcher.new(%r{^#{ defaults[:input] }/(.+\.h[ta]ml)$}) super(watchers, defaults) end |
Instance Method Details
#reload ⇒ Object
36 37 38 |
# File 'lib/guard/staticise.rb', line 36 def reload end |
#run_all ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/guard/staticise.rb', line 40 def run_all begin ::Staticise::Renderer.all rescue Exception => e = "Error compiling pages: #{ e. }" ::Guard::UI.info() Notifier.notify(false, ) end end |
#run_on_changes(paths) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/guard/staticise.rb', line 52 def run_on_changes(paths) puts paths.join(", ") begin paths.each do |f| if File.basename(f).start_with?("_") || f.index("layouts") ::Staticise::Renderer.all else ::Staticise::Renderer.new(f).export end end rescue Exception => e = "Error compiling #{ paths.join(", ")}: #{ e. }" ::Guard::UI.info() Notifier.notify(false, ) end end |
#run_on_removals(paths) ⇒ Object
71 72 73 |
# File 'lib/guard/staticise.rb', line 71 def run_on_removals(paths) # Runner.remove(Inspector.clean(paths, :missing_ok => true), watchers, options) end |
#start ⇒ Object
28 29 30 |
# File 'lib/guard/staticise.rb', line 28 def start run_all if [:all_on_start] end |
#stop ⇒ Object
32 33 34 |
# File 'lib/guard/staticise.rb', line 32 def stop end |