Class: Assets::Rule::Compile

Inherits:
Assets::Rule show all
Defined in:
lib/assets/rule/compile.rb,
lib/assets/rule/compile/css.rb,
lib/assets/rule/compile/javascript.rb,
lib/assets/rule/compile/javascript/coffescript.rb

Direct Known Subclasses

Css, Javascript

Defined Under Namespace

Classes: Css, Javascript

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Assets::Rule

#asset, #body, #fresh_at?, #rename

Class Method Details

.build(rule) ⇒ Rule::Compile

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build compiler rule

Parameters:

Returns:



72
73
74
75
76
# File 'lib/assets/rule/compile.rb', line 72

def self.build(rule)
  builder = Compile.registry.fetch(rule.mime)
  compiler = builder.new(rule)
  Rename.new(compiler.target_name, compiler)
end

.mimeMime

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mime type

Returns:



94
95
96
# File 'lib/assets/rule/compile.rb', line 94

def self.mime
  self::MIME
end

.registryHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return registry

Returns:

  • (Hash)


44
45
46
# File 'lib/assets/rule/compile.rb', line 44

def self.registry
  @registry ||= {}
end

Instance Method Details

#mimeMime

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mime type

Returns:



84
85
86
# File 'lib/assets/rule/compile.rb', line 84

def mime
  self.class.mime
end

#nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return name

Returns:

  • (String)


12
13
14
# File 'lib/assets/rule/compile.rb', line 12

def name
  input.name
end

#target_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return target name

Returns:

  • (String)


32
33
34
35
# File 'lib/assets/rule/compile.rb', line 32

def target_name
  regexp = %r(#{Regexp.escape(input.extname)}\z)
  name.gsub(regexp, mime.extname)
end

#updated_atTime

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return updated at

Returns:

  • (Time)


22
23
24
# File 'lib/assets/rule/compile.rb', line 22

def updated_at
  input.updated_at
end