Module: Jammit::Lite
- Defined in:
- lib/jammit_lite.rb,
lib/jammit/lite/asset.rb,
lib/jammit/lite/helper.rb,
lib/jammit/lite/routes.rb
Defined Under Namespace
Modules: Helper, Routes Classes: Asset
Class Method Summary collapse
-
.asset_hash(type) ⇒ Object
returns hash from yaml with given type, e.g.
-
.assets(type) ⇒ Object
returns hash of bundle file arrays keyed by bundle name.
-
.hash_to_assets(hash) ⇒ Object
typecasts paths in given Hash into Assets.
-
.yaml ⇒ Object
returns hash from config/assets.yml.
Class Method Details
.asset_hash(type) ⇒ Object
returns hash from yaml with given type, e.g. :javascripts expands all wildcard paths
22 23 24 25 26 27 28 |
# File 'lib/jammit_lite.rb', line 22 def self.asset_hash(type) yaml[type].symbolize_keys.inject({}) do |out,pair| bundle,files = pair out[bundle] = Jammit::Lite::Bundle.(files) out end end |
.assets(type) ⇒ Object
returns hash of bundle file arrays keyed by bundle name
6 7 8 9 |
# File 'lib/jammit_lite.rb', line 6 def self.assets(type) hash = asset_hash(type) hash_to_assets(hash) end |
.hash_to_assets(hash) ⇒ Object
typecasts paths in given Hash into Assets
12 13 14 15 16 17 18 |
# File 'lib/jammit_lite.rb', line 12 def self.hash_to_assets(hash) hash.inject({}) do |out,array| key,paths = array out[key] = paths.map { |path| Jammit::Lite::Asset.new(path) } out end end |
.yaml ⇒ Object
returns hash from config/assets.yml
31 32 33 34 |
# File 'lib/jammit_lite.rb', line 31 def self.yaml yaml = File.open("#{Rails.root}/config/assets.yml") YAML::load(yaml).symbolize_keys end |