Class: Skyrocket::AssetManager
- Inherits:
-
Object
- Object
- Skyrocket::AssetManager
- Defined in:
- lib/skyrocket/asset_manager.rb
Instance Attribute Summary collapse
-
#asset_dirs ⇒ Object
readonly
Returns the value of attribute asset_dirs.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#lib_dirs ⇒ Object
readonly
Returns the value of attribute lib_dirs.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Instance Method Summary collapse
- #compile(&block) ⇒ Object
-
#initialize(options) ⇒ AssetManager
constructor
A new instance of AssetManager.
- #watch(&block) ⇒ Object
Constructor Details
#initialize(options) ⇒ AssetManager
Returns a new instance of AssetManager.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/skyrocket/asset_manager.rb', line 7 def initialize() @asset_dirs = [:asset_dirs].map{ |ad| File.(ad) } @lib_dirs = [:lib_dirs].map{ |ld| File.(ld) } @output_dir = File.([:output_dir]) @base_url = [:base_url] @style = [:style] @af = AssetFactory.new(@asset_dirs, @lib_dirs, @output_dir) @aw = AssetWriter.new @al = AssetLocator.new(@af) Processor.asset_factory = @af Processor.base_url = @base_url end |
Instance Attribute Details
#asset_dirs ⇒ Object (readonly)
Returns the value of attribute asset_dirs.
5 6 7 |
# File 'lib/skyrocket/asset_manager.rb', line 5 def asset_dirs @asset_dirs end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/skyrocket/asset_manager.rb', line 5 def base_url @base_url end |
#lib_dirs ⇒ Object (readonly)
Returns the value of attribute lib_dirs.
5 6 7 |
# File 'lib/skyrocket/asset_manager.rb', line 5 def lib_dirs @lib_dirs end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
5 6 7 |
# File 'lib/skyrocket/asset_manager.rb', line 5 def output_dir @output_dir end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
5 6 7 |
# File 'lib/skyrocket/asset_manager.rb', line 5 def style @style end |
Instance Method Details
#compile(&block) ⇒ Object
20 21 22 |
# File 'lib/skyrocket/asset_manager.rb', line 20 def compile(&block) update_public(&block) end |
#watch(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/skyrocket/asset_manager.rb', line 24 def watch(&block) gem 'listen', '>=0.4.2' require 'listen' begin update_public(&block) rescue Exception => e puts e. puts e.backtrace end Listen.to(*(@asset_dirs)) do |modified, added, removed| begin (modified + added).each { |am| process_change(@af.build_asset(am), &block) } removed.each do |del| as = @af.build_asset(del) process_deleted(as.output_path, &block) end rescue Exception => e puts e. puts e.backtrace end end end |