Sha256: dd0069938c911ae4f5726b751304b6e24b210295c827a0986a82d4810c50098b

Contents?: true

Size: 549 Bytes

Versions: 6

Compression:

Stored size: 549 Bytes

Contents

module RequirejsOptimizer

  module Step

    class Digestify < Base

      def initialize
        Rails.application.initialize!(:assets) unless Rails.application.assets.present?
      end

      def perform(*)
        RequirejsOptimizer.target_files.each do |f|
          digestify_file f
        end
      end

      def digestify_file(path)
        digest = Rails.application.assets.file_digest(path).hexdigest
        new_path = path.gsub(/\.([^\.]*)$/) { "-#{digest}.#{$1}" }
        FileUtils.cp(path, new_path)
      end

    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
requirejs_optimizer-0.4.2 lib/requirejs_optimizer/step/digestify.rb
requirejs_optimizer-0.3.2 lib/requirejs_optimizer/step/digestify.rb
requirejs_optimizer-0.4.1 lib/requirejs_optimizer/step/digestify.rb
requirejs_optimizer-0.2.0 lib/requirejs_optimizer/step/digestify.rb
requirejs_optimizer-0.1.0 lib/requirejs_optimizer/step/digestify.rb
requirejs_optimizer-0.0.5 lib/requirejs_optimizer/step/digestify.rb