-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.rb
181 lines (153 loc) · 5.97 KB
/
main.rb
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
puts "\r\n\r\n*****************************************************************************************************"
puts "Let me ask you a few questions before I start bootstrapping your app"
puts "*****************************************************************************************************"
auth_option = ask("\r\n\r\nWhat authentication framework do you want to use?\r\n(1) Devise\r\n(2) Authlogic\r\n(3) Omniauth\r\nPress Enter to skip")
deploy_option = ask("\r\n\r\nWhat deploy method do you want to use?\r\n(1) Capistrano\r\n(2) Inploy\r\nPress Enter to skip")
locale_str = ask("\r\n\r\nEnter a list of locales you want to use separated by commas (e.g. 'es, de, fr'). For a reference list visit http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale/. Press enter to skip: ")
exceptions_option = ask("\r\n\r\nWhat exceptions tracker do you want to use?\r\n(1) Exceptional\r\n(2) Hoptoad\r\nPress Enter to skip")
if ['1', '2', '3'].include?(auth_option)
auth = 'devise' if auth_option=='1'
auth = 'authlogic' if auth_option=='2'
auth = 'omniauth' if auth_option=='3'
else
auth = nil
end
if ['1', '2'].include?(deploy_option)
deploy = 'capistrano' if deploy_option=='1'
deploy = 'inploy' if deploy_option=='2'
else
deploy = nil
end
if ['1', '2'].include?(exceptions_option)
exceptions_tracker = 'exceptional' if exceptions_option=='1'
exceptions_tracker = 'hoptoad' if exceptions_option=='2'
exceptions_key = ask("\r\n\r\nWhat is your API key for your exceptions tracker?")
else
exceptions_tracker = nil
end
puts "\r\n\r\n*****************************************************************************************************"
puts "All set. Bootstrapping your app!!"
puts "*****************************************************************************************************"
# GO!
run 'rm -Rf .gitignore README public/index.html public/images/rails.png public/javascripts/* app/views/layouts/*'
# gems
gem 'haml-rails', '>= 0.2'
gem 'inherited_resources', '~> 1.1.2'
gem 'friendly_id', '~>3.1'
gem 'compass', '>= 0.10.5'
gem 'fancy-buttons'
gem 'simple_form'
gem 'show_for'
gem 'will_paginate', '>=3.0.pre2'
gem 'tabs_on_rails'
gem 'breadcrumbs_on_rails'
gem 'paperclip'
gem 'meta_search'
# development
gem 'rails3-generators', :group => :development
gem 'rails-erd', :group => :development
gem 'wirble', :group => :development
gem 'awesome_print', :group => :development
gem 'hirb', :group => :development
# testing
gem 'factory_girl_rails', :group => [:test, :cucumber]
gem 'shoulda', :group => [:test, :shoulda]
gem 'faker', :group => [:test, :cucumber]
gem 'mynyml-redgreen', :group => :test, :require => 'redgreen'
gem 'cucumber', '>=0.6.3', :group => :cucumber
gem 'cucumber-rails', '>=0.3.2', :group => :cucumber
gem 'capybara', '>=0.3.6', :group => :cucumber
gem 'database_cleaner', '>=0.5.0', :group => :cucumber
gem 'spork', '>=0.8.4', :group => :cucumber
gem 'pickle', '>=0.4.2', :group => :cucumber
gem 'launchy', :group => :cucumber
# staging & production stuff
gem 'whenever', :group => :production
gem 'backup', :group => :production
if exceptions_tracker == 'hoptoad'
gem 'hoptoad_notifier', '~> 2.3.6'
initializer 'hoptoad.rb', <<-FILE
HoptoadNotifier.configure do |config|
config.api_key = #{exceptions_key}
end
FILE
end
if exceptions_tracker == 'exceptional'
gem 'exceptional'
run "exceptional install #{exceptions_key}"
end
run 'bundle install'
# plugins
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git'
# generators
application <<-GENERATORS
config.generators do |g|
g.orm :active_record
g.stylesheets false
g.template_engine :haml
g.test_framework :shoulda, :fixture_replacement => :factory_girl
g.fallbacks[:shoulda] = :test_unit
g.integration_tool :cucumber
g.helper false
end
GENERATORS
# configure cucumber
generate 'cucumber:install --capybara --testunit --spork'
generate 'pickle --path --email'
get 'https://github.com/recrea/rails3-templates/raw/master/within_steps.rb' ,'features/step_definitions/within_steps.rb'
# configure other gems
generate 'friendly_id'
generate 'simple_form:install -e haml'
generate 'show_for:install'
file 'lib/templates/haml/scaffold/show.html.haml', <<-FILE
= show_for @<%= singular_name %> do |a|
<% attributes.each do |attribute| -%>
= a.<%= attribute.reference? ? :association : :attribute %> :<%= attribute.name %>
<% end -%>
== \#{link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) } | \#{ link_to 'Back', <%= plural_name %>_path }
FILE
run 'wheneverize .'
run 'rails g backup'
# configure compass
run 'compass init rails . --quiet --sass-dir app/stylesheets --css-dir public/stylesheets'
create_file 'app/stylesheets/partials/_colors.scss'
get 'https://github.com/recrea/rails3-templates/raw/master/handheld.scss' ,'app/stylesheets/handheld.scss'
get 'https://github.com/recrea/rails3-templates/raw/master/application.html.haml', 'app/views/layouts/application.html.haml'
file 'config/asset_packages.yml', <<-FILE
---
javascripts:
- base:
- jquery.rails
stylesheets:
- ie:
- ie
- screen:
- screen
- print:
- print
- handheld:
- handheld
FILE
# get locales
unless locale_str.empty?
locales = locale_str.split(',')
locales.each do |loc|
get('http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/#{loc.strip}.yml', file)
end
end
# get jquery
get 'https://github.com/rails/jquery-ujs/raw/master/src/rails.js', 'public/javascripts/jquery.rails.js'
# other stuff
get 'https://github.com/recrea/rails3-templates/raw/master/gitignore' ,'.gitignore'
get 'https://github.com/recrea/rails3-templates/raw/master/build.rake', 'lib/tasks/build.rake'
append_file 'Rakefile', <<-METRIC_FU
MetricFu::Configuration.run do |config|
config.rcov[:rcov_opts] << '-Ispec'
end rescue nil
METRIC_FU
git :init
git :add => '.'
git :commit => '-am \'Initial commit\''
apply "https://github.com/recrea/rails3-templates/raw/master/#{auth}.rb" unless auth.blank?
apply "https://github.com/recrea/rails3-templates/raw/master/#{deploy}.rb" unless deploy.blank?
puts "SUCCESS!"