roboparts 0.5.4 → 0.6.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/roboparts/app_builder.rb +100 -125
- data/lib/roboparts/generators/app_generator.rb +47 -40
- data/lib/roboparts/version.rb +1 -1
- data/roboparts.gemspec +9 -6
- data/spec/fakes/bin/hub +5 -0
- data/spec/features/github_spec.rb +10 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/fake_github.rb +21 -0
- data/spec/support/roboparts.rb +49 -0
- data/templates/Gemfile.erb +4 -1
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +17 -0
- data/templates/_analytics.html.erb +8 -9
- data/templates/action_mailer.rb +1 -1
- data/templates/application.css.scss +6 -6
- data/templates/background_jobs_rspec.rb +1 -1
- data/templates/config_locales_en.yml.erb +2 -0
- data/templates/database_cleaner_rspec.rb +1 -1
- data/templates/development_seeds.rb +1 -1
- data/templates/factory_girl_rspec.rb +1 -1
- data/templates/rails_helper.rb +2 -2
- data/templates/roboparts_gitignore +1 -0
- data/templates/roboparts_layout.html.erb.erb +6 -6
- data/templates/sample.env +3 -0
- data/templates/secrets.yml +1 -1
- data/templates/spec_helper.rb +2 -1
- data/templates/unicorn.rb +6 -4
- metadata +14 -9
- data/.DS_Store +0 -0
- data/bin/setup +0 -13
- data/templates/config_i18n_tasks.yml +0 -13
- data/templates/i18n.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef9f61be48e2e433742758f508a486a06c15117
|
4
|
+
data.tar.gz: 5222ad8ec73607c11cc48b0d60f49a15e71bc460
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d09fa72833c2749d846abd563710e4d8b02a6c272f24b2950bc731ce27f4eef2381e5fa8998dc9ef4b12b9447b288a3c01126dffc65e6e0ee78bf88fc02551
|
7
|
+
data.tar.gz: cc72d10935fabdf0b9d5805f862d2d08b560891f4db07e93d9c943d9ff5a158dcec91db5d5541ca61dd5fb5d33a45895b084cf37b6ace52720e7aa568d8dbb76
|
data/.gitignore
ADDED
@@ -2,6 +2,11 @@ module Roboparts
|
|
2
2
|
class AppBuilder < Rails::AppBuilder
|
3
3
|
include Roboparts::Actions
|
4
4
|
|
5
|
+
# Readme
|
6
|
+
def readme
|
7
|
+
template 'README.md.erb', 'README.md'
|
8
|
+
end
|
9
|
+
|
5
10
|
# Customize gemfile
|
6
11
|
def replace_gemfile
|
7
12
|
remove_file 'Gemfile'
|
@@ -27,7 +32,7 @@ module Roboparts
|
|
27
32
|
end
|
28
33
|
|
29
34
|
def provide_setup_script
|
30
|
-
template 'bin_setup.erb', 'bin/setup', port_number: port
|
35
|
+
template 'bin_setup.erb', 'bin/setup', port_number: port
|
31
36
|
run 'chmod a+x bin/setup'
|
32
37
|
end
|
33
38
|
|
@@ -53,59 +58,7 @@ module Roboparts
|
|
53
58
|
inject_into_class 'config/application.rb', 'Application', config
|
54
59
|
end
|
55
60
|
|
56
|
-
|
57
|
-
template 'postgresql_database.yml.erb', 'config/database.yml',
|
58
|
-
force: true
|
59
|
-
end
|
60
|
-
|
61
|
-
def create_database
|
62
|
-
bundle_command 'exec rake db:create db:migrate'
|
63
|
-
end
|
64
|
-
|
65
|
-
def raise_on_delivery_errors
|
66
|
-
replace_in_file 'config/environments/development.rb',
|
67
|
-
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
68
|
-
end
|
69
|
-
|
70
|
-
def raise_on_unpermitted_parameters
|
71
|
-
config = <<-RUBY
|
72
|
-
config.action_controller.action_on_unpermitted_parameters = :raise
|
73
|
-
RUBY
|
74
|
-
|
75
|
-
inject_into_class "config/application.rb", "Application", config
|
76
|
-
end
|
77
|
-
|
78
|
-
def provide_setup_script
|
79
|
-
template "bin_setup.erb", "bin/setup", port_number: port, force: true
|
80
|
-
run "chmod a+x bin/setup"
|
81
|
-
end
|
82
|
-
|
83
|
-
def provide_dev_prime_task
|
84
|
-
copy_file 'development_seeds.rb', 'lib/tasks/development_seeds.rake'
|
85
|
-
end
|
86
|
-
|
87
|
-
def configure_generators
|
88
|
-
config = <<-RUBY
|
89
|
-
config.generators do |generate|
|
90
|
-
generate.helper false
|
91
|
-
generate.javascript_engine false
|
92
|
-
generate.request_specs false
|
93
|
-
generate.routing_specs false
|
94
|
-
generate.stylesheets false
|
95
|
-
generate.test_framework :rspec
|
96
|
-
generate.view_specs false
|
97
|
-
end
|
98
|
-
|
99
|
-
RUBY
|
100
|
-
|
101
|
-
inject_into_class 'config/application.rb', 'Application', config
|
102
|
-
end
|
103
|
-
|
104
|
-
def configure_i18n_for_missing_translations
|
105
|
-
raise_on_missing_translations_in("development")
|
106
|
-
raise_on_missing_translations_in("test")
|
107
|
-
end
|
108
|
-
|
61
|
+
# Setup test environment
|
109
62
|
def setup_factory_girl_for_rspec
|
110
63
|
copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
|
111
64
|
end
|
@@ -135,19 +88,11 @@ module Roboparts
|
|
135
88
|
empty_directory_with_keep_file 'spec/support/features'
|
136
89
|
end
|
137
90
|
|
138
|
-
def configure_i18n_for_test_environment
|
139
|
-
copy_file "i18n.rb", "spec/support/i18n.rb"
|
140
|
-
end
|
141
|
-
|
142
|
-
def configure_18n_tasks
|
143
|
-
run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/"
|
144
|
-
copy_file "config_i18n_tasks.yml", "config/i18n-tasks.yml"
|
145
|
-
end
|
146
|
-
|
147
91
|
def configure_action_mailer_in_specs
|
148
92
|
copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
|
149
93
|
end
|
150
94
|
|
95
|
+
# Setup production environment
|
151
96
|
def configure_smtp
|
152
97
|
copy_file 'smtp.rb', 'config/smtp.rb'
|
153
98
|
|
@@ -155,8 +100,8 @@ module Roboparts
|
|
155
100
|
%{require Rails.root.join("config/smtp")\n}
|
156
101
|
|
157
102
|
config = <<-RUBY
|
158
|
-
|
159
|
-
|
103
|
+
config.action_mailer.delivery_method = :smtp
|
104
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
160
105
|
RUBY
|
161
106
|
|
162
107
|
inject_into_file 'config/environments/production.rb', config,
|
@@ -165,29 +110,36 @@ module Roboparts
|
|
165
110
|
|
166
111
|
def enable_rack_deflater
|
167
112
|
config = <<-RUBY
|
168
|
-
|
169
|
-
|
113
|
+
|
114
|
+
# Enable deflate / gzip compression of controller-generated responses
|
115
|
+
config.middleware.use Rack::Deflater
|
170
116
|
RUBY
|
171
117
|
|
172
|
-
inject_into_file
|
173
|
-
|
118
|
+
inject_into_file(
|
119
|
+
"config/environments/production.rb",
|
120
|
+
config,
|
121
|
+
after: serve_static_files_line
|
122
|
+
)
|
174
123
|
end
|
175
124
|
|
176
125
|
def setup_asset_host
|
177
126
|
replace_in_file 'config/environments/production.rb',
|
178
|
-
|
127
|
+
'# config.action_controller.asset_host = "http://assets.example.com"',
|
179
128
|
'config.action_controller.asset_host = ENV.fetch("ASSET_HOST")'
|
180
129
|
|
181
130
|
replace_in_file 'config/initializers/assets.rb',
|
182
|
-
"config.assets.version = '1.0'",
|
183
|
-
'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
|
131
|
+
"Rails.application.config.assets.version = '1.0'",
|
132
|
+
'Rails.application.config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
|
184
133
|
|
185
|
-
|
186
|
-
"config.
|
187
|
-
'config.static_cache_control = "public, max-age=#{1.year.to_i}"'
|
134
|
+
inject_into_file(
|
135
|
+
"config/environments/production.rb",
|
136
|
+
' config.static_cache_control = "public, max-age=#{1.year.to_i}"',
|
137
|
+
after: serve_static_files_line
|
138
|
+
)
|
188
139
|
end
|
189
140
|
|
190
|
-
|
141
|
+
# Setup staging environment
|
142
|
+
def setup_staging_environment
|
191
143
|
staging_file = 'config/environments/staging.rb'
|
192
144
|
copy_file 'staging.rb', staging_file
|
193
145
|
|
@@ -200,10 +152,12 @@ end
|
|
200
152
|
append_file staging_file, config
|
201
153
|
end
|
202
154
|
|
155
|
+
# Setup secret token
|
203
156
|
def setup_secret_token
|
204
157
|
template 'secrets.yml', 'config/secrets.yml', force: true
|
205
158
|
end
|
206
159
|
|
160
|
+
# Create roboparts views
|
207
161
|
def create_partials_directory
|
208
162
|
empty_directory 'app/views/application'
|
209
163
|
end
|
@@ -218,20 +172,23 @@ end
|
|
218
172
|
|
219
173
|
def create_application_layout
|
220
174
|
template 'roboparts_layout.html.erb.erb',
|
221
|
-
'app/views/layouts/application.html.erb',
|
175
|
+
'app/views/layouts/application.html.erb',
|
176
|
+
force: true
|
222
177
|
end
|
223
178
|
|
179
|
+
# Setup coffeescript
|
224
180
|
def remove_turbolinks
|
225
181
|
replace_in_file 'app/assets/javascripts/application.js',
|
226
182
|
/\/\/= require turbolinks\n/,
|
227
183
|
''
|
228
184
|
end
|
229
185
|
|
186
|
+
# Configure app
|
230
187
|
def configure_action_mailer
|
231
|
-
action_mailer_host
|
232
|
-
action_mailer_host
|
233
|
-
action_mailer_host
|
234
|
-
action_mailer_host
|
188
|
+
action_mailer_host "development", %{"localhost:#{port}"}
|
189
|
+
action_mailer_host "test", %{"www.example.com"}
|
190
|
+
action_mailer_host "staging", %{ENV.fetch("HOST")}
|
191
|
+
action_mailer_host "production", %{ENV.fetch("HOST")}
|
235
192
|
end
|
236
193
|
|
237
194
|
def configure_time_zone
|
@@ -251,6 +208,10 @@ end
|
|
251
208
|
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
|
252
209
|
end
|
253
210
|
|
211
|
+
def configure_simple_form
|
212
|
+
bundle_command "exec rails generate simple_form:install"
|
213
|
+
end
|
214
|
+
|
254
215
|
def disable_xml_params
|
255
216
|
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
256
217
|
end
|
@@ -265,7 +226,7 @@ end
|
|
265
226
|
|
266
227
|
def setup_default_rake_task
|
267
228
|
append_file 'Rakefile' do
|
268
|
-
<<-
|
229
|
+
<<-EOS
|
269
230
|
task(:default).clear
|
270
231
|
task default: [:spec]
|
271
232
|
|
@@ -275,7 +236,7 @@ if defined? RSpec
|
|
275
236
|
t.verbose = false
|
276
237
|
end
|
277
238
|
end
|
278
|
-
|
239
|
+
EOS
|
279
240
|
end
|
280
241
|
end
|
281
242
|
|
@@ -283,12 +244,46 @@ end
|
|
283
244
|
copy_file 'unicorn.rb', 'config/unicorn.rb'
|
284
245
|
end
|
285
246
|
|
247
|
+
def setup_foreman
|
248
|
+
copy_file 'sample.env', '.sample.env'
|
249
|
+
copy_file 'Procfile', 'Procfile'
|
250
|
+
end
|
251
|
+
|
252
|
+
# Setup stylesheets
|
286
253
|
def setup_stylesheets
|
287
254
|
remove_file 'app/assets/stylesheets/application.css'
|
288
255
|
copy_file 'application.css.scss',
|
289
256
|
'app/assets/stylesheets/application.css.scss'
|
290
257
|
end
|
291
258
|
|
259
|
+
# Copy miscellaneous files
|
260
|
+
def copy_miscellaneous_files
|
261
|
+
copy_file "errors.rb", "config/initializers/errors.rb"
|
262
|
+
copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
|
263
|
+
end
|
264
|
+
|
265
|
+
# Customize error pages
|
266
|
+
def customize_error_pages
|
267
|
+
meta_tags = <<-EOS
|
268
|
+
<meta charset="utf-8">
|
269
|
+
<meta name="ROBOTS" content="NOODP">
|
270
|
+
<meta name="viewport" content="initial-scale=1">
|
271
|
+
EOS
|
272
|
+
|
273
|
+
%w(500 404 422).each do |page|
|
274
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
275
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
# Remove routes comment lines
|
280
|
+
def remove_routes_comment_lines
|
281
|
+
replace_in_file 'config/routes.rb',
|
282
|
+
/Rails\.application\.routes\.draw do.*end/m,
|
283
|
+
"Rails.application.routes.draw do\nend"
|
284
|
+
end
|
285
|
+
|
286
|
+
# Setup git
|
292
287
|
def gitignore_files
|
293
288
|
remove_file '.gitignore'
|
294
289
|
copy_file 'roboparts_gitignore', '.gitignore'
|
@@ -310,70 +305,50 @@ end
|
|
310
305
|
run 'git init'
|
311
306
|
end
|
312
307
|
|
308
|
+
# Setup database
|
309
|
+
def use_postgres_config_template
|
310
|
+
template 'postgresql_database.yml.erb', 'config/database.yml',
|
311
|
+
force: true
|
312
|
+
end
|
313
|
+
|
314
|
+
def create_database
|
315
|
+
bundle_command 'exec rake db:create db:migrate'
|
316
|
+
end
|
317
|
+
|
318
|
+
# Create GitHub repo
|
313
319
|
def create_github_repo(repo_name)
|
314
320
|
path_addition = override_path_for_tests
|
315
321
|
run "#{path_addition} hub create #{repo_name}"
|
316
322
|
end
|
317
323
|
|
324
|
+
# Setup Google Analytics
|
318
325
|
def setup_google_analytics
|
319
326
|
copy_file '_analytics.html.erb',
|
320
327
|
'app/views/application/_analytics.html.erb'
|
321
328
|
end
|
322
329
|
|
330
|
+
# Setup bundler-audit
|
323
331
|
def setup_bundler_audit
|
324
332
|
copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
|
325
333
|
append_file "Rakefile", %{\ntask default: "bundler:audit"\n}
|
326
334
|
end
|
327
335
|
|
328
|
-
|
329
|
-
copy_file "errors.rb", "config/initializers/errors.rb"
|
330
|
-
copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
|
331
|
-
end
|
332
|
-
|
333
|
-
def customize_error_pages
|
334
|
-
meta_tags = <<-RUBY
|
335
|
-
<meta charset="utf-8" />
|
336
|
-
<meta name="ROBOTS" content="NOODP" />
|
337
|
-
<meta name="viewport" content="initial-scale=1" />
|
338
|
-
RUBY
|
336
|
+
private
|
339
337
|
|
340
|
-
|
341
|
-
|
342
|
-
|
338
|
+
def override_path_for_tests
|
339
|
+
if ENV['TESTING']
|
340
|
+
support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
|
341
|
+
"PATH=#{support_bin}:$PATH"
|
343
342
|
end
|
344
343
|
end
|
345
344
|
|
346
|
-
def
|
347
|
-
|
348
|
-
/Rails\.application\.routes\.draw do.*end/m,
|
349
|
-
"Rails.application.routes.draw do\nend"
|
345
|
+
def port
|
346
|
+
@port ||= [3000, 4000, 5000, 7000, 8000, 9000].sample
|
350
347
|
end
|
351
|
-
end
|
352
|
-
|
353
|
-
private
|
354
|
-
|
355
|
-
def raise_on_missing_translations_in(environment)
|
356
|
-
config = 'config.action_view.raise_on_missing_translations = true'
|
357
348
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
def override_path_for_tests
|
362
|
-
if ENV["TESTING"]
|
363
|
-
support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
|
364
|
-
"PATH=#{support_bin}:$PATH"
|
349
|
+
def serve_static_files_line
|
350
|
+
"config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n"
|
365
351
|
end
|
366
|
-
end
|
367
|
-
|
368
|
-
def factories_spec_rake_task
|
369
|
-
IO.read find_in_source_paths('factories_spec_rake_task.rb')
|
370
|
-
end
|
371
|
-
|
372
|
-
def generate_secret
|
373
|
-
SecureRandom.hex(64)
|
374
|
-
end
|
375
352
|
|
376
|
-
def port
|
377
|
-
@port ||= [3000, 4000, 5000, 7000, 8000, 9000].sample
|
378
353
|
end
|
379
354
|
end
|
@@ -17,6 +17,23 @@ module Roboparts
|
|
17
17
|
def roboparts_customization
|
18
18
|
invoke :customize_gemfile
|
19
19
|
invoke :setup_development_environment
|
20
|
+
invoke :setup_test_environment
|
21
|
+
invoke :setup_production_environment
|
22
|
+
invoke :setup_staging_environment
|
23
|
+
invoke :setup_secret_token
|
24
|
+
invoke :create_roboparts_views
|
25
|
+
invoke :setup_coffeescript
|
26
|
+
invoke :configure_app
|
27
|
+
invoke :setup_stylesheets
|
28
|
+
invoke :copy_miscellaneous_files
|
29
|
+
invoke :customize_error_pages
|
30
|
+
invoke :remove_routes_comment_lines
|
31
|
+
invoke :setup_git
|
32
|
+
invoke :setup_database
|
33
|
+
invoke :create_github_repo
|
34
|
+
invoke :setup_google_analytics
|
35
|
+
invoke :setup_bundler_audit
|
36
|
+
invoke :outro
|
20
37
|
end
|
21
38
|
|
22
39
|
def customize_gemfile
|
@@ -35,26 +52,6 @@ module Roboparts
|
|
35
52
|
build :configure_generators
|
36
53
|
end
|
37
54
|
|
38
|
-
def setup_database
|
39
|
-
say 'Setting up database'
|
40
|
-
|
41
|
-
if 'postgresql' == options[:database]
|
42
|
-
build :use_postgres_config_template
|
43
|
-
end
|
44
|
-
|
45
|
-
build :create_database
|
46
|
-
end
|
47
|
-
|
48
|
-
def setup_development_environment
|
49
|
-
say 'Setting up the development environment'
|
50
|
-
build :raise_on_delivery_errors
|
51
|
-
build :raise_on_unpermitted_parameters
|
52
|
-
build :provide_setup_script
|
53
|
-
build :provide_dev_prime_task
|
54
|
-
build :configure_generators
|
55
|
-
build :configure_i18n_for_missing_translations
|
56
|
-
end
|
57
|
-
|
58
55
|
def setup_test_environment
|
59
56
|
say 'Setting up test environment'
|
60
57
|
build :setup_factory_girl_for_rspec
|
@@ -63,20 +60,18 @@ module Roboparts
|
|
63
60
|
build :configure_background_jobs_for_rspec
|
64
61
|
build :enable_database_cleaner
|
65
62
|
build :configure_spec_support_features
|
66
|
-
build :configure_i18n_for_test_environment
|
67
|
-
build :configure_i18n_tasks
|
68
63
|
build :configure_action_mailer_in_specs
|
69
64
|
end
|
70
65
|
|
71
66
|
def setup_production_environment
|
72
|
-
say 'Setting up
|
67
|
+
say 'Setting up production environment'
|
73
68
|
build :configure_smtp
|
74
69
|
build :enable_rack_deflater
|
75
70
|
build :setup_asset_host
|
76
71
|
end
|
77
72
|
|
78
73
|
def setup_staging_environment
|
79
|
-
say 'Setting up
|
74
|
+
say 'Setting up staging environment'
|
80
75
|
build :setup_staging_environment
|
81
76
|
end
|
82
77
|
|
@@ -104,10 +99,12 @@ module Roboparts
|
|
104
99
|
build :configure_time_zone
|
105
100
|
build :configure_time_formats
|
106
101
|
build :configure_rack_timeout
|
102
|
+
build :configure_simple_form
|
107
103
|
build :disable_xml_params
|
108
104
|
build :fix_i18n_deprecation_warning
|
109
105
|
build :setup_default_rake_task
|
110
106
|
build :configure_unicorn
|
107
|
+
build :setup_foreman
|
111
108
|
end
|
112
109
|
|
113
110
|
def setup_stylesheets
|
@@ -115,6 +112,20 @@ module Roboparts
|
|
115
112
|
build :setup_stylesheets
|
116
113
|
end
|
117
114
|
|
115
|
+
def copy_miscellaneous_files
|
116
|
+
say 'Copying miscellaneous support files'
|
117
|
+
build :copy_miscellaneous_files
|
118
|
+
end
|
119
|
+
|
120
|
+
def customize_error_pages
|
121
|
+
say 'Customizing the 500/404/422 pages'
|
122
|
+
build :customize_error_pages
|
123
|
+
end
|
124
|
+
|
125
|
+
def remove_routes_comment_lines
|
126
|
+
build :remove_routes_comment_lines
|
127
|
+
end
|
128
|
+
|
118
129
|
def setup_git
|
119
130
|
if !options[:skip_git]
|
120
131
|
say 'Initializing git'
|
@@ -131,6 +142,16 @@ module Roboparts
|
|
131
142
|
build :init_git
|
132
143
|
end
|
133
144
|
|
145
|
+
def setup_database
|
146
|
+
say 'Setting up database'
|
147
|
+
|
148
|
+
if 'postgresql' == options[:database]
|
149
|
+
build :use_postgres_config_template
|
150
|
+
end
|
151
|
+
|
152
|
+
build :create_database
|
153
|
+
end
|
154
|
+
|
134
155
|
def create_github_repo
|
135
156
|
if !options[:skip_git] && options[:github]
|
136
157
|
say 'Creating GitHub repo'
|
@@ -144,26 +165,12 @@ module Roboparts
|
|
144
165
|
end
|
145
166
|
|
146
167
|
def setup_bundler_audit
|
147
|
-
say
|
168
|
+
say 'Setting up bundler-audit'
|
148
169
|
build :setup_bundler_audit
|
149
170
|
end
|
150
171
|
|
151
|
-
def copy_miscellaneous_files
|
152
|
-
say 'Copying miscellaneous support files'
|
153
|
-
build :copy_miscellaneous_files
|
154
|
-
end
|
155
|
-
|
156
|
-
def customize_error_pages
|
157
|
-
say 'Customizing the 500/404/422 pages'
|
158
|
-
build :customize_error_pages
|
159
|
-
end
|
160
|
-
|
161
|
-
def remove_routes_comment_lines
|
162
|
-
build :remove_routes_comment_lines
|
163
|
-
end
|
164
|
-
|
165
172
|
def outro
|
166
|
-
say
|
173
|
+
say 'All set up!'
|
167
174
|
end
|
168
175
|
|
169
176
|
protected
|
data/lib/roboparts/version.rb
CHANGED
data/roboparts.gemspec
CHANGED
@@ -3,22 +3,25 @@ require 'roboparts/version'
|
|
3
3
|
require 'date'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
+
s.required_ruby_version = ">= #{Roboparts::RUBY_VERSION}"
|
6
7
|
s.name = 'roboparts'
|
8
|
+
s.authors = ["Daniel Strunk"]
|
9
|
+
s.email = 'daniel@silentpost.co'
|
7
10
|
s.date = Date.today.strftime('%Y-%m-%d')
|
11
|
+
|
8
12
|
s.description = <<-RUBY
|
9
13
|
Roboparts is a base Rails project that you can upgrade. It is used by SILENTPOST
|
10
14
|
to get a jump start on a working app using preferred settings. It is heavily inspired
|
11
15
|
by Thoughtbot's Suspenders, but is more tailored to small team development and
|
12
16
|
has different preferences.
|
13
17
|
RUBY
|
14
|
-
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
+
|
19
|
+
s.summary = "A custom Rails app using SILENTPOST's development standards"
|
20
|
+
s.homepage = 'http://github.com/silentpost/roboparts'
|
21
|
+
s.license = 'MIT'
|
18
22
|
s.require_paths = ['lib']
|
23
|
+
s.executables = ['roboparts']
|
19
24
|
s.files = `git ls-files`.split("\n")
|
20
|
-
s.homepage = 'http://silentpost.co/roboparts'
|
21
|
-
s.license = 'MIT'
|
22
25
|
s.version = Roboparts::VERSION
|
23
26
|
|
24
27
|
s.add_dependency 'bundler', '~> 1.3'
|
data/spec/fakes/bin/hub
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'capybara/rspec'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
Bundler.require(:default, :test)
|
5
|
+
|
6
|
+
require (Pathname.new(__FILE__).dirname + '../lib/roboparts').expand_path
|
7
|
+
|
8
|
+
Dir['./spec/support/**/*.rb'].each { |file| require file }
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include RobopartsTestHelpers
|
12
|
+
|
13
|
+
config.before(:all) do
|
14
|
+
create_tmp_directory
|
15
|
+
end
|
16
|
+
|
17
|
+
config.before(:each) do
|
18
|
+
drop_dummy_database
|
19
|
+
remove_project_directory
|
20
|
+
|
21
|
+
FakeGithub.clear!
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class FakeGithub
|
2
|
+
RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'hub_commands'), File.dirname(__FILE__))
|
3
|
+
|
4
|
+
def initialize(args)
|
5
|
+
@args = args
|
6
|
+
end
|
7
|
+
|
8
|
+
def run!
|
9
|
+
File.open(RECORDER, 'a') do |file|
|
10
|
+
file.write @args.join(' ')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.clear!
|
15
|
+
FileUtils.rm_rf RECORDER
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.has_created_repo?(repo_name)
|
19
|
+
File.read(RECORDER) == "create #{repo_name}"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module RobopartsTestHelpers
|
2
|
+
APP_NAME = 'dummy'
|
3
|
+
|
4
|
+
def remove_project_directory
|
5
|
+
FileUtils.rm_rf(project_path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_tmp_directory
|
9
|
+
FileUtils.mkdir_p(tmp_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run_roboparts(arguments = nil)
|
13
|
+
Dir.chdir(tmp_path) do
|
14
|
+
Bundler.with_clean_env do
|
15
|
+
ENV['TESTING'] = '1'
|
16
|
+
|
17
|
+
%x(#{roboparts_bin} #{APP_NAME} #{arguments})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def drop_dummy_database
|
23
|
+
if File.exist?(project_path)
|
24
|
+
Dir.chdir(project_path) do
|
25
|
+
Bundler.with_clean_env do
|
26
|
+
`rake db:drop`
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def project_path
|
33
|
+
@project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def tmp_path
|
39
|
+
@tmp_path ||= Pathname.new("#{root_path}/tmp")
|
40
|
+
end
|
41
|
+
|
42
|
+
def roboparts_bin
|
43
|
+
File.join(root_path, 'bin', 'roboparts')
|
44
|
+
end
|
45
|
+
|
46
|
+
def root_path
|
47
|
+
File.expand_path('../../../', __FILE__)
|
48
|
+
end
|
49
|
+
end
|
data/templates/Gemfile.erb
CHANGED
@@ -13,7 +13,9 @@ gem "pg"
|
|
13
13
|
gem "normalize-rails"
|
14
14
|
gem "bourbon"
|
15
15
|
gem "neat"
|
16
|
+
gem "title"
|
16
17
|
|
18
|
+
gem "rack-timeout"
|
17
19
|
gem "delayed_job_active_record"
|
18
20
|
gem "simple_form"
|
19
21
|
gem "unicorn"
|
@@ -27,12 +29,13 @@ end
|
|
27
29
|
|
28
30
|
group :development, :test do
|
29
31
|
gem "bundler-audit", require: false
|
30
|
-
gem "dotenv-rails"
|
31
32
|
gem "factory_girl_rails"
|
32
33
|
gem "rspec-rails"
|
33
34
|
end
|
34
35
|
|
35
36
|
group :test do
|
37
|
+
gem "capybara-webkit"
|
38
|
+
gem "database_cleaner"
|
36
39
|
gem "shoulda-matchers"
|
37
40
|
gem "timecop"
|
38
41
|
end
|
data/templates/Procfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# <%= app_name.humanize %>
|
2
|
+
|
3
|
+
## Getting started
|
4
|
+
|
5
|
+
After you've cloned this repo, run this setup script to set up your machine with the necessary dependencies to run and test this app:
|
6
|
+
|
7
|
+
% ./bin/setup
|
8
|
+
|
9
|
+
It assumes you have a machine equipped with Ruby, Postgres, etc.
|
10
|
+
|
11
|
+
After setting up, you can run the application using [foreman]:
|
12
|
+
|
13
|
+
% foreman start
|
14
|
+
|
15
|
+
If you don't have `foreman`, see [Foreman's install instructions][foreman].
|
16
|
+
|
17
|
+
[foreman]: https://github.com/ddollar/foreman
|
@@ -1,12 +1,11 @@
|
|
1
1
|
<% if ENV["GOOGLE_ANALYTICS_KEY"] %>
|
2
|
-
<script>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
<script type="text/javascript">
|
3
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
4
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
5
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
6
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
</script>
|
8
|
+
ga('create', '<%= ENV["GOOGLE_ANALYTICS_KEY"] %>', 'auto');
|
9
|
+
ga('send', 'pageview');
|
10
|
+
</script>
|
12
11
|
<% end %>
|
data/templates/action_mailer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
@charset
|
1
|
+
@charset "utf-8";
|
2
2
|
|
3
|
-
@import
|
4
|
-
@import
|
5
|
-
@import
|
6
|
-
@import
|
7
|
-
@import
|
3
|
+
@import "normalize-rails";
|
4
|
+
@import "bourbon";
|
5
|
+
@import "base/grid-settings";
|
6
|
+
@import "neat";
|
7
|
+
@import "base/base";
|
data/templates/rails_helper.rb
CHANGED
@@ -12,11 +12,11 @@ module Features
|
|
12
12
|
include Formulaic::Dsl
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
RSpec.configure do |config|
|
16
16
|
config.include Features, type: :feature
|
17
17
|
config.infer_base_class_for_anonymous_controllers = false
|
18
18
|
config.infer_spec_type_from_file_location!
|
19
|
-
config.use_transactional_fixtures =
|
19
|
+
config.use_transactional_fixtures = false
|
20
20
|
end
|
21
21
|
|
22
22
|
ActiveRecord::Migration.maintain_test_schema!
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<meta charset="utf-8"
|
5
|
-
<meta name="ROBOTS" content="NOODP"
|
6
|
-
<meta name="viewport" content="initial-scale=1"
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="ROBOTS" content="NOODP">
|
6
|
+
<meta name="viewport" content="initial-scale=1">
|
7
7
|
<title><%%= title %></title>
|
8
8
|
<%%= stylesheet_link_tag :application, media: "all" %>
|
9
|
-
<%%=
|
9
|
+
<%%= crsf_meta_tags %>
|
10
10
|
</head>
|
11
|
-
<body class
|
12
|
-
<%%= render "flashes"
|
11
|
+
<body class=<%%= body_class %>">
|
12
|
+
<%%= render "flashes" %>
|
13
13
|
<%%= yield %>
|
14
14
|
<%%= render "javascript" %>
|
15
15
|
</body>
|
data/templates/secrets.yml
CHANGED
data/templates/spec_helper.rb
CHANGED
data/templates/unicorn.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# https://devcenter.heroku.com/articles/rails-unicorn
|
2
|
+
|
1
3
|
worker_processes (ENV["UNICORN_WORKERS"] || 3).to_i
|
2
4
|
timeout (ENV["UNICORN_TIMEOUT"] || 15).to_i
|
3
5
|
preload_app true
|
4
6
|
|
5
|
-
before_fork do |
|
7
|
+
before_fork do |_server, _worker|
|
6
8
|
Signal.trap "TERM" do
|
7
|
-
puts "Unicorn master intercepting TERM
|
9
|
+
puts "Unicorn master intercepting TERM, sending myself QUIT instead"
|
8
10
|
Process.kill "QUIT", Process.pid
|
9
11
|
end
|
10
12
|
|
@@ -13,9 +15,9 @@ before_fork do |server, worker|
|
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
after_fork do |
|
18
|
+
after_fork do |_server, _worker|
|
17
19
|
Signal.trap "TERM" do
|
18
|
-
puts "Unicorn worker intercepting TERM
|
20
|
+
puts "Unicorn worker intercepting TERM, waiting for master to send QUIT"
|
19
21
|
end
|
20
22
|
|
21
23
|
if defined? ActiveRecord::Base
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roboparts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Strunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,7 +82,7 @@ executables:
|
|
82
82
|
extensions: []
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
|
-
- ".
|
85
|
+
- ".gitignore"
|
86
86
|
- ".ruby-version"
|
87
87
|
- Gemfile
|
88
88
|
- Gemfile.lock
|
@@ -91,14 +91,20 @@ files:
|
|
91
91
|
- bin/rake
|
92
92
|
- bin/roboparts
|
93
93
|
- bin/rspec
|
94
|
-
- bin/setup
|
95
94
|
- lib/roboparts.rb
|
96
95
|
- lib/roboparts/actions.rb
|
97
96
|
- lib/roboparts/app_builder.rb
|
98
97
|
- lib/roboparts/generators/app_generator.rb
|
99
98
|
- lib/roboparts/version.rb
|
100
99
|
- roboparts.gemspec
|
100
|
+
- spec/fakes/bin/hub
|
101
|
+
- spec/features/github_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
- spec/support/fake_github.rb
|
104
|
+
- spec/support/roboparts.rb
|
101
105
|
- templates/Gemfile.erb
|
106
|
+
- templates/Procfile
|
107
|
+
- templates/README.md.erb
|
102
108
|
- templates/_analytics.html.erb
|
103
109
|
- templates/_flashes.html.erb
|
104
110
|
- templates/_javascript.html.erb
|
@@ -107,26 +113,25 @@ files:
|
|
107
113
|
- templates/background_jobs_rspec.rb
|
108
114
|
- templates/bin_setup.erb
|
109
115
|
- templates/bundler_audit.rake
|
110
|
-
- templates/config_i18n_tasks.yml
|
111
116
|
- templates/config_locales_en.yml.erb
|
112
117
|
- templates/database_cleaner_rspec.rb
|
113
118
|
- templates/development_seeds.rb
|
114
119
|
- templates/disable_xml_params.rb
|
115
120
|
- templates/errors.rb
|
116
121
|
- templates/factory_girl_rspec.rb
|
117
|
-
- templates/i18n.rb
|
118
122
|
- templates/json_encoding.rb
|
119
123
|
- templates/postgresql_database.yml.erb
|
120
124
|
- templates/rack_timeout.rb
|
121
125
|
- templates/rails_helper.rb
|
122
126
|
- templates/roboparts_gitignore
|
123
127
|
- templates/roboparts_layout.html.erb.erb
|
128
|
+
- templates/sample.env
|
124
129
|
- templates/secrets.yml
|
125
130
|
- templates/smtp.rb
|
126
131
|
- templates/spec_helper.rb
|
127
132
|
- templates/staging.rb
|
128
133
|
- templates/unicorn.rb
|
129
|
-
homepage: http://
|
134
|
+
homepage: http://github.com/silentpost/roboparts
|
130
135
|
licenses:
|
131
136
|
- MIT
|
132
137
|
metadata: {}
|
@@ -138,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
143
|
requirements:
|
139
144
|
- - ">="
|
140
145
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
146
|
+
version: 2.1.3
|
142
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
148
|
requirements:
|
144
149
|
- - ">="
|
@@ -149,5 +154,5 @@ rubyforge_project:
|
|
149
154
|
rubygems_version: 2.2.2
|
150
155
|
signing_key:
|
151
156
|
specification_version: 4
|
152
|
-
summary: A custom Rails
|
157
|
+
summary: A custom Rails app using SILENTPOST's development standards
|
153
158
|
test_files: []
|
data/.DS_Store
DELETED
Binary file
|
data/bin/setup
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env sh
|
2
|
-
|
3
|
-
# Run this script immediately after cloning the codebase.
|
4
|
-
|
5
|
-
# Exit if any subcommand fails
|
6
|
-
set -e
|
7
|
-
|
8
|
-
# Set up Ruby dependencies via Bundler
|
9
|
-
bundle install
|
10
|
-
|
11
|
-
# Add binstubs to PATH in ~/.zshenv like this:
|
12
|
-
# export PATH=".git/safe/../../bin:$PATH"
|
13
|
-
mkdir -p .git/safe
|
data/templates/i18n.rb
DELETED