Class: GemNewgem::Newgem

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

Instance Method Summary collapse

Methods included from Validations

#validate

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

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/gem_newgem/newgem.rb', line 13

def config
  @config
end

#gem_nameObject (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_summaryObject (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

#templateObject (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