55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/legion/lex.rb', line 55
def create(name)
if Dir.pwd.include?('lex-')
say('already inside a lex_gen, try moving to a different directory', :red)
return nil
end
vars = { filename: "lex-#{name}", class_name: name.capitalize, lex: name }
filename = vars[:filename]
template('cli/lex/templates/base/gemspec.erb', "#{filename}/#{filename}.gemspec", vars)
template('cli/lex/templates/base/gemfile.erb', "#{filename}/Gemfile", vars)
template('cli/lex/templates/base/gitignore.erb', "#{filename}/.gitignore", vars)
template('cli/lex/templates/base/lic.erb', "#{filename}/LICENSE", vars)
template('cli/lex/templates/base/rubocop.yml.erb', "#{filename}/.rubocop.yml", vars)
template('cli/lex/templates/base/readme.md.erb', "#{filename}/README.md", **vars)
template('cli/lex/templates/base/lex.erb', "#{filename}/lib/legion/extensions/#{name}.rb", vars)
template('cli/lex/templates/base/version.erb', "#{filename}/lib/legion/extensions/#{name}/version.rb", vars)
template('cli/lex/templates/base/spec_helper.rb.erb', "#{filename}/spec/spec_helper.rb", vars)
template('cli/lex/templates/base/lex_spec.erb', "#{filename}/spec/legion/#{name}_spec.rb", vars)
template('cli/lex/templates/base/github_rspec.yml.erb', "#{filename}/.github/workflows/rspec.yml", vars)
template('cli/lex/templates/base/github_rubocop.yml.erb', "#{filename}/.github/workflows/rubocop.yml", vars)
return if !options[:git_init] && !options[:bundle_install]
run("cd lex_gen-#{filename}")
if options[:git_init]
run('git init')
run('git add .')
run('git commit -m \'Initial commit\'')
end
run('bundle update') if options[:bundle_install]
end
|