Class: Guard::Slim
- Defined in:
- lib/guard/slim.rb,
lib/guard/slim/version.rb
Constant Summary collapse
- ALL =
File.join '**', '*'
- Template =
::Slim::Template
- VERSION =
'0.0.1'
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Slim
constructor
A new instance of Slim.
- #run_all ⇒ Object
- #run_on_change(paths) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Slim
Returns a new instance of Slim.
11 12 13 14 15 16 17 18 |
# File 'lib/guard/slim.rb', line 11 def initialize(watchers = [], = {}) @output_root = .delete(:output_root) || Dir.getwd @input_root = .delete(:input_root) || Dir.getwd @context = .delete(:context) || Object.new @slim = .delete(:slim) || {} super watchers, end |
Instance Method Details
#run_all ⇒ Object
24 25 26 |
# File 'lib/guard/slim.rb', line 24 def run_all run_on_change all_paths end |
#run_on_change(paths) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/guard/slim.rb', line 27 def run_on_change(paths) paths.each do |path| content = render File.read(path) open(build_path(path), 'w') do |file| @slim[:pretty] ? file.puts(content) : file.write(content) end UI.info "Guard-Slim: Rendered #{ path } to #{ build_path path }" end end |
#start ⇒ Object
20 21 22 |
# File 'lib/guard/slim.rb', line 20 def start UI.info 'Guard-Slim: Waiting for changes...' end |