Class: OptimizeJS::SprocketsProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/optimize-js/sprockets-processor.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, &block) ⇒ SprocketsProcessor

Returns a new instance of SprocketsProcessor.



7
8
9
10
# File 'lib/optimize-js/sprockets-processor.rb', line 7

def initialize(filename, &block)
  @filename = filename
  @source   = block.call
end

Class Method Details

.call(input) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/optimize-js/sprockets-processor.rb', line 21

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

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

.run(filename, source, context) ⇒ Object



17
18
19
# File 'lib/optimize-js/sprockets-processor.rb', line 17

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

Instance Method Details

#render(context, _) ⇒ Object



12
13
14
# File 'lib/optimize-js/sprockets-processor.rb', line 12

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