-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.rb
More file actions
88 lines (70 loc) · 2.17 KB
/
template.rb
File metadata and controls
88 lines (70 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
alias :old_ask :ask
def yes?(question, default_yes=false)
(answer = old_ask("#{question} [#{default_yes ? "yes" : "no"}]")).blank? || ["yes","y"].include?(answer.downcase)
end
def ask(question, default)
(answer = old_ask("#{question} [#{default}]")).blank? ? default : answer
end
remove_file 'Gemfile'
add_file 'Gemfile'
add_source 'http://rubygems.org'
append_to_file "Gemfile","\n"
gem "rails", Rails::VERSION::STRING
gem "rake"
gem "jquery-rails"
gem ask("What database gem should I use?", "mysql")
append_to_file 'Gemfile', <<EOF
group :development do
gem 'capistrano'
gem 'capistrano-ext'
gem 'rvm'
gem 'ruby-debug'
#gem 'ruby-debug19'
end
group :development, :test, :cucumber do
gem 'capybara'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'pickle'
gem 'jasmine'
gem 'launchy'
end
EOF
if yes?("Should I configure RVM?", true)
inside '' do |path|
add_file ".rvmrc", "rvm #{ruby_version = ask("What ruby version?", 'ree')}@#{application_name = path.split('/').last}"
if !`rvm list`.match(ruby_version)
if yes?("#{ruby_version} is not installed, would you like me to install it?",true)
run "rvm install #{ruby_version}"
else
say "Unable to continue as the ruby version \"#{ruby_version}\" has not been installed, please continue manually"
exit
end
end
run "rvm use #{ruby_version}"
run "rvm gemset create #{application_name}"
run "rvm gemset use #{application_name}"
end
end
run "bundle install"
run "bundle package"
generate "rspec:install"
generate "cucumber:install", "--capybara --rspec"
generate "jquery:install", (yes?("Include JQuery UI?", true) ? "--ui" : "")
generate "pickle", "--email --paths"
generate "jasmine:install"
capify!
git :init unless File.exists?('.git')
git :add => '.'
git :commit => '-m "First commit"'
unless( remote_git_repos = old_ask("What is the remote git repository? (leave blank for none)")).blank?
if `git remote -v`.blank?
run "git remote set-url origin #{remote_git_repos}"
else
run "git remote add origin #{remote_git_repos}"
end
git :branch => "development"
git :push => "origin development"
end