Class: Guard::Haml
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Haml
- Defined in:
- lib/guard/haml.rb,
lib/guard/haml/notifier.rb
Defined Under Namespace
Classes: Notifier
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Haml
constructor
A new instance of Haml.
- #reload ⇒ Object
- #run_all ⇒ Object
- #run_on_changes(paths) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Haml
Returns a new instance of Haml.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/guard/haml.rb', line 10 def initialize(opts = {}) opts = { notifications: true, default_ext: 'html', auto_append_file_ext: false }.merge(opts) super(opts) if [:input] watchers << ::Guard::Watcher.new(%r{^#{[:input]}/([\w\-_]+(\.html)?\.haml)$}) end end |
Instance Method Details
#reload ⇒ Object
32 33 34 |
# File 'lib/guard/haml.rb', line 32 def reload run_all end |
#run_all ⇒ Object
36 37 38 |
# File 'lib/guard/haml.rb', line 36 def run_all run_on_changes(Watcher.match_files(self, Dir.glob(File.join('**', '*.*')))) end |
#run_on_changes(paths) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/guard/haml.rb', line 40 def run_on_changes(paths) paths.each do |file| output_paths = _output_paths(file) compiled_haml = compile_haml(file) output_paths.each do |output_file| FileUtils.mkdir_p File.dirname(output_file) File.open(output_file, 'w') { |f| f.write(compiled_haml) } end = "Successfully compiled haml to html!\n" += "# #{file} -> #{output_paths.join(', ')}".gsub("#{::Bundler.root.to_s}/", '') ::Guard::UI.info Notifier.notify(true, ) if [:notifications] end end |
#start ⇒ Object
24 25 26 |
# File 'lib/guard/haml.rb', line 24 def start run_all if [:run_at_start] end |
#stop ⇒ Object
28 29 30 |
# File 'lib/guard/haml.rb', line 28 def stop true end |