Class: Rake::Pipeline::DSL
- Inherits:
-
Object
- Object
- Rake::Pipeline::DSL
- Defined in:
- lib/rake-pipeline/dsl.rb
Overview
Instance Attribute Summary collapse
-
#pipeline ⇒ Pipeline
readonly
The pipeline the DSL should configure.
Class Method Summary collapse
-
.evaluate(pipeline, &block) ⇒ void
Configure a pipeline with a passed in block.
Instance Method Summary collapse
-
#filter(filter_class, *ctor_args, &block) ⇒ void
Add a filter to the pipeline.
-
#initialize(pipeline) ⇒ void
constructor
Create a new DSL to configure a pipeline.
-
#input(root, glob = "**/*") ⇒ void
Define the input location and files for the 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.
-
#tmpdir(root) ⇒ void
Specify the location of the temporary directory.
Constructor Details
#initialize(pipeline) ⇒ void
Create a new Rake::Pipeline::DSL to configure a pipeline.
35 36 37 |
# File 'lib/rake-pipeline/dsl.rb', line 35 def initialize(pipeline) @pipeline = pipeline end |
Instance Attribute Details
#pipeline ⇒ Pipeline (readonly)
Returns the pipeline the DSL should configure.
13 14 15 |
# File 'lib/rake-pipeline/dsl.rb', line 13 def pipeline @pipeline end |
Class Method Details
.evaluate(pipeline, &block) ⇒ void
This method returns an undefined value.
Configure a pipeline with a passed in block.
23 24 25 26 27 28 |
# File 'lib/rake-pipeline/dsl.rb', line 23 def self.evaluate(pipeline, &block) new(pipeline).instance_eval(&block) copy_filter = Rake::Pipeline::ConcatFilter.new copy_filter.output_name_generator = proc { |input| input } pipeline.add_filter(copy_filter) end |
Instance Method Details
#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.
80 81 82 83 |
# File 'lib/rake-pipeline/dsl.rb', line 80 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.
Define the input location and files for the pipeline.
54 55 56 57 |
# File 'lib/rake-pipeline/dsl.rb', line 54 def input(root, glob="**/*") pipeline.input_root = root pipeline.input_glob = 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.
116 117 118 119 120 121 |
# File 'lib/rake-pipeline/dsl.rb', line 116 def match(pattern, &block) matcher = pipeline.copy(Matcher, &block) matcher.glob = pattern pipeline.add_filter matcher matcher end |
#output(root) ⇒ void
This method returns an undefined value.
Specify the output directory for the pipeline.
127 128 129 |
# File 'lib/rake-pipeline/dsl.rb', line 127 def output(root) pipeline.output_root = root end |
#tmpdir(root) ⇒ void
This method returns an undefined value.
Specify the location of the temporary directory. Filters will store intermediate build artifacts here.
This defaults “tmp” in the current working directory.
139 140 141 |
# File 'lib/rake-pipeline/dsl.rb', line 139 def tmpdir(root) pipeline.tmpdir = root end |