Class: Luca::AssetCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/luca/asset_compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AssetCompiler

Returns a new instance of AssetCompiler.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/luca/asset_compiler.rb', line 5

def initialize(options={})
  @input    = options[:input]
  @type     = options[:type] 
  @name     = options[:name]

  @file     = options[:file]

  if file
    @name ||= File.basename(file).split('.').first
    @input ||= IO.read(file)
  end
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/luca/asset_compiler.rb', line 3

def file
  @file
end

#inputObject

Returns the value of attribute input.



3
4
5
# File 'lib/luca/asset_compiler.rb', line 3

def input
  @input
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/luca/asset_compiler.rb', line 3

def name
  @name
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/luca/asset_compiler.rb', line 3

def type
  @type
end

Instance Method Details

#compiledObject



22
23
24
# File 'lib/luca/asset_compiler.rb', line 22

def compiled
  compile_file_using_sprockets rescue compile_file_manually
end

#filenameObject



26
27
28
# File 'lib/luca/asset_compiler.rb', line 26

def filename
  @filename ||= "#{ rand(36**16).to_s(36).slice(0,8) }__#{ name }#{ extension }"
end

#outputObject



18
19
20
# File 'lib/luca/asset_compiler.rb', line 18

def output
  @output ||= compiled
end