forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathember_templates.rb
51 lines (42 loc) · 1.18 KB
/
ember_templates.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'guard'
require 'guard/guard'
require 'handlebars_tasks'
module Guard
class EmberTemplates < Guard
DEFAULT_OPTIONS = {
:hide_success => false,
:all_on_start => false
}
def initialize(watchers=[], options={})
super([::Guard::Watcher.new(/(app\/coffeescripts\/ember\/.*.hbs)\z/)], {})
end
def start
run_all if options[:all_on_start]
end
def run_on_change(paths)
paths.each do |path|
begin
UI.info "Compiling Ember template: #{path}"
HandlebarsTasks::EmberHbs.compile_file path
rescue Exception => e
::Guard::Notifier.notify(e.to_s, :title => path, :image => :failed)
UI.error "Error compiling: #{path}\n#{e}"
end
end
end
# Gets called when all files should be regenerated.
#
# @raise [:task_has_failed] when stop has failed
#
def run_all
UI.info "Compiling all Ember templates"
files = Dir.glob("app/coffeescripts/**/*.hbs")
files.each do |file|
HandlebarsTasks::EmberHbs.compile_file(file)
end
end
def run_on_deletion(paths)
puts "TODO: run_on_deletion not implemented"
end
end
end