Class: BPM::PackagePipeline
- Inherits:
-
Sprockets::Environment
- Object
- Sprockets::Environment
- BPM::PackagePipeline
- Defined in:
- lib/bpm/pipeline/package_pipeline.rb
Overview
A sub-environment created for each package in the project. Requests for individual assets will usually end up going through one of these instances. This allows each package to have its own set of processors for each file.
Instance Attribute Summary collapse
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
Instance Method Summary collapse
-
#index ⇒ Object
Index is for caching, but it causes us problem, we don’t need the caching.
-
#initialize(pipeline, package) ⇒ PackagePipeline
constructor
A new instance of PackagePipeline.
- #mode ⇒ Object
- #package_name ⇒ Object
- #plugin_js_for(logical_path) ⇒ Object
- #project ⇒ Object
- #resolve(*args) ⇒ Object
- #shell ⇒ Object
Constructor Details
#initialize(pipeline, package) ⇒ PackagePipeline
Returns a new instance of PackagePipeline.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 17 def initialize(pipeline, package) @pipeline = pipeline @package = package super package.root_path %w(text/css application/javascript).each do |kind| unregister_processor kind, Sprockets::DirectiveProcessor register_processor kind, BPM::DirectiveProcessor end # This gunks things up. I'm not a fan - PDW unregister_postprocessor 'application/javascript', Sprockets::SafetyColons package.used_formats(project).each do |ext, opts| register_engine ".#{ext}", BPM::FormatProcessor.with_plugin(ext,opts) end package.used_preprocessors(project).each do |opts| register_preprocessor opts['mime'], BPM::PluginProcessor.with_plugin(opts, 'preprocess') end package.used_postprocessors(project).each do |opts| register_postprocessor opts['mime'], BPM::PluginProcessor.with_plugin(opts, 'postprocess') end opts = package.used_transports(project) raise TooManyTransportsError(package) if opts.size>1 if opts.size>0 register_postprocessor 'application/javascript', BPM::PluginProcessor.with_plugin(opts.first, 'compileTransport') end append_path package.root_path end |
Instance Attribute Details
#package ⇒ Object (readonly)
Returns the value of attribute package.
11 12 13 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 11 def package @package end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
11 12 13 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 11 def pipeline @pipeline end |
Instance Method Details
#index ⇒ Object
Index is for caching, but it causes us problem, we don’t need the caching
79 80 81 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 79 def index self end |
#mode ⇒ Object
63 64 65 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 63 def mode pipeline.mode end |
#package_name ⇒ Object
55 56 57 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 55 def package_name package.name end |
#plugin_js_for(logical_path) ⇒ Object
67 68 69 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 67 def plugin_js_for(logical_path) pipeline.plugin_js_for logical_path end |
#project ⇒ Object
59 60 61 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 59 def project pipeline.project end |
#resolve(*args) ⇒ Object
71 72 73 74 75 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 71 def resolve(*args) super *args rescue Sprockets::FileNotFound => e raise Sprockets::FileNotFound, "#{e.} in package '#{package_name}'" end |
#shell ⇒ Object
13 14 15 |
# File 'lib/bpm/pipeline/package_pipeline.rb', line 13 def shell @shell ||= Thor::Base.shell.new end |