Class: Assets::Compiler::Base
- Inherits:
-
Object
- Object
- Assets::Compiler::Base
- Defined in:
- lib/assets/compiler/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#destination_path ⇒ Object
Returns the value of attribute destination_path.
-
#source_path ⇒ Object
Returns the value of attribute source_path.
-
#staleness_checker ⇒ Object
Returns the value of attribute staleness_checker.
Class Method Summary collapse
Instance Method Summary collapse
- #compile! ⇒ Object
- #destination_for_file(file) ⇒ Object
-
#initialize(paths) ⇒ Base
constructor
A new instance of Base.
Constructor Details
Instance Attribute Details
#destination_path ⇒ Object
Returns the value of attribute destination_path.
6 7 8 |
# File 'lib/assets/compiler/base.rb', line 6 def destination_path @destination_path end |
#source_path ⇒ Object
Returns the value of attribute source_path.
6 7 8 |
# File 'lib/assets/compiler/base.rb', line 6 def source_path @source_path end |
#staleness_checker ⇒ Object
Returns the value of attribute staleness_checker.
6 7 8 |
# File 'lib/assets/compiler/base.rb', line 6 def staleness_checker @staleness_checker end |
Class Method Details
.create(type, paths) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/assets/compiler/base.rb', line 8 def self.create(type, paths) begin klass = Assets::Compiler.const_get(type.to_s.capitalize) rescue NameError raise InvalidCompiler, "No compiler found for #{type}" end klass.new(paths) end |
Instance Method Details
#compile! ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/assets/compiler/base.rb', line 23 def compile! outdated_files.each do |file| destination_file = destination_for_file(file) FileUtils.mkdir_p(File.dirname(destination_file)) compile_file(file, destination_file) end end |
#destination_for_file(file) ⇒ Object
31 32 33 34 |
# File 'lib/assets/compiler/base.rb', line 31 def destination_for_file(file) relative_path = file.sub(source_path, '') File.join(destination_path, relative_path) end |