myrails 4.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/myrails.rb +366 -167
- data/lib/myrails/templates/capistrano/config/deploy/templates/maintenance/index.html +41 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/monit.conf.erb +4 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/nginx.conf.erb +69 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/unicorn.rb.erb +26 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/unicorn_init.sh.erb +71 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/maintenance.rake +16 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/monit.rake +64 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/nginx.rake +68 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/unicorn.rake +114 -0
- data/lib/myrails/templates/{assets → rails/app/assets/javascripts}/application.js +0 -1
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets}/animate.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets}/application.css.sass +0 -2
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/cerulean.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/cosmo.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/cyborg.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/darkly.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/flatly.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/journal.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/lumen.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/paper.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/readable.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/sandstone.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/simplex.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/slate.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/spacelab.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/superhero.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/united.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/yeti.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets}/will_paginate.scss +0 -0
- data/lib/myrails/templates/rails/{controller.rb → app/controllers/controller.rb} +0 -0
- data/lib/myrails/templates/rails/{namespace_controller.rb → app/controllers/namespace_controller.rb} +0 -0
- data/lib/myrails/templates/rails/{application_helper.rb → app/helpers/application_helper.rb} +0 -0
- data/lib/myrails/templates/{mailer → rails/app/mailers}/dev_mail_interceptor.rb +0 -0
- data/lib/myrails/templates/{mailer → rails/app/mailers}/sendgrid.rb +0 -0
- data/lib/myrails/templates/rails/{model.rb → app/models/model.rb} +0 -0
- data/lib/myrails/templates/rails/{namespace_model.rb → app/models/namespace_model.rb} +0 -0
- data/lib/myrails/templates/rails/{pundit.rb → app/policies/pundit.rb} +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/base.rb +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/presenter.rb +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/presenter_config.rb +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/presenter_spec.rb +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_error_messages.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_footer.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_info_messages.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_nav.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_success_message.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/application.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed-with-address-and-phones.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed-with-contact-form.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed-with-search.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed-with-address-and-phones.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed-with-contact-form.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed-with-search.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed.html.haml +0 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_detailed_pagination.html.haml +4 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_error_messages.html.haml +9 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_footer.html.haml +24 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_info_messages.html.haml +14 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_nav.html.haml +27 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_simple_pagination.html.haml +2 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_success_message.html.haml +7 -0
- data/lib/myrails/templates/rails/app/views/layout/material/application.html.haml +19 -0
- data/lib/myrails/templates/rails/app/views/layout/material/mailer.html.haml +246 -0
- data/lib/myrails/templates/rails/app/views/layout/material/mailer.text.haml +1 -0
- data/lib/myrails/templates/rails/config/application.example.yml +40 -0
- data/lib/myrails/templates/spec/controller.rb +123 -0
- data/lib/myrails/templates/{rspec → spec}/factory.rb +1 -1
- data/lib/myrails/templates/spec/feature.rb +8 -0
- data/lib/myrails/templates/{rspec → spec}/files.rb +0 -0
- data/lib/myrails/templates/spec/helper.rb +2 -0
- data/lib/myrails/templates/{rspec → spec}/model.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/pundit.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/request.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/request_shared_example.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/shared_example.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/database_cleaner.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/devise.rb +1 -1
- data/lib/myrails/templates/spec/support/configs/factory_bot.rb +3 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/mailer.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/shoulda_matchers.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/silence_backtrace.rb +0 -0
- data/lib/myrails/templates/spec/support/helpers/javascript.rb +12 -0
- data/lib/myrails/templates/spec/support/helpers/mailer.rb +9 -0
- data/lib/myrails/templates/spec/support/shared_examples/requires_authentication.rb +14 -0
- data/lib/myrails/templates/spec/support/shared_examples/requires_authorization.rb +16 -0
- data/lib/myrails/templates/spec/support/shared_examples/supports_file_type.rb +25 -0
- data/lib/myrails/version.rb +1 -1
- metadata +91 -68
- data/lib/myrails/templates/initializers/application_vars.rb +0 -2
- data/lib/myrails/templates/rails/application.yml +0 -19
- data/lib/myrails/templates/rspec/controller.rb +0 -98
- data/lib/myrails/templates/rspec/factory_girl.rb +0 -3
- data/lib/myrails/templates/rspec/javascript.rb +0 -8
- data/lib/myrails/templates/rspec/router.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7af89ba21720951b5f321eaa480e657d524b16c9
|
4
|
+
data.tar.gz: d3a11a743f04736f6ce534a0ef48543d00616732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd366e4bc56d862be02e2f68669b80dfcf7a2dcd2fba3f3e49c860c3ab64f31167352bce9840dfc30b9d04b3556e09c931c0c61cbf51034a3fb9e8f35c9498ed
|
7
|
+
data.tar.gz: e5889ff4a08db266f0e18ed64e4e35e4382650910c1b900b82a96b2142fe79e91bcef8d02ec54077012ff10aaa7e0cb7da468aaaddd3d86536e603996792a960
|
data/lib/myrails.rb
CHANGED
@@ -12,7 +12,7 @@ module Myrails
|
|
12
12
|
no_tasks do
|
13
13
|
desc 'install_application_helper', 'Replace current application helper with one that has commonly used code'
|
14
14
|
def install_application_helper
|
15
|
-
copy_file 'rails/application_helper.rb', 'app/helpers/application_helper.rb'
|
15
|
+
copy_file 'rails/app/helpers/application_helper.rb', 'app/helpers/application_helper.rb'
|
16
16
|
end
|
17
17
|
|
18
18
|
desc 'install_gems', 'Add & Install gems that I commonly use'
|
@@ -21,7 +21,7 @@ module Myrails
|
|
21
21
|
group :test do
|
22
22
|
gem 'simplecov'
|
23
23
|
gem 'shoulda-matchers'
|
24
|
-
gem '
|
24
|
+
gem 'factory_bot_rails'
|
25
25
|
gem 'database_cleaner'
|
26
26
|
gem 'chromedriver-helper'
|
27
27
|
gem 'launchy'
|
@@ -39,37 +39,35 @@ CODE
|
|
39
39
|
end
|
40
40
|
|
41
41
|
insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
|
42
|
-
gem 'bootstrap-sass', '~> 3.3.1'
|
43
|
-
gem 'autoprefixer-rails'
|
44
42
|
gem 'haml-rails'
|
45
43
|
gem "ransack"
|
46
44
|
gem 'will_paginate'
|
47
45
|
gem "font-awesome-rails"
|
48
46
|
gem 'trix'
|
49
47
|
gem 'record_tag_helper'
|
50
|
-
|
48
|
+
gem 'jquery-rails'
|
49
|
+
CODE
|
51
50
|
end
|
52
51
|
run 'bundle install'
|
53
52
|
|
54
53
|
insert_into_file 'app/controllers/application_controller.rb', before: 'end' do <<-CODE
|
55
|
-
|
56
|
-
|
54
|
+
private
|
55
|
+
CODE
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
60
59
|
desc 'install_assets', 'Generate common asset pipeline files'
|
61
60
|
def install_assets
|
62
61
|
run "rm app/assets/stylesheets/application.css"
|
63
|
-
copy_file 'assets/application.css.sass', 'app/assets/stylesheets/application.css.sass'
|
64
|
-
copy_file 'assets/application.js', 'app/assets/javascripts/application.js'
|
65
|
-
copy_file 'assets/animate.scss', 'app/assets/stylesheets/animate.scss'
|
66
|
-
copy_file 'assets/will_paginate.scss', 'app/assets/stylesheets/will_paginate.scss'
|
62
|
+
copy_file 'rails/app/assets/stylesheets/application.css.sass', 'app/assets/stylesheets/application.css.sass'
|
63
|
+
copy_file 'rails/app/assets/javascripts/application.js', 'app/assets/javascripts/application.js'
|
64
|
+
copy_file 'rails/app/assets/stylesheets/animate.scss', 'app/assets/stylesheets/animate.scss'
|
65
|
+
copy_file 'rails/app/assets/stylesheets/will_paginate.scss', 'app/assets/stylesheets/will_paginate.scss'
|
67
66
|
end
|
68
67
|
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
themes = Dir[File.join(TEMPLATES, 'assets', 'bootstrap_themes', '*')]
|
69
|
+
def choose_bootstrap_theme
|
70
|
+
themes = Dir[File.join(TEMPLATES, 'rails', 'app','assets', 'stylesheets', 'bootstrap', 'bootstrap_themes', '*')]
|
73
71
|
|
74
72
|
themes.each_with_index do |theme, index|
|
75
73
|
say "[#{index}] #{File.basename(theme,'.*')}"
|
@@ -77,18 +75,18 @@ gem 'record_tag_helper'
|
|
77
75
|
|
78
76
|
idx = ask("Choose a color theme (by number) for the application. Default: 'spacelab'")
|
79
77
|
idx = idx.empty? ? themes.index{|theme| theme if theme.include?('spacelab')} : idx.to_i
|
78
|
+
|
80
79
|
copy_file(themes[idx], "app/assets/stylesheets/#{File.basename(themes[idx])}")
|
81
80
|
|
82
81
|
inject_into_file 'app/assets/stylesheets/application.css.sass', before: "@import will_paginate" do <<-CODE
|
83
|
-
|
84
|
-
|
82
|
+
@import #{File.basename(themes[idx], '.*')}
|
83
|
+
CODE
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
footers_css = Dir[File.join(TEMPLATES, 'layout', 'footers', 'css', '*')]
|
87
|
+
def choose_bootstrap_footer
|
88
|
+
footers = Dir[File.join(TEMPLATES, 'rails', 'app', 'views','layout', 'bootstrap', 'footers', '*.haml')]
|
89
|
+
footers_css = Dir[File.join(TEMPLATES, 'rails', 'app', 'views', 'layout', 'bootstrap', 'footers', 'css', '*')]
|
92
90
|
|
93
91
|
footers.each_with_index do |footer, index|
|
94
92
|
say "[#{index}] #{File.basename(footer,'.html.*')}"
|
@@ -100,42 +98,114 @@ gem 'record_tag_helper'
|
|
100
98
|
copy_file footers_css[idx], "app/assets/stylesheets/#{File.basename(footers_css[idx])}"
|
101
99
|
|
102
100
|
inject_into_file 'app/assets/stylesheets/application.css.sass', after: "@import animate\n" do <<-CODE
|
103
|
-
|
104
|
-
|
101
|
+
@import #{File.basename(footers_css[idx], '.*')}
|
102
|
+
CODE
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def copy_bootstrap_files
|
107
|
+
template 'rails/app/views/layout/bootstrap/application.html.haml', 'app/views/layouts/application.html.haml'
|
108
|
+
template 'rails/app/views/layout/bootstrap/_nav.html.haml', 'app/views/layouts/_nav.html.haml'
|
109
|
+
copy_file 'rails/app/views/layout/bootstrap/_info_messages.html.haml', 'app/views/layouts/_info_messages.html.haml'
|
110
|
+
copy_file 'rails/app/views/layout/bootstrap/_success_message.html.haml', 'app/views/layouts/_success_message.html.haml'
|
111
|
+
copy_file 'rails/app/views/layout/bootstrap/_error_messages.html.haml', 'app/views/layouts/_error_messages.html.haml'
|
112
|
+
# copy_file 'rails/app/views/layout/bootstrap/_footer.html.haml', 'app/views/layouts/_footer.html.haml'
|
113
|
+
end
|
114
|
+
|
115
|
+
desc 'install_bootstrap', 'Generate Bootrap css theme'
|
116
|
+
def install_bootstrap
|
117
|
+
insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
|
118
|
+
gem 'bootstrap-sass', '~> 3.3.1'
|
119
|
+
gem 'autoprefixer-rails'
|
120
|
+
CODE
|
121
|
+
end
|
122
|
+
|
123
|
+
insert_into_file 'app/assets/stylesheets/application.css.sass', before: '@import trix' do <<-CODE
|
124
|
+
@import bootstrap-sprockets
|
125
|
+
@import bootstrap
|
126
|
+
CODE
|
127
|
+
end
|
128
|
+
|
129
|
+
insert_into_file 'app/assets/javascripts/application.js', before: '//= require trix' do <<-CODE
|
130
|
+
//= require bootstrap-sprockets
|
131
|
+
CODE
|
132
|
+
end
|
133
|
+
run 'bundle install'
|
134
|
+
choose_bootstrap_theme
|
135
|
+
choose_bootstrap_footer
|
136
|
+
copy_bootstrap_files
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
def copy_material_files
|
141
|
+
Dir["#{__dir__}/myrails/templates/rails/app/views/layout/material/**/*"].each do |file|
|
142
|
+
copy_file file, "app/views/layouts/#{File.basename(file)}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
desc 'install_material', 'Generate Material css theme'
|
147
|
+
def install_material
|
148
|
+
insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
|
149
|
+
gem 'materialize-sass'
|
150
|
+
gem 'material_icons'
|
151
|
+
CODE
|
152
|
+
end
|
153
|
+
|
154
|
+
run 'bundle install'
|
155
|
+
|
156
|
+
copy_material_files
|
157
|
+
|
158
|
+
insert_into_file 'app/assets/stylesheets/application.css.sass', before: '@import trix' do <<-CODE
|
159
|
+
@import "materialize/components/color"
|
160
|
+
$primary-color: color("grey", "darken-3") !default
|
161
|
+
$secondary-color: color("grey", "base") !default
|
162
|
+
@import materialize
|
163
|
+
@import material_icons
|
164
|
+
CODE
|
165
|
+
end
|
166
|
+
|
167
|
+
insert_into_file 'app/assets/javascripts/application.js', before: "//= require trix" do <<-CODE
|
168
|
+
//= require materialize
|
169
|
+
CODE
|
105
170
|
end
|
106
171
|
end
|
107
172
|
|
108
173
|
desc 'install_layout', 'Generate common layout files'
|
109
174
|
def install_layout
|
175
|
+
answer = ask 'Would you like to use [B]ootstrap or [M]aterial'
|
176
|
+
|
110
177
|
run 'rm app/views/layouts/application.html.erb'
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
178
|
+
|
179
|
+
install_assets
|
180
|
+
|
181
|
+
if answer =~ /^B|b/
|
182
|
+
install_bootstrap
|
183
|
+
elsif answer =~ /^M|m/
|
184
|
+
install_material
|
185
|
+
end
|
186
|
+
|
117
187
|
insert_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do <<-CODE
|
118
|
-
|
119
|
-
|
188
|
+
add_flash_types :error, :success
|
189
|
+
CODE
|
120
190
|
end
|
121
191
|
end
|
122
192
|
|
123
193
|
desc 'install_heroku', 'setup application for use with heroku using sqlite3 for development'
|
124
194
|
def install_heroku
|
125
195
|
insert_into_file 'Gemfile', before: "group :development, :test do\n" do <<-CODE
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
196
|
+
group :production do
|
197
|
+
gem 'pg'
|
198
|
+
gem 'rails_12factor'
|
199
|
+
end
|
130
200
|
|
131
|
-
|
201
|
+
CODE
|
132
202
|
end
|
133
203
|
copy_file 'db/sqlite3_database.yml', 'config/database.yml'
|
134
204
|
copy_file 'heroku/Procfile', 'Procfile'
|
135
205
|
copy_file 'heroku/puma.rb', 'config/puma.rb'
|
136
206
|
end
|
137
207
|
|
138
|
-
desc 'git_init', "Initialize git with some files
|
208
|
+
desc 'git_init', "Initialize git with some files automatically ignored"
|
139
209
|
def git_init
|
140
210
|
run 'git init'
|
141
211
|
run 'echo /coverage >> .gitignore'
|
@@ -149,47 +219,51 @@ gem 'record_tag_helper'
|
|
149
219
|
copy_file 'ui/ui_controller.rb', 'app/controllers/ui_controller.rb'
|
150
220
|
copy_file 'ui/index.html.haml', 'app/views/ui/index.html.haml'
|
151
221
|
inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do <<-CODE
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
222
|
+
# Requires an application restart everytime a new page is added.
|
223
|
+
Dir.glob('app/views/ui/*.html.haml').sort.each do |file|
|
224
|
+
action = File.basename(file,'.html.haml')
|
225
|
+
get \"ui/\#{action}\", controller: 'ui', action: action
|
226
|
+
end
|
227
|
+
CODE
|
158
228
|
end
|
159
229
|
end
|
160
230
|
|
161
231
|
desc 'install_rspec', 'Generate rspec structure & rspec configuration that I commonly use'
|
162
232
|
def install_rspec
|
163
233
|
insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
|
164
|
-
|
165
|
-
|
166
|
-
CODE
|
234
|
+
gem 'rspec-rails', group: :test
|
235
|
+
CODE
|
167
236
|
end
|
237
|
+
|
168
238
|
run 'bundle install'
|
169
239
|
run 'rails g rspec:install'
|
240
|
+
|
170
241
|
install_rails_helper
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
copy_file 'rspec/router.rb', 'spec/support/configs/router.rb'
|
178
|
-
copy_file 'rspec/files.rb', 'spec/support/configs/files.rb'
|
242
|
+
|
243
|
+
Dir["#{__dir__}/myrails/templates/spec/**/*"].each do |file|
|
244
|
+
if file.include?('/support/') && !['devise'].include?(File.basename(file, '.rb'))
|
245
|
+
copy_file file, "#{file.gsub(__dir__+'/myrails/templates/', '')}" unless File.directory? file
|
246
|
+
end
|
247
|
+
end
|
179
248
|
end
|
180
249
|
|
181
250
|
desc 'install_rails_helper', 'Add code to rspec/rails_helper so rspec runs the way I like'
|
182
251
|
def install_rails_helper
|
183
252
|
inject_into_file "spec/rails_helper.rb", after: "require 'rspec/rails'\n" do <<-CODE
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
253
|
+
require 'simplecov'
|
254
|
+
SimpleCov.start
|
255
|
+
|
256
|
+
Capybara.app_host = "http://localhost:3000"
|
257
|
+
Capybara.server_host = "localhost"
|
258
|
+
Capybara.server_port = "3000"
|
259
|
+
|
260
|
+
#use Chromedriver
|
261
|
+
unless ENV['NOCHROME']
|
262
|
+
Capybara.register_driver :selenium do |app|
|
263
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
CODE
|
193
267
|
end
|
194
268
|
|
195
269
|
gsub_file 'spec/rails_helper.rb', "# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }", "Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }"
|
@@ -197,19 +271,26 @@ gem 'record_tag_helper'
|
|
197
271
|
gsub_file "spec/rails_helper.rb", "config.use_transactional_fixtures = true", "config.use_transactional_fixtures = false"
|
198
272
|
|
199
273
|
inject_into_file 'spec/rails_helper.rb', after: "RSpec.configure do |config|\n" do <<-CODE
|
200
|
-
|
201
|
-
|
274
|
+
# Can use methods like dom_id in features
|
275
|
+
config.include ActionView::RecordIdentifier, type: :feature
|
276
|
+
# Can use methods likke strip_tags in features
|
277
|
+
config.include ActionView::Helpers::SanitizeHelper, type: :feature
|
278
|
+
# Can use methods like truncate
|
279
|
+
config.include ActionView::Helpers::TextHelper, type: :feature
|
280
|
+
config.include(JavascriptHelper, type: :feature)
|
281
|
+
config.include MailerHelper
|
282
|
+
CODE
|
202
283
|
end
|
203
284
|
end
|
204
285
|
|
205
286
|
desc 'install_devise', 'Generate devise files'
|
206
287
|
def install_devise
|
207
288
|
insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
|
208
|
-
|
209
|
-
|
289
|
+
gem 'devise'
|
290
|
+
CODE
|
210
291
|
end
|
211
292
|
run 'bundle update'
|
212
|
-
copy_file '
|
293
|
+
copy_file 'spec/support/configs/devise.rb', 'spec/support/configs/devise.rb'
|
213
294
|
|
214
295
|
devise_model = ask("What would you like to call the devise model? Default: user")
|
215
296
|
devise_model = devise_model.empty? ? 'user' : devise_model
|
@@ -218,33 +299,34 @@ gem 'record_tag_helper'
|
|
218
299
|
run "rails generate devise #{devise_model}"
|
219
300
|
run 'rails generate devise:views'
|
220
301
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
302
|
+
gsub_file 'app/controllers/application_controller.rb', "protect_from_forgery with: :exception", "protect_from_forgery"
|
303
|
+
inject_into_file 'app/controllers/application_controller.rb', after: "protect_from_forgery\n" do <<-CODE
|
304
|
+
# Devise authentication method
|
305
|
+
before_action :authenticate_#{devise_model}!
|
306
|
+
CODE
|
225
307
|
end
|
226
308
|
|
227
309
|
if File.exist?('app/controllers/ui_controller.rb')
|
228
310
|
inject_into_file 'app/controllers/ui_controller.rb', after: "class UiController < ApplicationController\n" do <<-CODE
|
229
|
-
|
230
|
-
|
311
|
+
skip_before_action :authenticate_#{devise_model}!
|
312
|
+
CODE
|
231
313
|
end
|
232
314
|
end
|
233
315
|
|
234
316
|
if yes?('Will you be needing registration params override? Answer "yes" if you will be adding attributes to the user model')
|
235
|
-
inject_into_file 'app/controllers/application_controller.rb', after: "
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
317
|
+
inject_into_file 'app/controllers/application_controller.rb', after: "before_action :authenticate_#{devise_model}!\n" do <<-CODE
|
318
|
+
# Before action include additional registration params
|
319
|
+
# (see #configure_permitted_parameters)
|
320
|
+
before_action :configure_permitted_parameters, if: :devise_controller?
|
321
|
+
CODE
|
240
322
|
end
|
241
323
|
|
242
324
|
inject_into_file 'app/controllers/application_controller.rb', after: "private\n" do <<-CODE
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
325
|
+
# Register additional registration params
|
326
|
+
def configure_permitted_parameters
|
327
|
+
devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute, :attribute])
|
328
|
+
end
|
329
|
+
CODE
|
248
330
|
end
|
249
331
|
end
|
250
332
|
end
|
@@ -258,42 +340,42 @@ gem 'pundit'
|
|
258
340
|
|
259
341
|
insert_into_file 'Gemfile', after: "group :test do\n" do <<-CODE
|
260
342
|
gem 'pundit-matchers', '~> 1.1.0'
|
261
|
-
|
343
|
+
CODE
|
262
344
|
end
|
263
345
|
|
264
346
|
run 'bundle update'
|
265
347
|
run 'rails g pundit:install'
|
266
348
|
|
267
349
|
inject_into_file 'app/controllers/application_controller.rb', after: "protect_from_forgery with: :exception\n" do <<-CODE
|
268
|
-
|
269
|
-
|
270
|
-
|
350
|
+
# Add pundit authorization
|
351
|
+
include Pundit
|
352
|
+
CODE
|
271
353
|
end
|
272
354
|
|
273
355
|
inject_into_file 'app/controllers/application_controller.rb', after: "rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized\n" do <<-CODE
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
356
|
+
# Rescue from pundit error
|
357
|
+
# (see #user_not_authorized)
|
358
|
+
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
359
|
+
CODE
|
278
360
|
end
|
279
361
|
|
280
362
|
inject_into_file 'app/controllers/application_controller.rb', after: "private\n" do <<-CODE
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
363
|
+
# Method to gracefully let a user know they are are not authorized
|
364
|
+
#
|
365
|
+
# @return flash [Hash] the action notice
|
366
|
+
def user_not_authorized
|
367
|
+
flash[:alert] = "You are not authorized to perform this action."
|
368
|
+
redirect_to home_path
|
369
|
+
end
|
370
|
+
CODE
|
289
371
|
end
|
290
372
|
end
|
291
373
|
|
292
374
|
desc 'install_footnotes', 'Install rails-footnotes and run its generator'
|
293
375
|
def install_footnotes
|
294
376
|
insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
|
295
|
-
|
296
|
-
|
377
|
+
gem 'rails-footnotes'
|
378
|
+
CODE
|
297
379
|
end
|
298
380
|
run 'bundle install'
|
299
381
|
run 'rails generate rails_footnotes:install'
|
@@ -330,59 +412,153 @@ CODE
|
|
330
412
|
install_pundit
|
331
413
|
install_rspec
|
332
414
|
install_footnotes
|
333
|
-
|
415
|
+
config_env
|
416
|
+
install_figaro
|
334
417
|
git_init
|
335
418
|
say 'Dont forget to run config_env'
|
336
419
|
end
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
def install_capistrano
|
424
|
+
insert_into_file 'Gemfile', after: "group :development do\n" do <<-CODE
|
425
|
+
gem 'capistrano', '~> 3.6', group: :development
|
426
|
+
gem 'capistrano-rails', '~> 1.3', group: :development
|
427
|
+
gem 'capistrano-rvm', group: :development
|
428
|
+
CODE
|
429
|
+
end
|
430
|
+
|
431
|
+
run 'bundle install'
|
432
|
+
run 'bundle exec cap install'
|
433
|
+
gsub_file 'Capfile', '# require "capistrano/rvm"', 'require "capistrano/rvm"'
|
434
|
+
gsub_file 'config/deploy.rb', '# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp', 'ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp'
|
435
|
+
gsub_file 'config/deploy.rb', '# set :deploy_to, "/var/www/my_app_name"', 'set :deploy_to, "/var/www/#{fetch(:application)}"'
|
436
|
+
gsub_file 'config/deploy.rb', '# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"', 'append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"'
|
437
|
+
|
438
|
+
run 'mkdir -p config/deploy/templates/maintenance'
|
439
|
+
|
440
|
+
Dir["#{__dir__}/myrails/templates/capistrano/**/*"].each do |file|
|
441
|
+
copy_file file, "#{file.gsub(__dir__+'/myrails/templates/capistrano/', '')}" unless File.directory? file
|
442
|
+
end
|
443
|
+
|
444
|
+
insert_into_file 'config/deploy.rb', before: '# Default branch is :master' do <<-CODE
|
445
|
+
set :deploy_via, :remote_cache
|
446
|
+
set :ssh_options, {forward_agent: true}
|
447
|
+
CODE
|
448
|
+
end
|
449
|
+
insert_into_file 'Capfile', after: "require \"capistrano/rvm\"\n" do <<-CODE
|
450
|
+
require "capistrano/rails"
|
451
|
+
CODE
|
452
|
+
end
|
453
|
+
insert_into_file 'config/deploy.rb', after: "# set :ssh_options, verify_host_key: :secure\n" do <<-CODE
|
454
|
+
namespace :deploy do
|
455
|
+
# after :restart, :clear_cache do
|
456
|
+
# on roles(:app), in: :groups, limit: 3, wait: 10 do
|
457
|
+
# # Here we can do anything such as:
|
458
|
+
# # within release_path do
|
459
|
+
# # execute :rake, 'cache:clear'
|
460
|
+
# # end
|
461
|
+
# end
|
462
|
+
# end
|
463
|
+
before :finishing, :restart do
|
464
|
+
on roles(:app) do
|
465
|
+
invoke 'unicorn:restart'
|
466
|
+
invoke 'nginx:restart'
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
task :upload_app_yml do
|
471
|
+
on roles(:app) do
|
472
|
+
info 'Uploading application.yml'
|
473
|
+
upload!("\#{Dir.pwd}/config/application.yml", "\#{fetch(:release_path)}/config")
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
before :starting, 'maintenance:on'
|
478
|
+
before :starting, 'monit:stop'
|
479
|
+
before :compile_assets, :upload_app_yml
|
480
|
+
before :published, 'nginx:create_nginx_config'
|
481
|
+
before :published, 'unicorn:create_unicorn_config'
|
482
|
+
before :published,'unicorn:create_unicorn_init'
|
483
|
+
after :restart, 'monit:create_monit_conf'
|
484
|
+
after :finished, 'monit:start'
|
485
|
+
after :finished, 'maintenance:off'
|
486
|
+
end
|
487
|
+
CODE
|
488
|
+
end
|
489
|
+
|
490
|
+
insert_into_file 'config/deploy/production.rb', before: "# role-based syntax" do <<-CODE
|
491
|
+
set :fqdn,'domain.com'
|
492
|
+
CODE
|
493
|
+
end
|
494
|
+
|
495
|
+
insert_into_file 'config/deploy/staging.rb', before: "# role-based syntax" do <<-CODE
|
496
|
+
set :fqdn,'domain.com'
|
497
|
+
CODE
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
def install_figaro
|
502
|
+
insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
|
503
|
+
gem "figaro"
|
504
|
+
CODE
|
505
|
+
end
|
506
|
+
|
507
|
+
run 'bundle install'
|
508
|
+
run 'bundle exec figaro install'
|
509
|
+
copy_file 'rails/config/application.example.yml', 'config/application.example.yml'
|
510
|
+
end
|
511
|
+
|
337
512
|
end
|
513
|
+
# end of no_tasks
|
338
514
|
|
339
515
|
desc 'model', "Generates a rails model with the given name along with its related spec file and namespace prefix for table creation. Use '/' to create a namespaced model"
|
340
516
|
option :name, required: true
|
341
517
|
def model
|
342
|
-
template 'rails/model.rb', "app/models/#{options[:name].downcase}.rb"
|
343
|
-
template 'rails/namespace_model.rb', "app/models/#{options[:name].split("/").first.singularize.downcase}.rb" if options[:name].include?("/")
|
344
|
-
template '
|
518
|
+
template 'rails/app/models/model.rb', "app/models/#{options[:name].downcase}.rb"
|
519
|
+
template 'rails/app/models/namespace_model.rb', "app/models/#{options[:name].split("/").first.singularize.downcase}.rb" if options[:name].include?("/")
|
520
|
+
template 'spec/model.rb', "spec/models/#{options[:name].downcase}_spec.rb"
|
345
521
|
end
|
346
522
|
|
347
523
|
desc 'controller', "Generates a rails controller with the given name along with related spec file. Use '/' to create a namespaced controller"
|
348
524
|
option :name, required: true
|
349
525
|
def controller
|
350
|
-
template 'rails/controller.rb', "app/controllers/#{options[:name].downcase.pluralize}_controller.rb"
|
526
|
+
template 'rails/app/controllers/controller.rb', "app/controllers/#{options[:name].downcase.pluralize}_controller.rb"
|
351
527
|
if options[:name].include?("/")
|
352
528
|
parent, child = options[:name].split("/")
|
353
|
-
template 'rails/namespace_controller.rb', "app/controllers/#{parent}/#{parent.downcase}_controller.rb"
|
529
|
+
template 'rails/app/controllers/namespace_controller.rb', "app/controllers/#{parent}/#{parent.downcase}_controller.rb"
|
354
530
|
end
|
355
|
-
template '
|
531
|
+
template 'spec/controller.rb', "spec/controllers/#{options[:name].downcase.pluralize}_controller_spec.rb"
|
356
532
|
run "mkdir -p app/views/#{options[:name].downcase.pluralize}"
|
357
533
|
end
|
358
534
|
|
359
535
|
desc 'policy', "Generates a pundit policy with the given name and a related spec file. Use '/' to create a namespaced policy"
|
360
536
|
option :name, required: true
|
361
537
|
def policy
|
362
|
-
template 'rails/pundit.rb', "app/policies/#{options[:name].downcase}_policy.rb"
|
363
|
-
template '
|
538
|
+
template 'rails/app/policies/pundit.rb', "app/policies/#{options[:name].downcase}_policy.rb"
|
539
|
+
template 'spec/pundit.rb', "spec/policies/#{options[:name].downcase}_policy_spec.rb"
|
364
540
|
end
|
365
541
|
|
366
542
|
desc 'presenter', "Generates a presenter class with the given name and a related spec file. Use '/' to create a namespaced presenter"
|
367
543
|
option :name, required: true
|
368
544
|
def presenters
|
369
|
-
copy_file 'presenters/base.rb', 'app/presenters/base_presenter.rb'
|
370
|
-
template 'presenters/presenter.rb', "app/presenters/#{options[:name].downcase}_presenter.rb"
|
371
|
-
copy_file 'presenters/presenter_config.rb', 'spec/support/configs/presenter.rb'
|
372
|
-
template 'presenters/presenter_spec.rb', "spec/presenters/#{options[:name].downcase}_presenter_spec.rb"
|
545
|
+
copy_file 'rails/app/presenters/base.rb', 'app/presenters/base_presenter.rb'
|
546
|
+
template 'rails/app/presenters/presenter.rb', "app/presenters/#{options[:name].downcase}_presenter.rb"
|
547
|
+
copy_file 'rails/app/presenters/presenter_config.rb', 'spec/support/configs/presenter.rb'
|
548
|
+
template 'rails/app/presenters/presenter_spec.rb', "spec/presenters/#{options[:name].downcase}_presenter_spec.rb"
|
373
549
|
end
|
374
550
|
|
375
|
-
desc 'factory', "Generates a
|
551
|
+
desc 'factory', "Generates a factory_bot factory in the spec/factories directory. Use '/' to create a namespaced factory"
|
376
552
|
option :name, required: true
|
377
553
|
def factory
|
378
|
-
template '
|
554
|
+
template 'spec/factory.rb', "spec/factories/#{options[:name].downcase}.rb"
|
379
555
|
end
|
380
556
|
|
381
557
|
desc 'sendgrid', 'Generate sendgrid initializer and mail interceptor'
|
382
558
|
option :email, required: true
|
383
559
|
def sendgrid
|
384
|
-
copy_file '
|
385
|
-
template '
|
560
|
+
copy_file 'rails/app/mailers/sendgrid.rb', 'config/initializers/sendgrid.rb'
|
561
|
+
template 'rails/app/mailers/dev_mail_interceptor.rb', 'app/mailers/dev_mail_interceptor.rb'
|
386
562
|
ENVIRONMENTS.each do |environment|
|
387
563
|
unless environment == 'production'
|
388
564
|
inject_into_file "config/environments/#{environment}.rb", after: "Rails.application.configure do\n" do <<-CODE
|
@@ -397,31 +573,27 @@ CODE
|
|
397
573
|
option :name, required: true
|
398
574
|
def config_env
|
399
575
|
ENVIRONMENTS.each do |environment|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
CODE
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
CODE
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
config.action_controller.default_url_options = { host: '' }
|
422
|
-
config.assets.compile = true
|
423
|
-
CODE
|
424
|
-
end
|
576
|
+
case environment
|
577
|
+
when 'development'
|
578
|
+
inject_into_file 'config/environments/development.rb', after: "config.action_mailer.raise_delivery_errors = false\n" do <<-CODE
|
579
|
+
config.action_mailer.delivery_method = :letter_opener
|
580
|
+
config.action_mailer.perform_deliveries = false
|
581
|
+
config.action_mailer.default_url_options = { host: ENV['DEFAULT_HOST'] }
|
582
|
+
config.action_controller.default_url_options = { host: ENV['DEFAULT_HOST'] }
|
583
|
+
CODE
|
584
|
+
end
|
585
|
+
when 'test'
|
586
|
+
inject_into_file 'config/environments/test.rb', after: "config.action_mailer.delivery_method = :test\n" do <<-CODE
|
587
|
+
config.action_mailer.default_url_options = { host: ENV['DEFAULT_HOST'] }
|
588
|
+
config.action_controller.default_url_options = { host: ENV['DEFAULT_HOST'] }
|
589
|
+
CODE
|
590
|
+
end
|
591
|
+
when 'production'
|
592
|
+
inject_into_file 'config/environments/production.rb', after: "config.active_record.dump_schema_after_migration = false\n" do <<-CODE
|
593
|
+
config.action_mailer.default_url_options = { host: ENV['DEFAULT_HOST'] }
|
594
|
+
config.action_controller.default_url_options = { host: ENV['DEFAULT_HOST'] }
|
595
|
+
config.assets.compile = true
|
596
|
+
CODE
|
425
597
|
end
|
426
598
|
end
|
427
599
|
end
|
@@ -446,7 +618,7 @@ CODE
|
|
446
618
|
run "rails plugin new #{options[:name]} --dummy-path=spec/dummy --skip-test-unit --#{etype}"
|
447
619
|
end
|
448
620
|
|
449
|
-
desc 'engine_setup', 'Configure rails engine for development with RSpec, Capybara and
|
621
|
+
desc 'engine_setup', 'Configure rails engine for development with RSpec, Capybara and FactoryBot'
|
450
622
|
option :name, required: true
|
451
623
|
def engine_setup
|
452
624
|
gsub_file "#{options[:name]}.gemspec", 's.homepage = "TODO"', 's.homepage = "http://TBD.com"'
|
@@ -463,7 +635,7 @@ CODE
|
|
463
635
|
inject_into_file "#{options[:name]}.gemspec", after: "s.add_development_dependency \"sqlite3\"\n" do <<-CODE
|
464
636
|
s.add_development_dependency 'rspec-rails'
|
465
637
|
s.add_development_dependency 'capybara'
|
466
|
-
s.add_development_dependency '
|
638
|
+
s.add_development_dependency 'factory_bot_rails'
|
467
639
|
s.add_development_dependency "faker"
|
468
640
|
s.add_development_dependency "byebug"
|
469
641
|
s.add_development_dependency 'rails-controller-testing'
|
@@ -481,11 +653,15 @@ CODE
|
|
481
653
|
end
|
482
654
|
|
483
655
|
run 'bundle'
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
656
|
+
|
657
|
+
Dir["#{__dir__}/myrails/templates/spec/**/*"].each do |file|
|
658
|
+
if file.include? '/support/'
|
659
|
+
copy_file file, "#{file.gsub(__dir__+'/myrails/templates/', '')}" unless File.directory? file
|
660
|
+
end
|
661
|
+
end
|
662
|
+
|
488
663
|
copy_file 'engines/rakefile', 'Rakefile'
|
664
|
+
|
489
665
|
run 'rails g rspec:install'
|
490
666
|
|
491
667
|
gsub_file 'spec/rails_helper.rb', "# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }", "Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f }"
|
@@ -494,7 +670,7 @@ CODE
|
|
494
670
|
|
495
671
|
inject_into_file 'spec/rails_helper.rb', after: "require 'rspec/rails'\n" do <<-CODE
|
496
672
|
require 'shoulda/matchers'
|
497
|
-
require '
|
673
|
+
require 'factory_bot'
|
498
674
|
require 'database_cleaner'
|
499
675
|
CODE
|
500
676
|
end
|
@@ -509,7 +685,7 @@ require 'database_cleaner'
|
|
509
685
|
inject_into_file "lib/#{options[:name]}/engine.rb", after: "class Engine < ::Rails::Engine\n" do <<-CODE
|
510
686
|
config.generators do |g|
|
511
687
|
g.test_framework :rspec, :fixture => false
|
512
|
-
g.fixture_replacement :
|
688
|
+
g.fixture_replacement :factory_bot, :dir => 'spec/factories'
|
513
689
|
g.assets false
|
514
690
|
g.helper false
|
515
691
|
end
|
@@ -520,25 +696,46 @@ require 'database_cleaner'
|
|
520
696
|
desc 'shared_example', 'Generates an RSpec shared example template in the support directory'
|
521
697
|
option :text, required: true
|
522
698
|
def shared_example
|
523
|
-
template '
|
699
|
+
template 'spec/shared_example.rb', 'spec/support/shared_examples/shared_examples.rb'
|
524
700
|
end
|
525
701
|
|
526
702
|
desc 'request', 'Generates an RSpec request spec'
|
527
703
|
option :name, required: true
|
528
704
|
def request
|
529
|
-
template '
|
530
|
-
copy_file '
|
705
|
+
template 'spec/request.rb', "spec/requests/#{options[:name]}_spec.rb"
|
706
|
+
copy_file 'spec/request_shared_example.rb', 'spec/support/shared_examples/request_shared_examples.rb'
|
531
707
|
end
|
532
708
|
|
533
|
-
desc '
|
709
|
+
desc 'feature', 'Generates an RSpec feature spec'
|
710
|
+
option :name, required: true
|
711
|
+
def feature
|
712
|
+
copy_file 'spec/feature.rb', "spec/features/#{options[:name]}_spec.rb"
|
713
|
+
end
|
714
|
+
|
715
|
+
desc 'helper', 'Generates an RSpec helper in support/helpers for extracting reusable code'
|
716
|
+
long_desc <<-LONGDESC
|
717
|
+
`myrails helper` will generate an RSpec helper module to use with rspec.
|
718
|
+
|
719
|
+
You can optionally specify a type parameter which will only include the module for the given type of spec.
|
720
|
+
|
721
|
+
> $ myrails helper --name article --type :feature
|
722
|
+
LONGDESC
|
723
|
+
option :name, required: true
|
724
|
+
option :type
|
725
|
+
def helper
|
726
|
+
template 'spec/helper.rb', "spec/support/helpers/#{options[:name].downcase.gsub("\s", '_')}.rb"
|
727
|
+
insert_into_file 'spec/rails_helper.rb', after: "RSpec.configure do |config|\n" do <<-CODE
|
728
|
+
config.include #{options[:name].camelize.gsub("\s", '')}Helper#{", type: #{options[:type]}" if options[:type]}
|
729
|
+
CODE
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
desc 'install NAME', 'Install customizations to convfigure application quickly. Type `myrails install` for options'
|
534
734
|
def install(name=nil)
|
535
735
|
options = {
|
536
736
|
application_helper: 'Overwrite default application helper with a custom helper',
|
537
737
|
gems: 'Install default gem set',
|
538
|
-
|
539
|
-
layout: 'Generate custom layout',
|
540
|
-
styles: 'Generate custom styles',
|
541
|
-
footer: 'Generate a footer',
|
738
|
+
layout: 'Generate assets and custom styles using either Boostrap or Material',
|
542
739
|
ui: 'Generate UI resource',
|
543
740
|
pundit: 'Install and configure Pundit gem',
|
544
741
|
rspec: 'Install and configure Rspec gem',
|
@@ -547,7 +744,10 @@ require 'database_cleaner'
|
|
547
744
|
git: 'Generate git directory and ignore default files',
|
548
745
|
heroku: 'Generate needed setup for Heroku deployment',
|
549
746
|
devise: 'Generate and configure Devise gem',
|
550
|
-
dotenv: 'Generate and configure Dotenv gem'
|
747
|
+
dotenv: 'Generate and configure Dotenv gem (Do not use if figaro is already installed)',
|
748
|
+
capistrano: 'Generate capistrano with default deployment',
|
749
|
+
figaro: 'Generate and configure Figaro Gem (Do not use if dotenv is already installed)',
|
750
|
+
env_config: 'Configure environment files with default hosts etc.'
|
551
751
|
}
|
552
752
|
unless name
|
553
753
|
say 'ERROR: "myrails install" was called with no arguments'
|
@@ -562,17 +762,10 @@ require 'database_cleaner'
|
|
562
762
|
install_application_helper
|
563
763
|
when 'gems'
|
564
764
|
install_gems
|
565
|
-
when 'assets'
|
566
|
-
install_assets
|
567
765
|
when 'layout'
|
568
766
|
install_layout
|
569
|
-
when 'styles'
|
570
|
-
install_css
|
571
|
-
when 'footer'
|
572
|
-
install_footer
|
573
767
|
when 'ui'
|
574
768
|
install_ui
|
575
|
-
say 'Dont forget to run config_env'
|
576
769
|
when 'pundit'
|
577
770
|
install_pundit
|
578
771
|
install_rails_helper
|
@@ -590,6 +783,12 @@ require 'database_cleaner'
|
|
590
783
|
install_devise
|
591
784
|
when 'dotenv'
|
592
785
|
install_dotenv
|
786
|
+
when 'capistrano'
|
787
|
+
install_capistrano
|
788
|
+
when 'figaro'
|
789
|
+
install_figaro
|
790
|
+
when 'env_config'
|
791
|
+
config_env
|
593
792
|
else
|
594
793
|
say "Unknown Action!"
|
595
794
|
end
|