Sha256: 434e5be6de75fd53b92794ad5dc98d153f86fc127a0a766e7f1ca6b32cffa6be
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
require 'sprockets' module BPM class TransportProcessor < Sprockets::Processor def evaluate(context, locals) project = context.environment.project pkg, module_id = project.package_and_module_from_path file transport_plugins = pkg.transport_plugins(project) # No transport, just return the existing data return data if transport_plugins.empty? if transport_plugins.size > 1 # TODO: Maybe make custom error for this raise "#{pkg.name} depends on #{transport_plugins.size} packages that define transport plugins. " \ "Select a plugin by adding a `plugin:transport` property to the package.json" end project_path = project.root_path.to_s project_path << '/' if project_path !~ /\/$/ filepath = file.sub(/^#{project_path}/,'') # relative file path from project transport_path = context.resolve project.path_from_module(transport_plugins.first) ctx = context.environment.js_context_for transport_path out = '' V8::C::Locker() do ctx["PACKAGE_INFO"] = pkg.attributes ctx["DATA"] = data out = ctx.eval("exports.compileTransport(DATA, PACKAGE_INFO, '#{module_id}', '#{filepath}');") end out + "\n\n" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bpm-0.1.3 | lib/bpm/pipeline/transport_processor.rb |
bpm-0.1.2 | lib/bpm/pipeline/transport_processor.rb |