14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/shortcut/application_tasks/new.rb', line 14
def skeleton
app_name = name.chomp("/") namespaced_path = app_name.tr('-', '/')
target = File.join(Dir.pwd, app_name)
constant_name = app_name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
constant_array = constant_name.split('::')
git_user_name = `git config user.name`.chomp
git_user_email = `git config user.email`.chomp
opts = {
:name => app_name,
:namespaced_path => namespaced_path,
:constant_name => constant_name,
:constant_array => constant_array,
:author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
:email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
:test => options[:test]
}
template("Gemfile.tt", File.join(target, "Gemfile"), opts)
template("Rakefile.tt", File.join(target, "Rakefile"), opts)
template("LICENSE.txt.tt", File.join(target, "LICENSE.txt"), opts)
template("README.md.tt", File.join(target, "README.md"), opts)
template("gitignore.tt", File.join(target, ".gitignore"), opts)
template("lib/newgem.rb.tt", File.join(target, "lib/#{namespaced_path}.rb"), opts)
template("lib/newgem/version.rb.tt", File.join(target, "lib/#{namespaced_path}/version.rb"), opts)
template("bin/newgem.tt", File.join(target, 'bin', app_name), opts)
template("config/launch4j.xml.tt", File.join(target, 'config/launch4j.xml'), opts)
case options[:test]
when 'rspec'
template("rspec.tt", File.join(target, ".rspec"), opts)
template("spec/spec_helper.rb.tt", File.join(target, "spec/spec_helper.rb"), opts)
template("spec/newgem_spec.rb.tt", File.join(target, "spec/#{namespaced_path}_spec.rb"), opts)
when 'minitest'
template("test/minitest_helper.rb.tt", File.join(target, "test/minitest_helper.rb"), opts)
template("test/test_newgem.rb.tt", File.join(target, "test/test_#{namespaced_path}.rb"), opts)
end
if options[:test]
template(".travis.yml.tt", File.join(target, ".travis.yml"), opts)
end
[16, 32, 64, 128].each do |size|
copy_file("images/icons/#{size}.png", File.join(target, "images/icons/#{size}.png"))
end
say "Initializating git repo in #{target}"
Dir.chdir(target) { `git init`; `git add .` }
end
|