Class: Jass::BundleProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/jass/bundle_processor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(input) ⇒ Object



9
10
11
# File 'lib/jass/bundle_processor.rb', line 9

def call(input)
  instance.call(input)
end

.instanceObject



5
6
7
# File 'lib/jass/bundle_processor.rb', line 5

def instance
  @instance ||= new
end

Instance Method Details

#call(input) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jass/bundle_processor.rb', line 14

def call(input)
  env, filename = input.fetch(:environment), input.fetch(:filename)
  dependencies = Set.new(input.fetch(:metadata).fetch(:dependencies))
  globals = input.fetch(:metadata).fetch(:globals, {})
  bundle_root = Pathname.new(filename).dirname
  bundle = Jass.compiler.bundle(filename, Jass.input_options, globals: globals)
  dependencies += bundle.fetch('map').fetch('sources').map { |dep| Sprockets::URIUtils.build_file_digest_uri(bundle_root.join(dep).to_s) }
  
  { data: bundle.fetch('code'),
    dependencies: dependencies,
    map: bundle.fetch('map') }
end