Class: Rake::Pipeline::DSL::PipelineDSL
- Inherits:
-
Object
- Object
- Rake::Pipeline::DSL::PipelineDSL
- Defined in:
- lib/rake-pipeline/dsl/pipeline_dsl.rb
Overview
This class is used by ProjectDSL to provide a convenient DSL for configuring a pipeline.
All instance methods of PipelineDSL are available in the context the block passed to Rake::Pipeline.
Rake::Pipeline.build.
Instance Attribute Summary collapse
-
#pipeline ⇒ Pipeline
readonly
The pipeline the DSL should configure.
Class Method Summary collapse
-
.evaluate(pipeline, options, &block) ⇒ void
Configure a pipeline with a passed in block.
Instance Method Summary collapse
-
#concat(*args, &block) ⇒ Object
(also: #copy)
A helper method for adding a concat filter to the pipeline.
-
#filter(filter_class, *ctor_args, &block) ⇒ void
Add a filter to the pipeline.
-
#initialize(pipeline) ⇒ void
constructor
Create a new PipelineDSL to configure a pipeline.
-
#input(root, glob = "**/*") ⇒ void
Add an input location and files to a pipeline.
-
#match(pattern, &block) ⇒ Matcher
Apply a number of filters, but only to files matching a particular pattern.
-
#output(root) ⇒ void
Specify the output directory for the pipeline.
Constructor Details
#initialize(pipeline) ⇒ void
Create a new Rake::Pipeline::DSL::PipelineDSL to configure a pipeline.
53 54 55 |
# File 'lib/rake-pipeline/dsl/pipeline_dsl.rb', line 53 def initialize(pipeline) @pipeline = pipeline end |
Instance Attribute Details
#pipeline ⇒ Pipeline (readonly)
Returns the pipeline the DSL should configure.
11 12 13 |
# File 'lib/rake-pipeline/dsl/pipeline_dsl.rb', line 11 def pipeline @pipeline end |
Class Method Details
.evaluate(pipeline, options, &block) ⇒ void
This method returns an undefined value.
Configure a pipeline with a passed in block.
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 |
# File 'lib/rake-pipeline/dsl/pipeline_dsl.rb', line 21 def self.evaluate(pipeline, , &block) dsl = new(pipeline) # If any before filters, apply them to the pipeline. # They will be run in reverse of insertion order. if before_filters = [:before_filters] before_filters.each do |klass, args, block| dsl.filter klass, *args, &block end end # Evaluate the block in the context of the DSL. dsl.instance_eval(&block) # If any after filters, apply them to the pipeline. # They will be run in insertion order. if after_filters = [:after_filters] after_filters.each do |klass, args, block| dsl.filter klass, *args, &block end end # the FinalizingFilter should always come after all # user specified after filters pipeline.finalize end |
Instance Method Details
#concat(*args, &block) ⇒ Object Also known as: copy
A helper method for adding a concat filter to the pipeline. If the first argument is an Array, it adds a new OrderingConcatFilter, otherwise it adds a new ConcatFilter.
157 158 159 160 161 162 163 |
# File 'lib/rake-pipeline/dsl/pipeline_dsl.rb', line 157 def concat(*args, &block) if args.first.kind_of?(Array) filter(Rake::Pipeline::OrderingConcatFilter, *args, &block) else filter(Rake::Pipeline::ConcatFilter, *args, &block) end end |
#filter(filter_class, *ctor_args, &block) ⇒ void
This method returns an undefined value.
Add a filter to the pipeline.
In addition to a filter class, #filter takes a block that describes how the filter should map input files to output files.
By default, the block maps an input file into an output file with the same name.
Any additional arguments passed to #filter will be passed on to the filter class’s constructor.
99 100 101 102 |
# File 'lib/rake-pipeline/dsl/pipeline_dsl.rb', line 99 def filter(filter_class, *ctor_args, &block) filter = filter_class.new(*ctor_args, &block) pipeline.add_filter(filter) end |
#input(root, glob = "**/*") ⇒ void
This method returns an undefined value.
Add an input location and files to a pipeline.
74 75 76 |
# File 'lib/rake-pipeline/dsl/pipeline_dsl.rb', line 74 def input(root, glob="**/*") pipeline.add_input root, glob end |
#match(pattern, &block) ⇒ Matcher
Apply a number of filters, but only to files matching a particular pattern.
Inside the block passed to match, you may specify any number of filters that should be applied to files matching the pattern.
134 135 136 137 138 139 |
# File 'lib/rake-pipeline/dsl/pipeline_dsl.rb', line 134 def match(pattern, &block) matcher = pipeline.copy(Matcher, &block) matcher.glob = pattern pipeline.add_filter matcher matcher end |