Class: GemNewgem::Newgem
- Inherits:
-
Object
- Object
- GemNewgem::Newgem
- Includes:
- Validations
- Defined in:
- lib/gem_newgem/newgem.rb,
lib/gem_newgem/newgem/template.rb,
lib/gem_newgem/newgem/validations.rb,
lib/gem_newgem/newgem/configuration.rb
Defined Under Namespace
Modules: Validations Classes: Configuration, Template
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#gem_summary ⇒ Object
readonly
Returns the value of attribute gem_summary.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #generate! ⇒ Object
-
#initialize(gem_name, gem_summary, template) ⇒ Newgem
constructor
A new instance of Newgem.
Methods included from Validations
Constructor Details
#initialize(gem_name, gem_summary, template) ⇒ Newgem
Returns a new instance of Newgem.
15 16 17 18 19 20 21 |
# File 'lib/gem_newgem/newgem.rb', line 15 def initialize(gem_name, gem_summary, template) @config = Configuration.instance @gem_name = gem_name || '' @gem_summary = gem_summary || config.default_summary template_name = template || config.default_template @template = Template.new(template_name) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/gem_newgem/newgem.rb', line 13 def config @config end |
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
13 14 15 |
# File 'lib/gem_newgem/newgem.rb', line 13 def gem_name @gem_name end |
#gem_summary ⇒ Object (readonly)
Returns the value of attribute gem_summary.
13 14 15 |
# File 'lib/gem_newgem/newgem.rb', line 13 def gem_summary @gem_summary end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
13 14 15 |
# File 'lib/gem_newgem/newgem.rb', line 13 def template @template end |
Instance Method Details
#generate! ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/gem_newgem/newgem.rb', line 23 def generate! load "#{File.join(template.path, template.name)}.thor" args = [gem_name, template.name] opts = { gem_summary: gem_summary } const_name = "GemNewgem::Templates::#{template.name.capitalize}".constantize script = const_name.new(args, opts) script.invoke_all end |