Class: Extruder::DSL
- Inherits:
-
Object
- Object
- Extruder::DSL
- Defined in:
- lib/extruder/dsl.rb
Overview
Instance Attribute Summary collapse
-
#extruder ⇒ Extruder::Main
readonly
The extruder the DSL should configure.
Class Method Summary collapse
-
.evaluate(extruder, &block) ⇒ void
Configure an extruder with a passed block.
Instance Method Summary collapse
-
#concat(*args, &block) ⇒ Object
(also: #copy)
A helper method for adding a concat filter to the Extruder.
-
#filter(filter_class, *ctor_args, &block) ⇒ void
Add a filter to the pipeline, normally called from within a match block.
-
#initialize(extruder) ⇒ void
constructor
Create a new DSL to configure an extruder.
-
#input(root, pattern = '**/*') ⇒ void
Define the input location and files for the extruder.
-
#match(pattern, &block) ⇒ void
Add a match to the pipeline with a passed block containing filters that belong to it.
-
#output(root) ⇒ void
Specify the output directory for the pipeline.
Constructor Details
#initialize(extruder) ⇒ void
Create a new Extruder::DSL to configure an extruder.
41 42 43 |
# File 'lib/extruder/dsl.rb', line 41 def initialize(extruder) @extruder = extruder end |
Instance Attribute Details
#extruder ⇒ Extruder::Main (readonly)
Returns the extruder the DSL should configure.
14 15 16 |
# File 'lib/extruder/dsl.rb', line 14 def extruder @extruder end |
Class Method Details
.evaluate(extruder, &block) ⇒ void
This method returns an undefined value.
Configure an extruder with a passed block.
27 28 29 30 31 |
# File 'lib/extruder/dsl.rb', line 27 def self.evaluate(extruder, &block) # create instance of self with the pipline passed # and evalute the block within it new(extruder).instance_eval(&block) end |
Instance Method Details
#concat(*args, &block) ⇒ Object Also known as: copy
A helper method for adding a concat filter to the Extruder. If the first argument is an Array, it adds a new OrderingConcatFilter, otherwise it adds a new ConcatFilter.
145 146 147 148 149 150 151 |
# File 'lib/extruder/dsl.rb', line 145 def concat(*args, &block) if args.first.kind_of?(Array) filter(OrderingConcatFilter, *args, &block) else filter(ConcatFilter, *args, &block) end end |
#filter(filter_class, *ctor_args, &block) ⇒ void
This method returns an undefined value.
Add a filter to the pipeline, normally called from within a match block. If a filter is added without a match block, the Extruder will automatically create one that matches all input files.
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.
118 119 120 121 |
# File 'lib/extruder/dsl.rb', line 118 def filter(filter_class, *ctor_args, &block) filter = filter_class.new(*ctor_args, &block) extruder.add_filter(filter) end |
#input(root, pattern = '**/*') ⇒ void
This method returns an undefined value.
Define the input location and files for the extruder.
63 64 65 |
# File 'lib/extruder/dsl.rb', line 63 def input(root, pattern='**/*') extruder.add_input root, pattern end |
#match(pattern, &block) ⇒ void
This method returns an undefined value.
Add a match to the pipeline with a passed block containing filters that belong to it.
86 87 88 89 |
# File 'lib/extruder/dsl.rb', line 86 def match(pattern, &block) extruder.add_match pattern block.call end |
#output(root) ⇒ void
This method returns an undefined value.
Specify the output directory for the pipeline.
130 131 132 |
# File 'lib/extruder/dsl.rb', line 130 def output(root) extruder.output_root = root end |