Class: GemBootstrap::SourceGenerator Private

Inherits:
Object
  • Object
show all
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.

API:

  • private

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.

API:

  • private

File.expand_path('../../templates', __dir__)

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

API:

  • private



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_dirString (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.

Returns:

API:

  • private



21
22
23
# File 'lib/gem-bootstrap/source_generator.rb', line 21

def templates_dir
  @templates_dir
end

Instance Method Details

#generate_srcEnumerable<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.

Returns:

  • Returns an enumerable of file paths and file contents as strings.

API:

  • private



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