Class: Guard::Haml
- Defined in:
- lib/guard/haml.rb,
lib/guard/haml/notifier.rb
Defined Under Namespace
Classes: Notifier
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Haml
constructor
A new instance of Haml.
- #reload ⇒ Object
- #run_all ⇒ Object
- #run_on_changes(paths) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Haml
Returns a new instance of Haml.
10 11 12 13 14 15 16 |
# File 'lib/guard/haml.rb', line 10 def initialize(watchers = [], = {}) @options = { :notifications => true, :default_ext => 'html' }.merge super(watchers, @options) end |
Instance Method Details
#reload ⇒ Object
26 27 28 |
# File 'lib/guard/haml.rb', line 26 def reload run_all end |
#run_all ⇒ Object
30 31 32 |
# File 'lib/guard/haml.rb', line 30 def run_all run_on_changes(Watcher.match_files(self, Dir.glob(File.join('**', '*.*')))) end |
#run_on_changes(paths) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/guard/haml.rb', line 34 def run_on_changes(paths) paths.each do |file| output_files = get_output(file) compiled_haml = compile_haml(file) output_files.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_files.join(', ')}".gsub("#{Bundler.root.to_s}/", '') ::Guard::UI.info Notifier.notify( true, ) if @options[:notifications] end notify paths end |
#start ⇒ Object
18 19 20 |
# File 'lib/guard/haml.rb', line 18 def start run_all if @options[:run_at_start] end |
#stop ⇒ Object
22 23 24 |
# File 'lib/guard/haml.rb', line 22 def stop true end |