Class: Radical::Assets

Inherits:
Object
  • Object
show all
Defined in:
lib/radical/assets.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAssets

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

#assetsObject

Returns the value of attribute assets.



5
6
7
# File 'lib/radical/assets.rb', line 5

def assets
  @assets
end

#assets_pathObject

Returns the value of attribute assets_path.



5
6
7
# File 'lib/radical/assets.rb', line 5

def assets_path
  @assets_path
end

#compiledObject

Returns the value of attribute compiled.



5
6
7
# File 'lib/radical/assets.rb', line 5

def compiled
  @compiled
end

Instance Method Details

#brotliObject



29
30
31
# File 'lib/radical/assets.rb', line 29

def brotli
  @compressor = :brotli
end

#compileObject



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

#gzipObject



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