Class: Straptible::Gem::Generators::Base

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/straptible/gem/generators/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/straptible/gem/generators/base.rb', line 10

def name
  @name
end

#optsObject

Returns the value of attribute opts.



10
11
12
# File 'lib/straptible/gem/generators/base.rb', line 10

def opts
  @opts
end

Class Method Details

.startObject



12
13
14
15
16
17
# File 'lib/straptible/gem/generators/base.rb', line 12

def self.start
  tmpl_path = File.join('..', 'templates')
  source_root File.expand_path(tmpl_path, File.dirname(__FILE__))

  super
end

Instance Method Details

#gem(name_or_path) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/straptible/gem/generators/base.rb', line 68

def gem(name_or_path)
  self.destination_root = File.expand_path(name_or_path, Dir.pwd)
  self.name = File.basename(name_or_path)

  self.opts = {
    name: name,
    namespaced_path: namespaced_path,
    constant_name: constant_name,
    constant_array: constant_array,
    author: author,
    email: email
  }

  template 'Gemfile.tt', opts
  template 'LICENSE.md.tt', opts
  template 'README.md.tt', opts
  template 'newgem.gemspec.tt', "#{name}.gemspec", opts
  template 'spec/spec_helper.rb.tt', 'spec/spec_helper.rb', opts

  template 'lib/newgem.rb.tt', "lib/#{namespaced_path}.rb", opts
  template 'lib/newgem/version.rb.tt',
           "lib/#{namespaced_path}/version.rb", opts

  copy_file 'Rakefile'
  copy_file 'gitignore', '.gitignore'
  copy_file 'rspec', '.rspec'
  copy_file 'travis.yml', '.travis.yml'

  git_init
end