Class: AssetTrip::Config
- Inherits:
-
Object
- Object
- AssetTrip::Config
- Defined in:
- lib/asset_trip/config.rb
Instance Attribute Summary collapse
-
#assets_hash ⇒ Object
readonly
Returns the value of attribute assets_hash.
-
#load_paths ⇒ Object
readonly
Returns the value of attribute load_paths.
Class Method Summary collapse
Instance Method Summary collapse
- #assets ⇒ Object
- #bundle! ⇒ Object
-
#initialize(&block) ⇒ Config
constructor
A new instance of Config.
- #resolve_file(asset_type, file) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 |
# File 'lib/asset_trip/config.rb', line 12 def initialize(&block) @load_paths = Hash.new { LoadPath.new } @load_paths[:javascripts] = LoadPath.new(["app/javascripts"]) @load_paths[:stylesheets] = LoadPath.new(["app/stylesheets"]) @assets_hash = {} instance_eval(&block) end |
Instance Attribute Details
#assets_hash ⇒ Object (readonly)
Returns the value of attribute assets_hash.
9 10 11 |
# File 'lib/asset_trip/config.rb', line 9 def assets_hash @assets_hash end |
#load_paths ⇒ Object (readonly)
Returns the value of attribute load_paths.
10 11 12 |
# File 'lib/asset_trip/config.rb', line 10 def load_paths @load_paths end |
Class Method Details
.from_file(dir) ⇒ Object
4 5 6 7 |
# File 'lib/asset_trip/config.rb', line 4 def self.from_file(dir) source = File.read(dir.join("assets.rb")) eval "self.new {( " + source + "\n )}" end |
Instance Method Details
#assets ⇒ Object
33 34 35 |
# File 'lib/asset_trip/config.rb', line 33 def assets @assets_hash.values end |
#bundle! ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/asset_trip/config.rb', line 21 def bundle! assets.each do |asset| asset.bundle! end ManifestWriter.new(assets).write! end |
#resolve_file(asset_type, file) ⇒ Object
29 30 31 |
# File 'lib/asset_trip/config.rb', line 29 def resolve_file(asset_type, file) @load_paths[asset_type].resolve(file) end |