Class: Guard::MtHaml
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::MtHaml
- Defined in:
- lib/guard/mthaml.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MtHaml
constructor
Initializer.
- #reload ⇒ Object
-
#run_all ⇒ Object
Run all.
-
#run_on_changes(paths) ⇒ Object
Run on changes to watched files.
-
#start ⇒ Object
Run at start.
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MtHaml
Initializer
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/guard/mthaml.rb', line 11 def initialize( = {}) = { :input => "views/src", :output => "views", :environment => "php", :notifications => true, :compress_output => false, :run_at_start => true, :static_files => false }.merge() super() if [:input] watchers << ::Guard::Watcher.new(%r{^#{[:input]}/(.+\.haml)$}) end end |
Instance Method Details
#reload ⇒ Object
40 41 42 |
# File 'lib/guard/mthaml.rb', line 40 def reload run_all end |
#run_all ⇒ Object
Run all
47 48 49 |
# File 'lib/guard/mthaml.rb', line 47 def run_all run_on_changes Watcher.match_files(self, Dir.glob(File.join("**", "*.*")).reject { |f| f[%r{(\.php)$}] }) end |
#run_on_changes(paths) ⇒ Object
Run on changes to watched files
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/guard/mthaml.rb', line 57 def run_on_changes(paths) paths.each do |file| file = Pathname.new(file) file_dir = file.dirname.realpath input_dir = Pathname.new([:input]).realpath input_file = file.realpath unless input_dir == file_dir output_dir = Pathname.new([:output]).realpath + file_dir.basename make_directory(output_dir) else output_dir = Pathname.new([:output]).realpath end compile_haml(input_file, output_dir) end end |
#start ⇒ Object
Run at start
32 33 34 |
# File 'lib/guard/mthaml.rb', line 32 def start run_all if [:run_at_start] end |
#stop ⇒ Object
36 37 38 |
# File 'lib/guard/mthaml.rb', line 36 def stop true end |