Class: Guard::Staticise

Inherits:
Guard
  • Object
show all
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

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 =[], options = {})
  watchers = [] if !watchers
  ::Guard::UI.info("staticise watcher #{ watchers }")

  defaults = DEFAULT_OPTIONS.clone.merge(options)

  watchers << ::Guard::Watcher.new(%r{^#{ defaults[:input] }/(.+\.h[ta]ml)$})

  super(watchers, defaults)
end

Instance Method Details

#reloadObject



36
37
38
# File 'lib/guard/staticise.rb', line 36

def reload

end

#run_allObject



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
    message = "Error compiling pages: #{ e.message }"
    ::Guard::UI.info(message)
    Notifier.notify(false, message)


  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
    message = "Error compiling #{ paths.join(", ")}: #{ e.message }"
    ::Guard::UI.info(message)
    Notifier.notify(false, message)

  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

#startObject



28
29
30
# File 'lib/guard/staticise.rb', line 28

def start
  run_all if options[:all_on_start]
end

#stopObject



32
33
34
# File 'lib/guard/staticise.rb', line 32

def stop

end