railslove-suspenders 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +94 -0
- data/LICENSE +21 -0
- data/NEWS.md +99 -0
- data/README.md +125 -0
- data/Rakefile +8 -0
- data/bin/railslove-suspenders +16 -0
- data/features/github_repo.feature +8 -0
- data/features/heroku_true.feature +9 -0
- data/features/rake_clean.feature +15 -0
- data/features/step_definitions/suspenders_steps.rb +68 -0
- data/features/support/bin/heroku +5 -0
- data/features/support/bin/hub +5 -0
- data/features/support/env.rb +10 -0
- data/features/support/fake_github.rb +21 -0
- data/features/support/fake_heroku.rb +21 -0
- data/lib/railslove-suspenders/actions.rb +40 -0
- data/lib/railslove-suspenders/app_builder.rb +335 -0
- data/lib/railslove-suspenders/generators/app_generator.rb +202 -0
- data/lib/railslove-suspenders/version.rb +4 -0
- data/railslove-suspenders.gemspec +33 -0
- data/templates/Gemfile_clean +42 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +9 -0
- data/templates/_flashes.html.haml +3 -0
- data/templates/_javascript.html.haml +3 -0
- data/templates/background_jobs_rspec.rb +19 -0
- data/templates/bin_setup +11 -0
- data/templates/config_locales_en.yml +11 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/email_validator.rb +7 -0
- data/templates/errors.rb +28 -0
- data/templates/factories_spec.rb +14 -0
- data/templates/factories_spec_rake_task.rb +9 -0
- data/templates/factory_girl_syntax_rspec.rb +3 -0
- data/templates/import_scss_styles +3 -0
- data/templates/javascripts/prefilled_input.js +59 -0
- data/templates/postgresql_database.yml.erb +11 -0
- data/templates/rack_timeout.rb +1 -0
- data/templates/rspec +3 -0
- data/templates/sample.env +2 -0
- data/templates/simplecov_init.rb +3 -0
- data/templates/smtp.rb +10 -0
- data/templates/strong_parameters.rb +1 -0
- data/templates/stylesheets/_shame.css.sass +0 -0
- data/templates/stylesheets/application.css.sass +14 -0
- data/templates/stylesheets/base/_colors.css.sass +7 -0
- data/templates/stylesheets/base/_dimension.css.sass +2 -0
- data/templates/stylesheets/base/_element_defaults.css.sass +5 -0
- data/templates/stylesheets/base/_global_mixins.css.sass +3 -0
- data/templates/stylesheets/base/_icon_font.css.sass +0 -0
- data/templates/stylesheets/base/_sprites.css.sass +0 -0
- data/templates/stylesheets/base/_typography.css.sass +3 -0
- data/templates/suspenders_gitignore +10 -0
- data/templates/suspenders_layout.html.haml +12 -0
- data/templates/unicorn.rb +26 -0
- metadata +175 -0
@@ -0,0 +1,335 @@
|
|
1
|
+
module RailsloveSuspenders
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include RailsloveSuspenders::Actions
|
4
|
+
|
5
|
+
def readme
|
6
|
+
template 'README.md.erb', 'README.md'
|
7
|
+
end
|
8
|
+
|
9
|
+
def remove_public_index
|
10
|
+
remove_file 'public/index.html'
|
11
|
+
end
|
12
|
+
|
13
|
+
def remove_rails_logo_image
|
14
|
+
remove_file 'app/assets/images/rails.png'
|
15
|
+
end
|
16
|
+
|
17
|
+
def raise_on_delivery_errors
|
18
|
+
replace_in_file 'config/environments/development.rb',
|
19
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
20
|
+
end
|
21
|
+
|
22
|
+
def raise_on_unpermitted_parameters
|
23
|
+
configure_environment 'development',
|
24
|
+
'config.action_controller.action_on_unpermitted_parameters = :raise'
|
25
|
+
end
|
26
|
+
|
27
|
+
def provide_setup_script
|
28
|
+
copy_file 'bin_setup', 'bin/setup'
|
29
|
+
run 'chmod a+x bin/setup'
|
30
|
+
end
|
31
|
+
|
32
|
+
def enable_factory_girl_syntax
|
33
|
+
copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_factories_first
|
37
|
+
copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
|
38
|
+
append_file 'Rakefile', factories_spec_rake_task
|
39
|
+
end
|
40
|
+
|
41
|
+
def configure_smtp
|
42
|
+
copy_file 'smtp.rb', 'config/initializers/smtp.rb'
|
43
|
+
|
44
|
+
prepend_file 'config/environments/production.rb',
|
45
|
+
"require Rails.root.join('config/initializers/smtp')\n"
|
46
|
+
|
47
|
+
config = <<-RUBY
|
48
|
+
|
49
|
+
config.action_mailer.delivery_method = :smtp
|
50
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
51
|
+
RUBY
|
52
|
+
|
53
|
+
inject_into_file 'config/environments/production.rb', config,
|
54
|
+
:after => 'config.action_mailer.raise_delivery_errors = false'
|
55
|
+
end
|
56
|
+
|
57
|
+
def setup_staging_environment
|
58
|
+
run 'cp config/environments/production.rb config/environments/staging.rb'
|
59
|
+
|
60
|
+
prepend_file 'config/environments/staging.rb',
|
61
|
+
"Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS'])\n"
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize_on_precompile
|
65
|
+
inject_into_file 'config/application.rb',
|
66
|
+
"\n config.assets.initialize_on_precompile = false",
|
67
|
+
:after => 'config.assets.enabled = true'
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_partials_directory
|
71
|
+
empty_directory 'app/assets/stylesheets/base'
|
72
|
+
empty_directory 'app/assets/stylesheets/modules'
|
73
|
+
empty_directory 'app/assets/stylesheets/layout'
|
74
|
+
empty_directory 'app/assets/stylesheets/controllers'
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_default_stylesheets
|
78
|
+
copy_file 'stylesheets/application.css.sass', 'app/assets/stylesheets/application.css.sass'
|
79
|
+
copy_file 'stylesheets/_shame.css.sass', 'app/assets/stylesheets/_shame.css.sass'
|
80
|
+
copy_file 'stylesheets/base/_colors.css.sass', 'app/assets/stylesheets/base/_colors.css.sass'
|
81
|
+
copy_file 'stylesheets/base/_dimension.css.sass', 'app/assets/stylesheets/base/_dimensions.css.sass'
|
82
|
+
copy_file 'stylesheets/base/_element_defaults.css.sass', 'app/assets/stylesheets/base/_element_defaults.css.sass'
|
83
|
+
copy_file 'stylesheets/base/_icon_font.css.sass', 'app/assets/stylesheets/base/_icon_font.css.sass'
|
84
|
+
copy_file 'stylesheets/base/_sprites.css.sass', 'app/assets/stylesheets/base/_sprites.css.sass'
|
85
|
+
copy_file 'stylesheets/base/_typography.css.sass', 'app/assets/stylesheets/base/_typography.css.sass'
|
86
|
+
copy_file 'stylesheets/base/_global_mixins.css.sass', 'app/assets/stylesheets/base/_global_mixins.css.sass'
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_shared_flashes
|
91
|
+
copy_file '_flashes.html.haml', 'app/views/layouts/_flashes.html.haml'
|
92
|
+
end
|
93
|
+
|
94
|
+
def create_shared_javascripts
|
95
|
+
copy_file '_javascript.html.haml', 'app/views/layouts/_javascript.html.haml'
|
96
|
+
end
|
97
|
+
|
98
|
+
def create_application_layout
|
99
|
+
remove_file 'app/views/layouts/application.html.erb'
|
100
|
+
template 'suspenders_layout.html.haml',
|
101
|
+
'app/views/layouts/application.html.haml',
|
102
|
+
:force => true
|
103
|
+
end
|
104
|
+
|
105
|
+
def create_common_javascripts
|
106
|
+
directory 'javascripts', 'app/assets/javascripts'
|
107
|
+
end
|
108
|
+
|
109
|
+
def add_jquery_ui
|
110
|
+
inject_into_file 'app/assets/javascripts/application.js',
|
111
|
+
"//= require jquery-ui\n", :before => '//= require_tree .'
|
112
|
+
end
|
113
|
+
|
114
|
+
def use_postgres_config_template
|
115
|
+
template 'postgresql_database.yml.erb', 'config/database.yml',
|
116
|
+
:force => true
|
117
|
+
end
|
118
|
+
|
119
|
+
def create_database
|
120
|
+
bundle_command 'exec rake db:create'
|
121
|
+
end
|
122
|
+
|
123
|
+
def replace_gemfile
|
124
|
+
remove_file 'Gemfile'
|
125
|
+
copy_file 'Gemfile_clean', 'Gemfile'
|
126
|
+
end
|
127
|
+
|
128
|
+
def set_ruby_to_version_being_used
|
129
|
+
inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
|
130
|
+
after: /source 'https:\/\/rubygems.org'/
|
131
|
+
end
|
132
|
+
|
133
|
+
def enable_database_cleaner
|
134
|
+
replace_in_file 'spec/spec_helper.rb',
|
135
|
+
'config.use_transactional_fixtures = true',
|
136
|
+
'config.use_transactional_fixtures = false'
|
137
|
+
|
138
|
+
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
139
|
+
end
|
140
|
+
|
141
|
+
def configure_rspec
|
142
|
+
remove_file '.rspec'
|
143
|
+
copy_file 'rspec', '.rspec'
|
144
|
+
prepend_file 'spec/spec_helper.rb', simplecov_init
|
145
|
+
|
146
|
+
replace_in_file 'spec/spec_helper.rb',
|
147
|
+
'# config.mock_with :mocha',
|
148
|
+
'config.mock_with :mocha'
|
149
|
+
|
150
|
+
rspec_expect_syntax = <<-RUBY
|
151
|
+
|
152
|
+
config.expect_with :rspec do |c|
|
153
|
+
c.syntax = :expect
|
154
|
+
end
|
155
|
+
RUBY
|
156
|
+
|
157
|
+
config = <<-RUBY
|
158
|
+
config.generators do |generate|
|
159
|
+
generate.test_framework :rspec
|
160
|
+
generate.helper false
|
161
|
+
generate.stylesheets false
|
162
|
+
generate.javascript_engine false
|
163
|
+
generate.view_specs false
|
164
|
+
end
|
165
|
+
|
166
|
+
RUBY
|
167
|
+
|
168
|
+
inject_into_file 'spec/spec_helper.rb', rspec_expect_syntax,
|
169
|
+
:after => 'RSpec.configure do |config|'
|
170
|
+
inject_into_class 'config/application.rb', 'Application', config
|
171
|
+
end
|
172
|
+
|
173
|
+
def configure_background_jobs_for_rspec
|
174
|
+
copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
|
175
|
+
run 'rails g delayed_job:active_record'
|
176
|
+
end
|
177
|
+
|
178
|
+
def blacklist_active_record_attributes
|
179
|
+
replace_in_file 'config/application.rb',
|
180
|
+
'config.active_record.whitelist_attributes = true',
|
181
|
+
'config.active_record.whitelist_attributes = false'
|
182
|
+
end
|
183
|
+
|
184
|
+
def configure_strong_parameters
|
185
|
+
copy_file 'strong_parameters.rb', 'config/initializers/strong_parameters.rb'
|
186
|
+
end
|
187
|
+
|
188
|
+
def configure_time_zone
|
189
|
+
config = <<-RUBY
|
190
|
+
config.active_record.default_timezone = :utc
|
191
|
+
|
192
|
+
RUBY
|
193
|
+
inject_into_class 'config/application.rb', 'Application', config
|
194
|
+
end
|
195
|
+
|
196
|
+
def configure_time_formats
|
197
|
+
remove_file 'config/locales/en.yml'
|
198
|
+
copy_file 'config_locales_en.yml', 'config/locales/en.yml'
|
199
|
+
end
|
200
|
+
|
201
|
+
def configure_rack_timeout
|
202
|
+
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
|
203
|
+
end
|
204
|
+
|
205
|
+
def configure_action_mailer
|
206
|
+
action_mailer_host 'development', "#{app_name}.local"
|
207
|
+
action_mailer_host 'test', 'www.example.com'
|
208
|
+
action_mailer_host 'staging', "staging.#{app_name}.com"
|
209
|
+
action_mailer_host 'production', "#{app_name}.com"
|
210
|
+
end
|
211
|
+
|
212
|
+
def generate_rspec
|
213
|
+
generate 'rspec:install'
|
214
|
+
end
|
215
|
+
|
216
|
+
def configure_capybara_webkit
|
217
|
+
append_file 'spec/spec_helper.rb' do
|
218
|
+
"\nCapybara.javascript_driver = :webkit"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def generate_clearance
|
223
|
+
generate 'clearance:install'
|
224
|
+
end
|
225
|
+
|
226
|
+
def configure_unicorn
|
227
|
+
copy_file 'unicorn.rb', 'config/unicorn.rb'
|
228
|
+
end
|
229
|
+
|
230
|
+
def setup_foreman
|
231
|
+
copy_file 'sample.env', '.sample.env'
|
232
|
+
copy_file 'Procfile', 'Procfile'
|
233
|
+
end
|
234
|
+
|
235
|
+
def setup_stylesheets
|
236
|
+
remove_file 'app/assets/stylesheets/application.css'
|
237
|
+
# concat_file 'import_scss_styles', 'app/assets/stylesheets/application.css.scss'
|
238
|
+
# create_file 'app/assets/stylesheets/_screen.scss'
|
239
|
+
end
|
240
|
+
|
241
|
+
def gitignore_files
|
242
|
+
concat_file 'suspenders_gitignore', '.gitignore'
|
243
|
+
[
|
244
|
+
'app/models',
|
245
|
+
'app/assets/images',
|
246
|
+
'db/migrate',
|
247
|
+
'log',
|
248
|
+
'spec/support',
|
249
|
+
'spec/lib',
|
250
|
+
'spec/models',
|
251
|
+
'spec/views',
|
252
|
+
'spec/controllers',
|
253
|
+
'spec/helpers',
|
254
|
+
'spec/support/matchers',
|
255
|
+
'spec/support/mixins',
|
256
|
+
'spec/support/shared_examples'
|
257
|
+
].each do |dir|
|
258
|
+
empty_directory_with_gitkeep dir
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def init_git
|
263
|
+
run 'git init'
|
264
|
+
end
|
265
|
+
|
266
|
+
def create_heroku_apps
|
267
|
+
path_addition = override_path_for_tests
|
268
|
+
run "#{path_addition} heroku create #{app_name}-production --remote=production"
|
269
|
+
run "#{path_addition} heroku create #{app_name}-staging --remote=staging"
|
270
|
+
run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging"
|
271
|
+
end
|
272
|
+
|
273
|
+
def create_github_repo(repo_name)
|
274
|
+
path_addition = override_path_for_tests
|
275
|
+
run "#{path_addition} hub create #{repo_name}"
|
276
|
+
end
|
277
|
+
|
278
|
+
def copy_miscellaneous_files
|
279
|
+
copy_file 'errors.rb', 'config/initializers/errors.rb'
|
280
|
+
end
|
281
|
+
|
282
|
+
def customize_error_pages
|
283
|
+
meta_tags =<<-EOS
|
284
|
+
<meta charset='utf-8' />
|
285
|
+
<meta name='ROBOTS' content='NOODP' />
|
286
|
+
EOS
|
287
|
+
style_tags =<<-EOS
|
288
|
+
<link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
|
289
|
+
EOS
|
290
|
+
|
291
|
+
%w(500 404 422).each do |page|
|
292
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
293
|
+
replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
|
294
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def remove_routes_comment_lines
|
299
|
+
replace_in_file 'config/routes.rb',
|
300
|
+
/Application\.routes\.draw do.*end/m,
|
301
|
+
"Application.routes.draw do\nend"
|
302
|
+
end
|
303
|
+
|
304
|
+
def add_email_validator
|
305
|
+
copy_file 'email_validator.rb', 'app/validators/email_validator.rb'
|
306
|
+
end
|
307
|
+
|
308
|
+
def disable_xml_params
|
309
|
+
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
310
|
+
end
|
311
|
+
|
312
|
+
def setup_default_rake_task
|
313
|
+
append_file 'Rakefile' do
|
314
|
+
"task(:default).clear\ntask :default => [:spec]"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
private
|
319
|
+
|
320
|
+
def override_path_for_tests
|
321
|
+
if ENV['TESTING']
|
322
|
+
support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin'))
|
323
|
+
"PATH=#{support_bin}:$PATH"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
def factories_spec_rake_task
|
328
|
+
IO.read find_in_source_paths('factories_spec_rake_task.rb')
|
329
|
+
end
|
330
|
+
|
331
|
+
def simplecov_init
|
332
|
+
IO.read find_in_source_paths('simplecov_init.rb')
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
|
4
|
+
module RailsloveSuspenders
|
5
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
+
class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql',
|
7
|
+
:desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
8
|
+
|
9
|
+
class_option :heroku, :type => :boolean, :aliases => '-H', :default => false,
|
10
|
+
:desc => 'Create staging and production Heroku apps'
|
11
|
+
|
12
|
+
class_option :github, :type => :string, :aliases => '-G', :default => nil,
|
13
|
+
:desc => 'Create Github repository and add remote origin pointed to repo'
|
14
|
+
|
15
|
+
class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
|
16
|
+
:desc => 'Skip Test::Unit files'
|
17
|
+
|
18
|
+
def finish_template
|
19
|
+
invoke :suspenders_customization
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def suspenders_customization
|
24
|
+
invoke :remove_files_we_dont_need
|
25
|
+
invoke :customize_gemfile
|
26
|
+
invoke :setup_database
|
27
|
+
invoke :setup_development_environment
|
28
|
+
invoke :setup_test_environment
|
29
|
+
invoke :setup_production_environment
|
30
|
+
invoke :setup_staging_environment
|
31
|
+
invoke :create_suspenders_views
|
32
|
+
invoke :create_common_javascripts
|
33
|
+
# invoke :add_jquery_ui
|
34
|
+
invoke :configure_app
|
35
|
+
invoke :setup_stylesheets
|
36
|
+
invoke :copy_miscellaneous_files
|
37
|
+
invoke :customize_error_pages
|
38
|
+
invoke :remove_routes_comment_lines
|
39
|
+
invoke :setup_git
|
40
|
+
# invoke :create_heroku_apps
|
41
|
+
# invoke :create_github_repo
|
42
|
+
invoke :outro
|
43
|
+
end
|
44
|
+
|
45
|
+
def remove_files_we_dont_need
|
46
|
+
build :remove_public_index
|
47
|
+
build :remove_rails_logo_image
|
48
|
+
end
|
49
|
+
|
50
|
+
def customize_gemfile
|
51
|
+
build :replace_gemfile
|
52
|
+
build :set_ruby_to_version_being_used
|
53
|
+
bundle_command 'install'
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup_database
|
57
|
+
say 'Setting up database'
|
58
|
+
|
59
|
+
if 'postgresql' == options[:database]
|
60
|
+
build :use_postgres_config_template
|
61
|
+
end
|
62
|
+
|
63
|
+
build :create_database
|
64
|
+
end
|
65
|
+
|
66
|
+
def setup_development_environment
|
67
|
+
say 'Setting up the development environment'
|
68
|
+
build :raise_on_delivery_errors
|
69
|
+
# build :raise_on_unpermitted_parameters
|
70
|
+
build :provide_setup_script
|
71
|
+
end
|
72
|
+
|
73
|
+
def setup_test_environment
|
74
|
+
say 'Setting up the test environment'
|
75
|
+
build :enable_factory_girl_syntax
|
76
|
+
build :test_factories_first
|
77
|
+
build :generate_rspec
|
78
|
+
build :configure_rspec
|
79
|
+
# build :configure_background_jobs_for_rspec
|
80
|
+
build :enable_database_cleaner
|
81
|
+
build :configure_capybara_webkit
|
82
|
+
# build :setup_guard_spork
|
83
|
+
end
|
84
|
+
|
85
|
+
def setup_production_environment
|
86
|
+
say 'Setting up the production environment'
|
87
|
+
# build :configure_smtp
|
88
|
+
end
|
89
|
+
|
90
|
+
def setup_staging_environment
|
91
|
+
say 'Setting up the staging environment'
|
92
|
+
build :setup_staging_environment
|
93
|
+
build :initialize_on_precompile
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_suspenders_views
|
97
|
+
say 'Creating suspenders views'
|
98
|
+
build :create_partials_directory
|
99
|
+
say 'Add default stylesheets'
|
100
|
+
build :add_default_stylesheets
|
101
|
+
build :create_shared_flashes
|
102
|
+
build :create_shared_javascripts
|
103
|
+
build :create_application_layout
|
104
|
+
end
|
105
|
+
|
106
|
+
def create_common_javascripts
|
107
|
+
say 'Pulling in some common javascripts'
|
108
|
+
build :create_common_javascripts
|
109
|
+
end
|
110
|
+
|
111
|
+
def add_jquery_ui
|
112
|
+
say 'Add jQuery ui to the standard application.js'
|
113
|
+
build :add_jquery_ui
|
114
|
+
end
|
115
|
+
|
116
|
+
def configure_app
|
117
|
+
say 'Configuring app'
|
118
|
+
build :configure_action_mailer
|
119
|
+
build :blacklist_active_record_attributes
|
120
|
+
# build :configure_strong_parameters
|
121
|
+
build :configure_time_zone
|
122
|
+
build :configure_time_formats
|
123
|
+
build :configure_rack_timeout
|
124
|
+
build :disable_xml_params
|
125
|
+
build :add_email_validator
|
126
|
+
build :setup_default_rake_task
|
127
|
+
# build :configure_unicorn
|
128
|
+
# build :setup_foreman
|
129
|
+
end
|
130
|
+
|
131
|
+
def setup_stylesheets
|
132
|
+
say 'Set up stylesheets'
|
133
|
+
build :setup_stylesheets
|
134
|
+
end
|
135
|
+
|
136
|
+
def setup_git
|
137
|
+
say 'Initializing git'
|
138
|
+
invoke :setup_gitignore
|
139
|
+
invoke :init_git
|
140
|
+
end
|
141
|
+
|
142
|
+
def create_heroku_apps
|
143
|
+
if options[:heroku]
|
144
|
+
say 'Creating Heroku apps'
|
145
|
+
build :create_heroku_apps
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def create_github_repo
|
150
|
+
if options[:github]
|
151
|
+
say 'Creating Github repo'
|
152
|
+
build :create_github_repo, options[:github]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def setup_gitignore
|
157
|
+
build :gitignore_files
|
158
|
+
end
|
159
|
+
|
160
|
+
def init_git
|
161
|
+
build :init_git
|
162
|
+
end
|
163
|
+
|
164
|
+
def copy_libraries
|
165
|
+
say 'Copying libraries'
|
166
|
+
build :copy_libraries
|
167
|
+
end
|
168
|
+
|
169
|
+
def copy_miscellaneous_files
|
170
|
+
say 'Copying miscellaneous support files'
|
171
|
+
build :copy_miscellaneous_files
|
172
|
+
end
|
173
|
+
|
174
|
+
def customize_error_pages
|
175
|
+
say 'Customizing the 500/404/422 pages'
|
176
|
+
build :customize_error_pages
|
177
|
+
end
|
178
|
+
|
179
|
+
def remove_routes_comment_lines
|
180
|
+
build :remove_routes_comment_lines
|
181
|
+
end
|
182
|
+
|
183
|
+
def outro
|
184
|
+
say 'Congratulations! You just pulled our suspenders.'
|
185
|
+
say "Remember to run 'rails generate airbrake' with your API key."
|
186
|
+
end
|
187
|
+
|
188
|
+
def run_bundle
|
189
|
+
# Let's not: We'll bundle manually at the right spot
|
190
|
+
end
|
191
|
+
|
192
|
+
protected
|
193
|
+
|
194
|
+
def get_builder_class
|
195
|
+
RailsloveSuspenders::AppBuilder
|
196
|
+
end
|
197
|
+
|
198
|
+
def using_active_record?
|
199
|
+
!options[:skip_active_record]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'railslove-suspenders/version'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.required_ruby_version = '>= 1.9.2'
|
8
|
+
s.add_dependency 'bundler', '~> 1.3'
|
9
|
+
s.add_dependency 'hub', '~> 1.10'
|
10
|
+
s.add_dependency 'rails', '3.2.13'
|
11
|
+
# s.add_development_dependency 'aruba', '~> 0.5'
|
12
|
+
# s.add_development_dependency 'cucumber', '~> 1.2'
|
13
|
+
s.authors = ['stephanpavlovic']
|
14
|
+
s.date = Date.today.strftime('%Y-%m-%d')
|
15
|
+
|
16
|
+
s.description = <<-HERE
|
17
|
+
Suspenders is a base Rails project that you can upgrade. It is used by
|
18
|
+
thoughtbot to get a jump start on a working app. Use Suspenders if you're in a
|
19
|
+
rush to build something amazing; don't use it if you like missing deadlines.
|
20
|
+
HERE
|
21
|
+
|
22
|
+
s.email = 'stephan@railslove.com'
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |file| File.basename(file) }
|
24
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
25
|
+
s.files = `git ls-files`.split("\n")
|
26
|
+
s.homepage = 'http://github.com/railslove/railslove-suspenders'
|
27
|
+
s.name = 'railslove-suspenders'
|
28
|
+
s.rdoc_options = ['--charset=UTF-8']
|
29
|
+
s.require_paths = ['lib']
|
30
|
+
s.summary = "Generate a Rails app using thoughtbot's best practices."
|
31
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
32
|
+
s.version = RailsloveSuspenders::VERSION
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'airbrake'
|
4
|
+
gem 'compass'
|
5
|
+
gem 'jquery-rails'
|
6
|
+
gem 'pg'
|
7
|
+
gem 'rails', '>= 3.2.13'
|
8
|
+
gem 'quiet_assets'
|
9
|
+
gem 'newrelic_rpm'
|
10
|
+
|
11
|
+
|
12
|
+
group :assets do
|
13
|
+
gem 'coffee-rails'
|
14
|
+
gem 'sass-rails'
|
15
|
+
gem 'haml-rails'
|
16
|
+
gem 'uglifier'
|
17
|
+
end
|
18
|
+
|
19
|
+
group :development do
|
20
|
+
gem 'better_errors'
|
21
|
+
gem 'binding_of_caller'
|
22
|
+
gem 'smurfville'
|
23
|
+
gem 'i18n_viz'
|
24
|
+
end
|
25
|
+
|
26
|
+
group :development, :test do
|
27
|
+
gem 'factory_girl_rails'
|
28
|
+
gem 'rspec-rails'
|
29
|
+
end
|
30
|
+
|
31
|
+
group :test do
|
32
|
+
gem 'capybara-webkit', '>= 0.14.1'
|
33
|
+
gem 'database_cleaner'
|
34
|
+
gem 'launchy'
|
35
|
+
gem 'shoulda-matchers'
|
36
|
+
gem 'timecop'
|
37
|
+
end
|
38
|
+
|
39
|
+
group :deploy do
|
40
|
+
gem "capistrano"
|
41
|
+
gem "capistrano-ext"
|
42
|
+
end
|
data/templates/Procfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
You look great in Suspenders
|
2
|
+
============================
|
3
|
+
|
4
|
+
Use the following guides for getting things done, programming well, and
|
5
|
+
programming in style.
|
6
|
+
|
7
|
+
* [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
|
8
|
+
* [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
|
9
|
+
* [Style](http://github.com/thoughtbot/guides/blob/master/style)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BackgroundJobs
|
2
|
+
def run_background_jobs_immediately
|
3
|
+
delay_jobs = Delayed::Worker.delay_jobs
|
4
|
+
Delayed::Worker.delay_jobs = false
|
5
|
+
yield
|
6
|
+
ensure
|
7
|
+
Delayed::Worker.delay_jobs = delay_jobs
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.around(:each, type: :feature) do |example|
|
13
|
+
run_background_jobs_immediately do
|
14
|
+
example.run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.include BackgroundJobs
|
19
|
+
end
|
data/templates/bin_setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
# Set up Rails app. Run this script immediately after cloning the codebase.
|
4
|
+
# https://github.com/thoughtbot/guides/tree/master/protocol
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
bundle exec rake db:setup
|
8
|
+
|
9
|
+
if [ ! -f .env ]; then
|
10
|
+
cp .sample.env .env
|
11
|
+
fi
|