Sha256: 49d4a24a38027209acf028fdc809318dfebb7a07030be6368dd2256fa5e869bc

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

# Sprockets 2, 3 & 4 interface
# https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#registering-all-versions-of-sprockets-in-processors
class OptimizeJS::SprocketsProcessor
  def initialize(filename, &block)
    @filename = filename
    @source   = block.call
  end

  def render(context, _)
    self.class.run(@filename, @source, context)
  end

  class << self
    def run(filename, source, context)
      OptimizeJS.perform(source)
    end

    def call(input)
      filename = input[:filename]
      source   = input[:data]
      context  = input[:environment].context_class.new(input)

      result = run(filename, source, context)
      context.metadata.merge(data: result)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
optimize-js-1.0.3 lib/optimize-js/sprockets-processor.rb
optimize-js-1.0.2 lib/optimize-js/sprockets-processor.rb