Class: GemBootstrap::CLI

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/gem_bootstrap/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



26
27
28
# File 'lib/gem_bootstrap/cli.rb', line 26

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#copy_licenceObject

rubocop:enable all



64
65
66
# File 'lib/gem_bootstrap/cli.rb', line 64

def copy_licence
  copy_file '../../templates/MIT_LICENSE', "#{name}/LICENSE"
end

#copy_test_filesObject

rubocop:disable MethodLength, LineLength



53
54
55
56
57
58
59
60
61
# File 'lib/gem_bootstrap/cli.rb', line 53

def copy_test_files
  if options.deep_symbolize_keys[:test_framework] == 'minitest'
    template "#{TEMPLATES_DIR}/test/test_helper.rb",            "#{name}/test/test_helper.rb"
    template "#{TEMPLATES_DIR}/test/lib/newgem/test_newgem.rb", "#{name}/test/lib/#{name}/test_#{name}.rb"
  else
    template "#{TEMPLATES_DIR}/spec/spec_helper.rb",            "#{name}/spec/spec_helper.rb"
    template "#{TEMPLATES_DIR}/spec/lib/newgem/newgem_spec.rb", "#{name}/spec/lib/#{name}/#{name}_spec.rb"
  end
end

#create_git_projectObject

Create the git project to store our generated code



69
70
71
# File 'lib/gem_bootstrap/cli.rb', line 69

def create_git_project
  GemBootstrap::GitUtils.create_git_project(File.expand_path(name), name)
end

#create_lib_fileObject

rubocop:disable MethodLength, LineLength



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gem_bootstrap/cli.rb', line 31

def create_lib_file
  template "#{TEMPLATES_DIR}/README.md",             "#{name}/README.md"
  template "#{TEMPLATES_DIR}/CHANGELOG.md",          "#{name}/CHANGELOG.md"
  template "#{TEMPLATES_DIR}/dot_yardopts",          "#{name}/.yardopts"
  template "#{TEMPLATES_DIR}/dot_gitignore",         "#{name}/.gitignore"
  template "#{TEMPLATES_DIR}/Gemfile",               "#{name}/Gemfile"
  template "#{TEMPLATES_DIR}/dot_rubocop.yml",       "#{name}/.rubocop.yml"
  template "#{TEMPLATES_DIR}/bin/newgem",            "#{name}/bin/#{name}"
  template "#{TEMPLATES_DIR}/lib/newgem.rb",         "#{name}/lib/#{name}.rb"
  template "#{TEMPLATES_DIR}/lib/newgem/version.rb", "#{name}/lib/#{name}/version.rb"
  template "#{TEMPLATES_DIR}/lib/newgem/cli.rb",     "#{name}/lib/#{name}/cli.rb"
  template "#{TEMPLATES_DIR}/lib/newgem/newgem.rb",  "#{name}/lib/#{name}/#{name}.rb"

  test_framework = options.deep_symbolize_keys[:test_framework]

  template "#{TEMPLATES_DIR}/Rakefile-#{test_framework}",  "#{name}/Rakefile"
  template "#{TEMPLATES_DIR}/Guardfile-#{test_framework}", "#{name}/Guardfile"
  template "#{TEMPLATES_DIR}/newgem-#{test_framework}.gemspec.tt", "#{name}/#{name}.gemspec"
end