Class: Antelope::Generator::Group
- Extended by:
- Antelope::Generator
- Defined in:
- lib/antelope/generator/group.rb
Overview
For use to use multiple generators as a bundle. Works exactly like a normal generator, i.e. responds to both Base.register_as and #generate, but also responds to #register_generator, like Antelope::Generator. Any generators registered to the group are used to generate the files.
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#generate ⇒ void
Generates files using the generators contained within this group.
-
#generators ⇒ Array<Generator::Base>
private
Retrieve a list of all of the generators that are contained within this group.
-
#initialize(*_) ⇒ Group
constructor
Initialize the group generator.
Methods included from Antelope::Generator
directives, register_generator
Methods inherited from Base
directive, directives, inherited, register_as, source_root, #template
Methods included from Base::Extra
Methods included from Base::Coerce
#coerce_directive_class, #coerce_directive_value, #coerce_nested_hash, #directives
Constructor Details
#initialize(*_) ⇒ Group
Initialize the group generator. Calls Base#initialize, and then instantizes all of the generators in the group.
18 19 20 21 22 23 24 |
# File 'lib/antelope/generator/group.rb', line 18 def initialize(*_) super generators.map! do |gen| gen.new(*_) end end |
Instance Method Details
#generate ⇒ void
This method returns an undefined value.
Generates files using the generators contained within this group. If it encounters an error in one of the generators, it will continue to try to generate the rest of the generators. It will then raise the last error given at the end.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/antelope/generator/group.rb', line 32 def generate error = nil generators.map do |gen| begin gen.generate rescue => e puts "Error running #{gen.class}: #{e.}" error = e rescue SyntaxError => e puts "Error running #{gen.class}: #{e.}" error = e end end raise error if error end |
#generators ⇒ Array<Generator::Base> (private)
Retrieve a list of all of the generators that are contained within this group.
55 56 57 |
# File 'lib/antelope/generator/group.rb', line 55 def generators @_generators ||= self.class.generators.values end |