Class: Coyote::Compiler
- Inherits:
-
Object
- Object
- Coyote::Compiler
- Defined in:
- lib/coyote/compiler.rb
Instance Attribute Summary collapse
-
#bundle ⇒ Object
readonly
Returns the value of attribute bundle.
Instance Method Summary collapse
- #compile! ⇒ Object
-
#initialize(input, output, options = {}) ⇒ Compiler
constructor
A new instance of Compiler.
- #save! ⇒ Object
- #watch ⇒ Object
Constructor Details
Instance Attribute Details
#bundle ⇒ Object (readonly)
Returns the value of attribute bundle.
8 9 10 |
# File 'lib/coyote/compiler.rb', line 8 def bundle @bundle end |
Instance Method Details
#compile! ⇒ Object
17 18 19 20 |
# File 'lib/coyote/compiler.rb', line 17 def compile! save! watch if @options.fetch(:watch, false) end |
#save! ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/coyote/compiler.rb', line 23 def save! notify "\n" + @bundle.manifest unless @options.fetch(:quiet, false) time = Benchmark.realtime do @bundle.compress! if @options.fetch(:compress, false) @bundle.save! end notify "Saved bundle to #{@output} [#{@bundle.files.length} files] [#{'%.4f' % time} sec]", :timestamp, :success end |
#watch ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/coyote/compiler.rb', line 34 def watch listener = Coyote::FSListener.new listener.on_change do |changed_files| changed_files = @bundle.files & changed_files.map {|file| File. file } if changed_files.length > 0 notify "Detected change, recompiling...", :warning, :timestamp @bundle.update! changed_files save! end end notify "Watching for changes to your bundle. ctrl+c to stop.", :timestamp listener.start end |