Class: Staticise::Watcher
- Inherits:
-
Object
- Object
- Staticise::Watcher
- Defined in:
- lib/staticise/watcher.rb
Instance Attribute Summary collapse
-
#no_coffee ⇒ Object
Returns the value of attribute no_coffee.
-
#no_haml ⇒ Object
Returns the value of attribute no_haml.
-
#no_less ⇒ Object
Returns the value of attribute no_less.
-
#no_sass ⇒ Object
Returns the value of attribute no_sass.
Instance Method Summary collapse
- #coffee(file) ⇒ Object
- #haml(file) ⇒ Object
-
#initialize(options) ⇒ Watcher
constructor
A new instance of Watcher.
- #less(file) ⇒ Object
- #process(file) ⇒ Object
- #sass(file) ⇒ Object
Constructor Details
#initialize(options) ⇒ Watcher
Returns a new instance of Watcher.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/staticise/watcher.rb', line 9 def initialize() @no_sass = !.no_sass.nil? @no_less = !.no_less.nil? @no_haml = !.no_haml.nil? @no_coffee = !.no_coffee.nil? puts "listening now with #{ self.inspect }" @listener = Listen.to!(File.join(APP_ROOT, 'app')) do |modified, added, removed| process(modified) end end |
Instance Attribute Details
#no_coffee ⇒ Object
Returns the value of attribute no_coffee.
7 8 9 |
# File 'lib/staticise/watcher.rb', line 7 def no_coffee @no_coffee end |
#no_haml ⇒ Object
Returns the value of attribute no_haml.
7 8 9 |
# File 'lib/staticise/watcher.rb', line 7 def no_haml @no_haml end |
#no_less ⇒ Object
Returns the value of attribute no_less.
7 8 9 |
# File 'lib/staticise/watcher.rb', line 7 def no_less @no_less end |
#no_sass ⇒ Object
Returns the value of attribute no_sass.
7 8 9 |
# File 'lib/staticise/watcher.rb', line 7 def no_sass @no_sass end |
Instance Method Details
#coffee(file) ⇒ Object
59 60 61 |
# File 'lib/staticise/watcher.rb', line 59 def coffee(file) Staticise::Renderer.scripts end |
#haml(file) ⇒ Object
44 45 46 |
# File 'lib/staticise/watcher.rb', line 44 def haml(file) Staticise::Renderer.pages end |
#less(file) ⇒ Object
48 49 50 |
# File 'lib/staticise/watcher.rb', line 48 def less(file) Staticise::Renderer.styles end |
#process(file) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/staticise/watcher.rb', line 22 def process(file) if file.class.eql?(Array) file.each {|f| process(f)} return end ext = File.extname(file.to_s).downcase case ext when ".sass" sass(file) unless @no_sass when ".less" less(file) unless @no_less when ".haml" haml(file) unless @no_haml when ".coffee" coffee(file) unless @no_coffee else end end |
#sass(file) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/staticise/watcher.rb', line 52 def sass(file) puts "processing #{ file }" ext = '.sass' FileUtils.mkdir_p(File.join(APP_ROOT, "public", "css")) unless File.exist?(File.join(APP_ROOT, "public", "css")) `sass #{ File.join(APP_ROOT, 'app', file) }:#{ File.join(APP_ROOT, 'public', File.dirname(file), "#{ File.basename(file, ext) }.css") }` end |