Class: JekyllAssetPipeline::Pipeline
- Inherits:
-
Object
- Object
- JekyllAssetPipeline::Pipeline
- Defined in:
- lib/jekyll_asset_pipeline/pipeline.rb
Overview
The pipeline itself, the run method is where it all happens rubocop:disable ClassLength
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#html ⇒ Object
readonly
Returns the value of attribute html.
Class Method Summary collapse
-
.cache ⇒ Object
Cache processed pipelines.
-
.clear_cache ⇒ Object
Empty cache.
-
.hash(source, manifest, options = {}) ⇒ Object
Generate hash based on manifest.
-
.puts(message) ⇒ Object
Add prefix to output.
-
.remove_staged_assets(source, config) ⇒ Object
Remove staged assets.
-
.run(manifest, prefix, source, destination, tag, type, config) ⇒ Object
Run the pipeline This is called from JekyllAssetPipeline::LiquidBlockExtensions.render or, to be more precise, from JekyllAssetPipeline::CssAssetTag.render and JekyllAssetPipeline::JavaScriptAssetTag.render rubocop:disable ParameterLists.
Instance Method Summary collapse
-
#initialize(manifest, prefix, source, destination, type, options = {}) ⇒ Pipeline
constructor
Initialize new pipeline rubocop:disable ParameterLists.
Constructor Details
#initialize(manifest, prefix, source, destination, type, options = {}) ⇒ Pipeline
Initialize new pipeline rubocop:disable ParameterLists
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 86 def initialize(manifest, prefix, source, destination, type, = {}) # rubocop:enable ParameterLists @manifest = manifest @prefix = prefix @source = source @destination = destination @type = type @options = ::JekyllAssetPipeline::DEFAULTS.merge() process end |
Instance Attribute Details
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
98 99 100 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 98 def assets @assets end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
98 99 100 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 98 def destination @destination end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
98 99 100 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 98 def html @html end |
Class Method Details
.cache ⇒ Object
Cache processed pipelines
47 48 49 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 47 def cache @cache ||= {} end |
.clear_cache ⇒ Object
Empty cache
52 53 54 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 52 def clear_cache @cache = {} end |
.hash(source, manifest, options = {}) ⇒ Object
Generate hash based on manifest
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 8 def hash(source, manifest, = {}) = DEFAULTS.merge() begin Digest::MD5.hexdigest(YAML.safe_load(manifest).map! do |path| "#{path}#{File.mtime(File.join(source, path)).to_i}" end.join.concat(.to_s)) rescue StandardError => se puts "Failed to generate hash from provided manifest: #{se.}" raise se end end |
.puts(message) ⇒ Object
Add prefix to output
64 65 66 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 64 def puts() $stdout.puts("Asset Pipeline: #{}") end |
.remove_staged_assets(source, config) ⇒ Object
Remove staged assets
57 58 59 60 61 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 57 def remove_staged_assets(source, config) config = DEFAULTS.merge(config) staging_path = File.join(source, config['staging_path']) FileUtils.rm_rf(staging_path) end |
.run(manifest, prefix, source, destination, tag, type, config) ⇒ Object
Run the pipeline This is called from JekyllAssetPipeline::LiquidBlockExtensions.render or, to be more precise, from JekyllAssetPipeline::CssAssetTag.render and JekyllAssetPipeline::JavaScriptAssetTag.render rubocop:disable ParameterLists
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jekyll_asset_pipeline/pipeline.rb', line 25 def run(manifest, prefix, source, destination, tag, type, config) # rubocop:enable ParameterLists # Get hash for pipeline hash = hash(source, manifest, config) # Check if pipeline has been cached return cache[hash], true if cache.key?(hash) begin puts "Processing '#{tag}' manifest '#{prefix}'" pipeline = new(manifest, prefix, source, destination, type, config) process_pipeline(hash, pipeline) rescue StandardError => se # Add exception to cache cache[hash] = se # Re-raise the exception raise se end end |