class Sprockets::Rollup

Attributes

configuration[RW]
cache_key[R]

Public Class Methods

cache_key() click to toggle source
# File lib/sprockets/rollup.rb, line 36
def cache_key
  instance.cache_key
end
call(input) click to toggle source
# File lib/sprockets/rollup.rb, line 32
def call(input)
  instance.call(input)
end
configuration_hash() click to toggle source
# File lib/sprockets/rollup.rb, line 12
def configuration_hash
  configuration.to_h.reduce({}) do |hash, (key, val)|
    hash[key.to_s] = val
    hash
  end
end
configure() { |configuration| ... } click to toggle source
# File lib/sprockets/rollup.rb, line 23
def configure
  self.configuration ||= OpenStruct.new
  yield configuration
end
instance() click to toggle source
# File lib/sprockets/rollup.rb, line 19
def instance
  @instance ||= new
end
new(options = {}) click to toggle source
# File lib/sprockets/rollup.rb, line 48
def initialize(options = {})
  @options = configuration_hash.merge(options).freeze
end
reset_configuration() click to toggle source
# File lib/sprockets/rollup.rb, line 28
def reset_configuration
  self.configuration = OpenStruct.new
end

Public Instance Methods

call(input) click to toggle source
# File lib/sprockets/rollup.rb, line 52
def call(input)
  transform input
end
compile(input) click to toggle source
# File lib/sprockets/rollup.rb, line 67
def compile(input)
  path_to_buble  = File.join File.dirname(__FILE__), "buble.js"
  output = nil

  IO.popen(['node', path_to_buble], 'r+') do |pipe|
    pipe.write(input)
    pipe.close_write
    output = pipe.read
  end

  raise ArgumentError, output if $? != 0
  output
end
configuration_hash() click to toggle source
# File lib/sprockets/rollup.rb, line 44
def configuration_hash
  self.class.configuration_hash
end
rollup(input) click to toggle source
# File lib/sprockets/rollup.rb, line 60
def rollup(input)
  path_to_rollup = File.join File.dirname(__FILE__), "rollup.js"
  output = `node #{path_to_rollup} #{input[:filename].shellescape}`
  raise ArgumentError, output if $? != 0
  output
end
transform(input) click to toggle source
# File lib/sprockets/rollup.rb, line 56
def transform(input)
  compile(rollup(input))
end