Class: RequirejsOptimizer::Step::Digestify
- Defined in:
- lib/requirejs_optimizer/step/digestify.rb
Instance Method Summary collapse
- #digestify_file(path) ⇒ Object
-
#initialize ⇒ Digestify
constructor
A new instance of Digestify.
- #perform ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ Digestify
Returns a new instance of Digestify.
7 8 9 |
# File 'lib/requirejs_optimizer/step/digestify.rb', line 7 def initialize Rails.application.initialize!(:assets) unless Rails.application.assets.present? end |
Instance Method Details
#digestify_file(path) ⇒ Object
17 18 19 20 21 |
# File 'lib/requirejs_optimizer/step/digestify.rb', line 17 def digestify_file(path) digest = Rails.application.assets.file_digest(path).hexdigest new_path = path.gsub(/\.([^\.]*)$/) { "-#{digest}.#{$1}" } FileUtils.cp(path, new_path) end |
#perform ⇒ Object
11 12 13 14 15 |
# File 'lib/requirejs_optimizer/step/digestify.rb', line 11 def perform(*) RequirejsOptimizer.target_files.each do |f| digestify_file f end end |