Class: Radical::Assets
- Inherits:
-
Object
- Object
- Radical::Assets
- Defined in:
- lib/radical/assets.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
Returns the value of attribute assets.
-
#assets_path ⇒ Object
Returns the value of attribute assets_path.
-
#compiled ⇒ Object
Returns the value of attribute compiled.
Instance Method Summary collapse
- #brotli ⇒ Object
- #compile ⇒ Object
- #css(filenames) ⇒ Object
- #gzip ⇒ Object
-
#initialize ⇒ Assets
constructor
A new instance of Assets.
- #js(filenames) ⇒ Object
- #prepend_assets_path(path) ⇒ Object
Constructor Details
#initialize ⇒ Assets
Returns a new instance of Assets.
7 8 9 10 11 12 13 14 15 |
# File 'lib/radical/assets.rb', line 7 def initialize @assets = { css: [], js: [] } @compressor = :none @assets_path = File.join(__dir__, 'assets') @compiled = {} end |
Instance Attribute Details
#assets ⇒ Object
Returns the value of attribute assets.
5 6 7 |
# File 'lib/radical/assets.rb', line 5 def assets @assets end |
#assets_path ⇒ Object
Returns the value of attribute assets_path.
5 6 7 |
# File 'lib/radical/assets.rb', line 5 def assets_path @assets_path end |
#compiled ⇒ Object
Returns the value of attribute compiled.
5 6 7 |
# File 'lib/radical/assets.rb', line 5 def compiled @compiled end |
Instance Method Details
#brotli ⇒ Object
29 30 31 |
# File 'lib/radical/assets.rb', line 29 def brotli @compressor = :brotli end |
#compile ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/radical/assets.rb', line 37 def compile css = @assets[:css].map { |f| Asset.new(f, path: File.join(@assets_path, 'css')) } js = @assets[:js].map { |f| Asset.new(f, path: File.join(@assets_path, 'js')) } @compiled[:css] = AssetCompiler.compile(css, path: @assets_path, compressor: @compressor) @compiled[:js] = AssetCompiler.compile(js, path: @assets_path, compressor: @compressor) end |
#css(filenames) ⇒ Object
17 18 19 |
# File 'lib/radical/assets.rb', line 17 def css(filenames) @assets[:css] = filenames end |
#gzip ⇒ Object
33 34 35 |
# File 'lib/radical/assets.rb', line 33 def gzip @compressor = :gzip end |
#js(filenames) ⇒ Object
21 22 23 |
# File 'lib/radical/assets.rb', line 21 def js(filenames) @assets[:js] = filenames end |
#prepend_assets_path(path) ⇒ Object
25 26 27 |
# File 'lib/radical/assets.rb', line 25 def prepend_assets_path(path) @assets_path = File.join(path, 'assets') end |