Class: Luca::CompiledAsset
- Inherits:
-
Object
- Object
- Luca::CompiledAsset
- Defined in:
- lib/luca/compiled_asset.rb
Class Attribute Summary collapse
-
.asset_stores_setup ⇒ Object
Returns the value of attribute asset_stores_setup.
-
.coffeescript_assets ⇒ Object
Returns the value of attribute coffeescript_assets.
-
.less_assets ⇒ Object
Returns the value of attribute less_assets.
-
.markdown_assets ⇒ Object
Returns the value of attribute markdown_assets.
-
.sass_assets ⇒ Object
Returns the value of attribute sass_assets.
-
.scss_assets ⇒ Object
Returns the value of attribute scss_assets.
Instance Attribute Summary collapse
-
#asset ⇒ Object
Returns the value of attribute asset.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #compiler ⇒ Object
-
#initialize(type, asset) ⇒ CompiledAsset
constructor
A new instance of CompiledAsset.
- #mime_type ⇒ Object
- #output ⇒ Object
Constructor Details
#initialize(type, asset) ⇒ CompiledAsset
Returns a new instance of CompiledAsset.
27 28 29 30 31 |
# File 'lib/luca/compiled_asset.rb', line 27 def initialize type, asset CompiledAsset.setup_asset_stores @type = type @asset = asset end |
Class Attribute Details
.asset_stores_setup ⇒ Object
Returns the value of attribute asset_stores_setup.
4 5 6 |
# File 'lib/luca/compiled_asset.rb', line 4 def asset_stores_setup @asset_stores_setup end |
.coffeescript_assets ⇒ Object
Returns the value of attribute coffeescript_assets.
4 5 6 |
# File 'lib/luca/compiled_asset.rb', line 4 def coffeescript_assets @coffeescript_assets end |
.less_assets ⇒ Object
Returns the value of attribute less_assets.
4 5 6 |
# File 'lib/luca/compiled_asset.rb', line 4 def less_assets @less_assets end |
.markdown_assets ⇒ Object
Returns the value of attribute markdown_assets.
4 5 6 |
# File 'lib/luca/compiled_asset.rb', line 4 def markdown_assets @markdown_assets end |
.sass_assets ⇒ Object
Returns the value of attribute sass_assets.
4 5 6 |
# File 'lib/luca/compiled_asset.rb', line 4 def sass_assets @sass_assets end |
.scss_assets ⇒ Object
Returns the value of attribute scss_assets.
4 5 6 |
# File 'lib/luca/compiled_asset.rb', line 4 def scss_assets @scss_assets end |
Instance Attribute Details
#asset ⇒ Object
Returns the value of attribute asset.
25 26 27 |
# File 'lib/luca/compiled_asset.rb', line 25 def asset @asset end |
#type ⇒ Object
Returns the value of attribute type.
25 26 27 |
# File 'lib/luca/compiled_asset.rb', line 25 def type @type end |
Class Method Details
.find_by_type_and_id(type, id) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/luca/compiled_asset.rb', line 51 def self.find_by_type_and_id type, id if ["markdown", "haml","coffeescript","sass","scss","less"].include?(type) asset = self.send("#{ type }_assets".to_sym) asset = asset && asset.show(:id) if !asset.nil? new(type, asset) end end end |
.setup_asset_stores ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/luca/compiled_asset.rb', line 14 def self.setup_asset_stores return if self.asset_stores_setup == true self.coffeescript_assets = Luca::Collection.new(namespace:"coffeescripts",backend:"file") self.sass_assets = Luca::Collection.new(namespace:"sass_stylesheets",backend:"file") self.scss_assets = Luca::Collection.new(namespace:"scss_stylesheets",backend:"file") self.less_assets = Luca::Collection.new(namespace:"less_stylesheets",backend:"file") self.markdown_assets = Luca::Collection.new(namespace:"markdown_assets",backend:"file") self.asset_stores_setup = true end |
Instance Method Details
#compiler ⇒ Object
33 34 35 |
# File 'lib/luca/compiled_asset.rb', line 33 def compiler @compiler ||= AssetCompiler.new(input: asset['input'], type: type) end |
#mime_type ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/luca/compiled_asset.rb', line 41 def mime_type if type == "coffeescript" || type == "haml" || type == "mustache" "text/javascript" elsif type == "markdown" "text/html" else "text/css" end end |
#output ⇒ Object
37 38 39 |
# File 'lib/luca/compiled_asset.rb', line 37 def output compiler.output end |