Class: GemBootstrap::SourceGenerator Private
- Inherits:
-
Object
- Object
- GemBootstrap::SourceGenerator
- Defined in:
- lib/gem-bootstrap/source_generator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- TEMPLATES_DIR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
File.('../../templates', __dir__)
Instance Attribute Summary collapse
- #templates_dir ⇒ String readonly private
Instance Method Summary collapse
-
#generate_src ⇒ Enumerable<String,String>
private
Returns an enumerable of file paths and file contents as strings.
-
#initialize(config:, templates_dir: TEMPLATES_DIR) ⇒ SourceGenerator
constructor
private
A new instance of SourceGenerator.
Constructor Details
#initialize(config:, templates_dir: TEMPLATES_DIR) ⇒ SourceGenerator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SourceGenerator.
12 13 14 15 16 17 18 |
# File 'lib/gem-bootstrap/source_generator.rb', line 12 def initialize(config:, templates_dir: TEMPLATES_DIR) @config = config @templates_dir = templates_dir @mustache = Mustache.new @mustache.raise_on_context_miss = true @mustache.template_path = templates_dir end |
Instance Attribute Details
#templates_dir ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/gem-bootstrap/source_generator.rb', line 21 def templates_dir @templates_dir end |
Instance Method Details
#generate_src ⇒ Enumerable<String,String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an enumerable of file paths and file contents as strings.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gem-bootstrap/source_generator.rb', line 25 def generate_src Enumerator.new do |y| Dir.glob("#{templates_dir}/**/{.*,*}.mustache").each do |template_path| y << [ src_path(template_path), src_code(template_path), ] end end end |