Class: BPM::PluginProcessor
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- BPM::PluginProcessor
- Defined in:
- lib/bpm/pipeline/plugin_processor.rb
Overview
A processor that will invoke a JavaScript-based plugin provided by a package in the system. The passed method name will be invoked on the plugin.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.method_name ⇒ Object
19 20 21 |
# File 'lib/bpm/pipeline/plugin_processor.rb', line 19 def self.method_name @method_name end |
.plugin_name ⇒ Object
23 24 25 |
# File 'lib/bpm/pipeline/plugin_processor.rb', line 23 def self.plugin_name @plugin_opts["main"] end |
.with_plugin(plugin_opts, method_name) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/bpm/pipeline/plugin_processor.rb', line 10 def self.with_plugin(plugin_opts, method_name) ret = Class.new(self) ret.instance_eval do @method_name = method_name @plugin_opts = plugin_opts end ret end |
Instance Method Details
#evaluate(context, locals, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bpm/pipeline/plugin_processor.rb', line 30 def evaluate(context, locals, &block) plugin_ctx = context.environment.plugin_js_for self.class.plugin_name project = context.environment.project pkg, module_id = project.package_and_module_from_path file filepath = file.to_s # MEGAHAX!!! # This issue that we specifically target only appears when a format # is re-provided twice and the re-provider has a transport. # This prevents the format from being inappropriately wrapped in # the transport. if self.class.method_name == 'compileTransport' plugin = pkg.find_transport_plugins(project).first if !plugin || plugin['main'] != self.class.plugin_name return data end end plugin_context = BPM::PluginContext.new(pkg, module_id); minifier_js = plugin_context.minify_as_js; # CTX.additionalContext is the minifier's execution environment plugin_ctx += <<-end_eval ; // Safety CTX = #{plugin_context.to_json}; DATA = #{data.to_json}; CTX.additionalContext=#{minifier_js}; end_eval ctx = BPM.compile_js(plugin_ctx) ctx.eval("BPM_PLUGIN.#{self.class.method_name}(DATA, CTX, '#{filepath}')") end |
#prepare ⇒ Object
27 28 |
# File 'lib/bpm/pipeline/plugin_processor.rb', line 27 def prepare end |