Class: Content::Pipeline
- Inherits:
-
Object
- Object
- Content::Pipeline
- Defined in:
- lib/content/pipeline.rb,
lib/content/pipeline/filters.rb,
lib/content/pipeline/version.rb
Defined Under Namespace
Modules: Filters, Jekyll Classes: Filter
Constant Summary collapse
- VERSION =
"1.2.0"
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#filter(out, opts = {}) ⇒ Object
————————————————————————- ————————————————————————-.
-
#initialize(filters = nil, opts = nil) ⇒ Pipeline
constructor
————————————————————————- ————————————————————————-.
Constructor Details
#initialize(filters = nil, opts = nil) ⇒ Pipeline
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/content/pipeline.rb', line 14 def initialize(filters = nil, opts = nil) if filters.is_a?(Hash) && opts.nil? opts = filters filters = nil end opts = {} if opts.nil? filters = Filters::DEFAULT_FILTERS if filters.nil? @opts, @filters = opts.freeze, [ filters ].flatten.freeze end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
7 8 9 |
# File 'lib/content/pipeline.rb', line 7 def filters @filters end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
7 8 9 |
# File 'lib/content/pipeline.rb', line 7 def opts @opts end |
Instance Method Details
#filter(out, opts = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/content/pipeline.rb', line 31 def filter(out, opts = {}) return out if out.nil? || out.empty? || @filters.empty? opts = @opts.deep_merge(opts) @filters.each_with_index do |f, i| fopts = opts.values_at(*to_opt(f)).delete_if(&:nil?). \ reduce({}, :merge) out = f.new(out, fopts).run(@filters[i + 1]) end out end |