Module: Gemsmith::Helpers::Template

Included in:
CLI
Defined in:
lib/gemsmith/helpers/template.rb

Overview

Provides Thor CLI helper methods. These methods are necessary to resolve %% file and folder variables and render dynamic content within the Thor ERB templates structure.

Instance Method Summary collapse

Instance Method Details

#gem_classObject



16
17
18
# File 'lib/gemsmith/helpers/template.rb', line 16

def gem_class
  configuration.dig :gem, :class
end

#gem_nameObject



8
9
10
# File 'lib/gemsmith/helpers/template.rb', line 8

def gem_name
  configuration.dig :gem, :name
end

#gem_pathObject



12
13
14
# File 'lib/gemsmith/helpers/template.rb', line 12

def gem_path
  configuration.dig :gem, :path
end

#rails_versionObject



20
21
22
# File 'lib/gemsmith/helpers/template.rb', line 20

def rails_version
  configuration.dig :versions, :rails
end

#render_namespace(&block) ⇒ Object



24
25
26
27
# File 'lib/gemsmith/helpers/template.rb', line 24

def render_namespace &block
  body = capture(&block) if block_given?
  concat Gem::ModuleFormatter.new(gem_class).render(body)
end