Class: Tap::Generator::Generators::Config
- Defined in:
- lib/tap/generator/generators/config.rb
Overview
:startdoc::generator a config file generator
Generates a new config file for a task. The configurations, defaults, and documentation is determined from the source file.
Configurations for other types of configurable resources may also be generated. Specify the constant attribute identifying the resource using the ‘type’ flag. This generates a config file for the Root generator:
% tap generate config root --type generator
Constant Summary collapse
- DUMP_NEST_CONFIGS =
Dumps nested configurations.
dump_nest_configs
- DOC_FORMAT =
Dumps configurations as YAML with documentation, used when the doc config is true.
doc_format
- NODOC_FORMAT =
Dumps configurations as YAML without documentation, used when the doc config is false.
nodoc_format
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Helpers
Instance Method Summary collapse
-
#format_block ⇒ Object
A hook to set a formatting block.
- #manifest(m, name, config_name = nil) ⇒ Object
Methods inherited from Base
#action, build, convert_to_spec, #directories, #directory, #file, #initialize, #iterate, #log_relative, #on, parse_as, #path, #process, #template, #template_files
Methods included from Helpers
Constructor Details
This class inherits a constructor from Tap::Generator::Base
Instance Method Details
#format_block ⇒ Object
A hook to set a formatting block. By default format_blocks returns DOC_FORMAT or NODOC_FORMAT as per the doc config.
104 105 106 |
# File 'lib/tap/generator/generators/config.rb', line 104 def format_block doc ? DOC_FORMAT : NODOC_FORMAT end |
#manifest(m, name, config_name = nil) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/tap/generator/generators/config.rb', line 76 def manifest(m, name, config_name=nil) # setup clas = app.env.constant(name) config_name ||= clas.to_s.underscore config_file = path('config', config_name) config_file += ".yml" if File.extname(config_file).empty? # generate the dumps dumps = Configurable::Utils.dump_file( clas.configurations, config_file, nest, true, &format_block) # now put the dumps to the manifest m.directory 'config' dumps.each do |path, content| next if content.empty? && !blanks m.file(path) do |file| file << content end end end |