onotole 1.0.8 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddc9c847f5351269fde4990a5bed9e0ff6cd4623
4
- data.tar.gz: dbf35516b4a9c84e8e6245a3b17f1acedc8c877b
3
+ metadata.gz: 7dc7303b50ac44931dbea07f86282518630ef33f
4
+ data.tar.gz: e5d5ee1620a68e5ae1eb71d01aa58274b61f5287
5
5
  SHA512:
6
- metadata.gz: bc9b27921b0794e2b0eafc0d9cec8174d9e149a222bff409ee79206cc4b34a59f979994a9b89a454e6cb70fa1d7b5daeafb84bbaf35fcd159d7b7b7c4bbcd37e
7
- data.tar.gz: 2c47b3194d7b4084cdcfadc0904ad7616812ea7eeb41398ab7dc0f648d278518b903faff31934d759719e8a89f53782ee749ed5e4e54581b08fadf586e3df38d
6
+ metadata.gz: 6b90e76edfd53882e6454ac49a0d47f3005ab2469bfb5b6ada03c1618eeb14b6d41ba5fade3e2344d86b14abfe3883403b0f9bafe073190049ce5eb960a5affa
7
+ data.tar.gz: 652bece2dadbc02b748bb8b9cddcae02e5cc053580f3c3c2178d1f9bc5300b7fc53370cbd0e41d9ad345d9b5413e1741ec43aabd6b0949529ee33ddc9fc00656
data/.rubocop.yml CHANGED
@@ -40,8 +40,7 @@ AllCops:
40
40
  Exclude:
41
41
  - 'bin/**/*'
42
42
  - 'vendor/**/*'
43
- - 'log/**/*'
44
- - 'tmp/**/*'
43
+ - 'log/**/*'
45
44
  TargetRubyVersion: 2.3
46
45
  Metrics/AbcSize:
47
46
  Max: 30
data/README.md CHANGED
@@ -73,6 +73,10 @@ pack will not be installed with any gem option.
73
73
  provides an easy-to-use interface for managing your data
74
74
  * [activeadmin](https://github.com/activeadmin/activeadmin) Rails framework for
75
75
  creating elegant backends for website administration.
76
+ * [ActiveAdminImport](https://github.com/activeadmin-plugins/active_admin_import)
77
+ Based on ActiveRecord-import gem - the most efficient way to import for ActiveAdmin
78
+ * [ActiveAdminTheme](https://github.com/activeadmin-plugins/active_admin_theme)
79
+ Flat skin for ActiveAdmin
76
80
  * `*`[rubycritic](https://github.com/whitesmith/rubycritic) A Ruby code quality
77
81
  reporter
78
82
  * [railroady](https://github.com/preston/railroady) Model and controller UML
data/bin/install CHANGED
@@ -1,2 +1,5 @@
1
1
  #!/bin/sh
2
- rm onotole-*.gem && gem build onotole.gemspec && gem install onotole
2
+ rm onotole-*.gem
3
+ rm -fr tmp/
4
+ git add .
5
+ gem build onotole.gemspec && gem install onotole
@@ -13,6 +13,7 @@ module Onotole
13
13
  :guard_rubocop,
14
14
  :bootstrap3_sass,
15
15
  :bootstrap3,
16
+ :active_admin_theme,
16
17
  :normalize,
17
18
  :tinymce,
18
19
  :rubocop,
@@ -135,9 +136,14 @@ end
135
136
  end
136
137
 
137
138
  def after_install_typus
138
- rails_generator 'typus'
139
- rails_generator 'typus:migration'
140
- rails_generator 'typus:views'
139
+ rails_generator 'typus'
140
+ rails_generator 'typus:migration'
141
+ rails_generator 'typus:views'
142
+ end
143
+
144
+ def after_install_active_admin_theme
145
+ append_file('app/assets/stylesheets/active_admin.scss',
146
+ "\n@import 'wigu/active_admin_theme';")
141
147
  end
142
148
  end
143
149
  end
@@ -5,13 +5,6 @@ module Onotole
5
5
  add_to_user_choise(:normalize)
6
6
  end
7
7
 
8
- def add_user_gems
9
- GEMPROCLIST.each do |g|
10
- send "add_#{g}_gem" if user_choose? g.to_sym
11
- end
12
- # add_foo_bar_gem if user_choose?(:foo) && user_choose?(:bar)
13
- end
14
-
15
8
  def add_haml_gem
16
9
  inject_into_file('Gemfile', "\ngem 'haml-rails'", after: '# user_choice')
17
10
  end
@@ -119,14 +112,6 @@ module Onotole
119
112
  copy_file 'devise_rspec.rb', 'spec/support/devise.rb'
120
113
  end
121
114
 
122
- def add_will_paginate_gem
123
- inject_into_file('Gemfile', "\ngem 'will_paginate', '~> 3.0.6'",
124
- after: '# user_choice')
125
- inject_into_file('Gemfile', "\ngem 'will_paginate-bootstrap'",
126
- after: '# user_choice') if user_choose?(:bootstrap3) ||
127
- user_choose?(:bootstrap3_sass)
128
- end
129
-
130
115
  def add_responders_gem
131
116
  inject_into_file('Gemfile', "\ngem 'responders'", after: '# user_choice')
132
117
  end
@@ -180,7 +165,6 @@ module Onotole
180
165
 
181
166
  def add_rails_admin_gem
182
167
  inject_into_file('Gemfile', "\ngem 'rails_admin'", after: '# user_choice')
183
- puts
184
168
  end
185
169
 
186
170
  def add_rubycritic_gem
@@ -189,12 +173,35 @@ module Onotole
189
173
  end
190
174
 
191
175
  def add_railroady_gem
192
- inject_into_file('Gemfile', "\n gem 'railroady', :require => false",
193
- after: 'group :development do')
176
+ inject_into_file('Gemfile', "\n gem 'railroady'", after: 'group :development do')
194
177
  end
195
178
 
196
179
  def add_typus_gem
197
180
  inject_into_file('Gemfile', "\n gem 'typus', github: 'typus/typus'", after: '# user_choice')
198
181
  end
182
+
183
+ def add_will_paginate_gem
184
+ inject_into_file('Gemfile', "\ngem 'will_paginate', '~> 3.0.6'",
185
+ after: '# user_choice')
186
+ inject_into_file('Gemfile', "\ngem 'will_paginate-bootstrap'",
187
+ after: '# user_choice') if user_choose?(:bootstrap3) ||
188
+ user_choose?(:bootstrap3_sass)
189
+ end
190
+
191
+ def add_kaminari_gem
192
+ inject_into_file('Gemfile', "\ngem 'kaminari'", after: '# user_choice')
193
+ copy_file 'kaminari.rb', 'config/initializers/kaminari.rb'
194
+ inject_into_file('Gemfile', "\ngem 'bootstrap-kaminari-views'",
195
+ after: '# user_choice') if user_choose?(:bootstrap3) ||
196
+ user_choose?(:bootstrap3_sass)
197
+ end
198
+
199
+ def add_active_admin_import_gem
200
+ inject_into_file('Gemfile', "\ngem 'active_admin_import'", after: '# user_choice')
201
+ end
202
+
203
+ def add_active_admin_theme_gem
204
+ inject_into_file('Gemfile', "\ngem 'active_admin_theme'", after: '# user_choice')
205
+ end
199
206
  end
200
207
  end
@@ -29,18 +29,39 @@ module Onotole
29
29
 
30
30
  def choose_cms_engine
31
31
  variants = { none: 'None',
32
- activeadmin: 'Activeadmin CMS',
32
+ activeadmin: 'Activeadmin CMS (if devise selected Admin model will create automatic)',
33
33
  rails_admin: 'Rails admin CMS',
34
34
  rails_db: 'Rails DB. Simple pretty view in browser & xls export for models',
35
35
  typus: 'Typus control panel to allow trusted users edit structured content.' }
36
36
  gem = choice 'Select control panel or CMS: ', variants
37
37
  add_to_user_choise(gem) if gem
38
- puts gem
38
+ show_active_admin_plugins_submenu
39
+ end
40
+
41
+ def show_active_admin_plugins_submenu
42
+ return unless user_choose? :activeadmin
43
+ variants = { none: 'None',
44
+ active_admin_import: 'Active_admin_import - the most efficient way to import for ActiveAdmin',
45
+ active_admin_theme: 'Active_admin_theme - flat skin for activeadmin' }
46
+ multiple_choice('Select activeadmin plug-ins.', variants).each do |gem|
47
+ add_to_user_choise gem
48
+ end
49
+ end
50
+
51
+ def choose_pagimation
52
+ if user_choose? :activeadmin
53
+ add_to_user_choise(:kaminari)
54
+ return
55
+ end
56
+ variants = { none: 'None',
57
+ will_paginate: 'Will paginate',
58
+ kaminari: 'Kaminari' }
59
+ gem = choice 'Select paginator: ', variants
60
+ add_to_user_choise(gem) if gem
39
61
  end
40
62
 
41
63
  def choose_undroup_gems
42
64
  variants = { none: 'None',
43
- will_paginate: 'Easy pagination implement',
44
65
  faker: 'Gem for generate fake data in testing',
45
66
  rubocop: 'Code inspector and code formatting tool',
46
67
  rubycritic: 'A Ruby code quality reporter',
@@ -81,12 +102,11 @@ module Onotole
81
102
  end
82
103
 
83
104
  def ask_cleanup_commens
84
- unless options[:clean_comments]
105
+ return if options[:clean_comments]
85
106
  variants = { none: 'No', clean_comments: 'Yes' }
86
107
  sel = choice 'Delete comments in Gemfile, routes.rb & config files? ',
87
108
  variants
88
109
  add_to_user_choise(sel) unless sel == :none
89
- end
90
110
  end
91
111
 
92
112
  def add_github_repo_creation_choice
@@ -2,10 +2,11 @@
2
2
  module Onotole
3
3
  module UserGemsMenu
4
4
  def users_gems
5
- choose_authenticate_engine
5
+ choose_cms_engine
6
6
  choose_template_engine
7
7
  choose_frontend
8
- choose_cms_engine
8
+ choose_authenticate_engine
9
+ choose_pagimation
9
10
  # Placeholder for other gem additions
10
11
  # menu description in add_gems_in_menu.rb
11
12
 
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  require 'forwardable'
3
3
  # require 'pry'
4
- Dir['lib/onotole/**/*.rb'].each { |file| require file.slice(4..-4) }
4
+ Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), '../')) + '/**/*.rb'].each do |file|
5
+ require file
6
+ end
5
7
 
6
8
  module Onotole
7
9
  class AppBuilder < Rails::AppBuilder
@@ -15,7 +17,9 @@ module Onotole
15
17
  include Onotole::Tests
16
18
  include Onotole::Mail
17
19
  include Onotole::Goodbye
18
- include Onotole::FrontendDefault
20
+ include Onotole::DefaultFrontend
21
+ include Onotole::DefalutScripts
22
+ include Onotole::Deploy
19
23
  extend Forwardable
20
24
 
21
25
  @use_asset_pipelline = true
@@ -23,11 +27,13 @@ module Onotole
23
27
  @app_file_scss = 'app/assets/stylesheets/application.scss'
24
28
  @app_file_css = 'app/assets/stylesheets/application.css'
25
29
  @js_file = 'app/assets/javascripts/application.js'
30
+ @quiet = true
26
31
 
27
32
  class << self
28
33
  attr_accessor :use_asset_pipelline,
29
34
  :devise_model,
30
- :user_choice, :app_file_scss, :app_file_css, :js_file
35
+ :user_choice, :app_file_scss,
36
+ :app_file_css, :js_file, :quiet
31
37
  end
32
38
 
33
39
  def_delegators :heroku_adapter,
@@ -41,10 +47,6 @@ module Onotole
41
47
  :set_heroku_serve_static_files,
42
48
  :set_up_heroku_specific_gems
43
49
 
44
- def readme
45
- template 'README.md.erb', 'README.md'
46
- end
47
-
48
50
  def add_bullet_gem_configuration
49
51
  config = <<-RUBY
50
52
  config.after_initialize do
@@ -62,20 +64,6 @@ module Onotole
62
64
  )
63
65
  end
64
66
 
65
- def raise_on_unpermitted_parameters
66
- config = "\n config.action_controller.action_on_unpermitted_parameters = :raise\n"
67
- inject_into_class 'config/application.rb', 'Application', config
68
- end
69
-
70
- def provide_setup_script
71
- template 'bin_setup', 'bin/setup', force: true
72
- run 'chmod a+x bin/setup'
73
- end
74
-
75
- def provide_dev_prime_task
76
- copy_file 'dev.rake', 'lib/tasks/dev.rake'
77
- end
78
-
79
67
  def set_up_hound
80
68
  copy_file 'hound.yml', '.hound.yml'
81
69
  end
@@ -84,112 +72,15 @@ module Onotole
84
72
  template 'newrelic.yml.erb', 'config/newrelic.yml'
85
73
  end
86
74
 
87
- def enable_rack_canonical_host
88
- config = <<-RUBY
89
-
90
- if ENV.fetch("HEROKU_APP_NAME", "").include?("staging-pr-")
91
- ENV["APPLICATION_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
92
- end
93
-
94
- # Ensure requests are only served from one, canonical host name
95
- config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")
96
- RUBY
97
-
98
- inject_into_file(
99
- 'config/environments/production.rb',
100
- config,
101
- after: 'Rails.application.configure do'
102
- )
103
- end
104
-
105
- def enable_rack_deflater
106
- config = <<-RUBY
107
-
108
- # Enable deflate / gzip compression of controller-generated responses
109
- config.middleware.use Rack::Deflater
110
- RUBY
111
-
112
- inject_into_file(
113
- 'config/environments/production.rb',
114
- config,
115
- after: serve_static_files_line
116
- )
117
- end
118
-
119
- def setup_staging_environment
120
- staging_file = 'config/environments/staging.rb'
121
- copy_file 'staging.rb', staging_file
122
-
123
- config = <<-RUBY
124
-
125
- Rails.application.configure do
126
- # ...
127
- end
128
- RUBY
129
-
130
- append_file staging_file, config
131
- end
132
-
133
- def setup_secret_token
134
- template 'secrets.yml', 'config/secrets.yml', force: true
135
- end
136
-
137
- def disallow_wrapping_parameters
138
- remove_file 'config/initializers/wrap_parameters.rb'
139
- end
140
-
141
- def create_shared_javascripts
142
- copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
143
- end
144
-
145
- def use_postgres_config_template
146
- template 'postgresql_database.yml.erb', 'config/database.yml',
147
- force: true
148
- template 'postgresql_database.yml.erb', 'config/database.yml.sample',
149
- force: true
150
- end
151
-
152
- def create_database
153
- bundle_command 'exec rake db:drop db:create db:migrate db:seed'
154
- end
155
-
156
- def replace_gemfile
157
- remove_file 'Gemfile'
158
- template 'Gemfile.erb', 'Gemfile'
159
- end
160
-
161
- def set_ruby_to_version_being_used
162
- create_file '.ruby-version', "#{Onotole::RUBY_VERSION}\n"
163
- end
164
-
165
75
  def configure_ci
166
76
  template 'circle.yml.erb', 'circle.yml'
167
77
  end
168
78
 
169
- def configure_i18n_for_missing_translations
170
- raise_on_missing_translations_in('development')
171
- raise_on_missing_translations_in('test')
172
- end
173
-
174
- def configure_background_jobs_for_rspec
175
- rails_generator 'delayed_job:active_record'
176
- end
177
-
178
- def configure_time_formats
179
- remove_file 'config/locales/en.yml'
180
- template 'config_locales_en.yml.erb', 'config/locales/en.yml'
181
- end
182
-
183
- def configure_rack_timeout
184
- rack_timeout_config = 'Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i'
185
- append_file 'config/environments/production.rb', rack_timeout_config
186
- end
187
-
188
79
  def configure_simple_form
189
80
  if user_choose?(:bootstrap3_sass) || user_choose?(:bootstrap3)
190
- rails_generator 'simple_form:install --bootstrap'
81
+ rails_generator "simple_form:install --bootstrap"
191
82
  else
192
- rails_generator 'simple_form:install'
83
+ rails_generator "simple_form:install"
193
84
  end
194
85
  end
195
86
 
@@ -200,116 +91,10 @@ end
200
91
  configure_environment 'test', 'config.active_job.queue_adapter = :inline'
201
92
  end
202
93
 
203
- def fix_i18n_deprecation_warning
204
- config = ' config.i18n.enforce_available_locales = true'
205
- inject_into_class 'config/application.rb', 'Application', config
206
- end
207
-
208
94
  def configure_puma
209
95
  copy_file 'puma.rb', 'config/puma.rb'
210
96
  end
211
97
 
212
- def set_up_forego
213
- copy_file 'Procfile', 'Procfile'
214
- end
215
-
216
- def install_refills
217
- rails_generator 'refills:import flashes'
218
- run 'rm app/views/refills/_flashes.html.erb'
219
- run 'rmdir app/views/refills'
220
- end
221
-
222
- def copy_dotfiles
223
- directory 'dotfiles', '.', force: true
224
- end
225
-
226
- def create_heroku_apps(flags)
227
- create_staging_heroku_app(flags)
228
- create_production_heroku_app(flags)
229
- end
230
-
231
- def provide_deploy_script
232
- copy_file 'bin_deploy', 'bin/deploy'
233
-
234
- instructions = <<-MARKDOWN
235
-
236
- ## Deploying
237
-
238
- If you have previously run the `./bin/setup` script,
239
- you can deploy to staging and production with:
240
-
241
- $ ./bin/deploy staging
242
- $ ./bin/deploy production
243
- MARKDOWN
244
-
245
- append_file 'README.md', instructions
246
- run 'chmod a+x bin/deploy'
247
- end
248
-
249
- def configure_automatic_deployment
250
- deploy_command = <<-YML.strip_heredoc
251
- deployment:
252
- staging:
253
- branch: master
254
- commands:
255
- - bin/deploy staging
256
- YML
257
-
258
- append_file 'circle.yml', deploy_command
259
- end
260
-
261
- def setup_spring
262
- bundle_command 'exec spring binstub --all'
263
- bundle_command 'exec spring stop'
264
- end
265
-
266
- def copy_miscellaneous_files
267
- copy_file 'browserslist', 'browserslist'
268
- copy_file 'errors.rb', 'config/initializers/errors.rb'
269
- copy_file 'json_encoding.rb', 'config/initializers/json_encoding.rb'
270
- end
271
-
272
- def remove_config_comment_lines
273
- config_files = [
274
- 'application.rb',
275
- 'environment.rb',
276
- 'environments/development.rb',
277
- 'environments/production.rb',
278
- 'environments/test.rb'
279
- ]
280
-
281
- config_files.each do |config_file|
282
- cleanup_comments File.join(destination_root, "config/#{config_file}")
283
- end
284
- end
285
-
286
- def remove_routes_comment_lines
287
- replace_in_file 'config/routes.rb',
288
- /Rails\.application\.routes\.draw do.*end/m,
289
- "Rails.application.routes.draw do\nend"
290
- end
291
-
292
- def disable_xml_params
293
- copy_file 'disable_xml_params.rb',
294
- 'config/initializers/disable_xml_params.rb'
295
- end
296
-
297
- def setup_default_rake_task
298
- append_file 'Rakefile' do
299
- <<-EOS
300
- task(:default).clear
301
- task default: [:spec]
302
-
303
- if defined? RSpec
304
- task(:spec).clear
305
- RSpec::Core::RakeTask.new(:spec) do |t|
306
- t.verbose = false
307
- end
308
- end
309
- EOS
310
- end
311
- end
312
-
313
98
  # def rvm_bundler_stubs_install
314
99
  # if system "rvm -v | grep 'rvm.io'"
315
100
  # run 'chmod +x $rvm_path/hooks/after_cd_bundler'
@@ -317,18 +102,6 @@ end
317
102
  # end
318
103
  # end
319
104
 
320
- def user_gems_from_args_or_default_set
321
- gems_flags = []
322
- options.each { |gem, usage| gems_flags.push(gem.to_sym) if usage }
323
- gems = GEMPROCLIST & gems_flags
324
- if gems.empty?
325
- AppBuilder.user_choice = DEFAULT_GEMSET
326
- else
327
- gems.each { |gem| AppBuilder.user_choice << gem }
328
- end
329
- add_user_gems
330
- end
331
-
332
105
  def delete_comments
333
106
  return unless options[:clean_comments] || user_choose?(:clean_comments)
334
107
  cleanup_comments 'Gemfile'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Onotole
3
- module FrontendDefault
3
+ module DefaultFrontend
4
4
  def configure_quiet_assets
5
5
  config = "\n config.quiet_assets = true\n"
6
6
  inject_into_class 'config/application.rb', 'Application', config
@@ -64,5 +64,15 @@ module Onotole
64
64
  def create_partials_directory
65
65
  empty_directory 'app/views/application'
66
66
  end
67
+
68
+ def install_refills
69
+ rails_generator 'refills:import flashes'
70
+ run 'rm app/views/refills/_flashes.html.erb'
71
+ run 'rmdir app/views/refills'
72
+ end
73
+
74
+ def create_shared_javascripts
75
+ copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
76
+ end
67
77
  end
68
78
  end
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+ module Onotole
3
+ module DefalutScripts
4
+ def raise_on_unpermitted_parameters
5
+ config = "\n config.action_controller.action_on_unpermitted_parameters = :raise\n"
6
+ inject_into_class 'config/application.rb', 'Application', config
7
+ end
8
+
9
+ def provide_setup_script
10
+ template 'bin_setup', 'bin/setup', force: true
11
+ run 'chmod a+x bin/setup'
12
+ end
13
+
14
+ def provide_dev_prime_task
15
+ copy_file 'dev.rake', 'lib/tasks/dev.rake'
16
+ end
17
+
18
+ def enable_rack_deflater
19
+ config = <<-RUBY
20
+
21
+ # Enable deflate / gzip compression of controller-generated responses
22
+ config.middleware.use Rack::Deflater
23
+ RUBY
24
+
25
+ inject_into_file(
26
+ 'config/environments/production.rb',
27
+ config,
28
+ after: serve_static_files_line
29
+ )
30
+ end
31
+
32
+ def set_up_forego
33
+ copy_file 'Procfile', 'Procfile'
34
+ end
35
+
36
+ def setup_staging_environment
37
+ staging_file = 'config/environments/staging.rb'
38
+ copy_file 'staging.rb', staging_file
39
+
40
+ config = <<-RUBY
41
+
42
+ Rails.application.configure do
43
+ # ...
44
+ end
45
+ RUBY
46
+
47
+ append_file staging_file, config
48
+ end
49
+
50
+ def setup_secret_token
51
+ template 'secrets.yml', 'config/secrets.yml', force: true
52
+ end
53
+
54
+ def disallow_wrapping_parameters
55
+ remove_file 'config/initializers/wrap_parameters.rb'
56
+ end
57
+
58
+ def use_postgres_config_template
59
+ template 'postgresql_database.yml.erb', 'config/database.yml',
60
+ force: true
61
+ template 'postgresql_database.yml.erb', 'config/database.yml.sample',
62
+ force: true
63
+ end
64
+
65
+ def create_database
66
+ bundle_command 'exec rake db:drop db:create db:migrate db:seed'
67
+ end
68
+
69
+ def replace_gemfile
70
+ remove_file 'Gemfile'
71
+ template 'Gemfile.erb', 'Gemfile'
72
+ end
73
+
74
+ def set_ruby_to_version_being_used
75
+ create_file '.ruby-version', "#{Onotole::RUBY_VERSION}\n"
76
+ end
77
+
78
+ def configure_background_jobs_for_rspec
79
+ rails_generator 'delayed_job:active_record'
80
+ end
81
+
82
+ def configure_time_formats
83
+ remove_file 'config/locales/en.yml'
84
+ template 'config_locales_en.yml.erb', 'config/locales/en.yml'
85
+ end
86
+
87
+ def configure_i18n_for_missing_translations
88
+ raise_on_missing_translations_in('development')
89
+ raise_on_missing_translations_in('test')
90
+ end
91
+
92
+ def configure_rack_timeout
93
+ rack_timeout_config = 'Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i'
94
+ append_file 'config/environments/production.rb', rack_timeout_config
95
+ end
96
+
97
+ def fix_i18n_deprecation_warning
98
+ config = ' config.i18n.enforce_available_locales = true'
99
+ inject_into_class 'config/application.rb', 'Application', config
100
+ end
101
+
102
+ def copy_dotfiles
103
+ directory 'dotfiles', '.', force: true
104
+ end
105
+
106
+ def setup_spring
107
+ bundle_command 'exec spring binstub --all'
108
+ bundle_command 'exec spring stop'
109
+ end
110
+
111
+ def remove_config_comment_lines
112
+ config_files = [
113
+ 'application.rb',
114
+ 'environment.rb',
115
+ 'environments/development.rb',
116
+ 'environments/production.rb',
117
+ 'environments/test.rb'
118
+ ]
119
+
120
+ config_files.each do |config_file|
121
+ cleanup_comments File.join(destination_root, "config/#{config_file}")
122
+ end
123
+ end
124
+
125
+ def remove_routes_comment_lines
126
+ replace_in_file 'config/routes.rb',
127
+ /Rails\.application\.routes\.draw do.*end/m,
128
+ "Rails.application.routes.draw do\nend"
129
+ end
130
+
131
+ def disable_xml_params
132
+ copy_file 'disable_xml_params.rb',
133
+ 'config/initializers/disable_xml_params.rb'
134
+ end
135
+
136
+ def setup_default_rake_task
137
+ append_file 'Rakefile' do
138
+ <<-EOS
139
+ task(:default).clear
140
+ task default: [:spec]
141
+
142
+ if defined? RSpec
143
+ task(:spec).clear
144
+ RSpec::Core::RakeTask.new(:spec) do |t|
145
+ t.verbose = false
146
+ end
147
+ end
148
+ EOS
149
+ end
150
+ end
151
+
152
+ def copy_miscellaneous_files
153
+ copy_file 'browserslist', 'browserslist'
154
+ copy_file 'errors.rb', 'config/initializers/errors.rb'
155
+ copy_file 'json_encoding.rb', 'config/initializers/json_encoding.rb'
156
+ end
157
+
158
+ def enable_rack_canonical_host
159
+ config = <<-RUBY
160
+
161
+ if ENV.fetch("HEROKU_APP_NAME", "").include?("staging-pr-")
162
+ ENV["APPLICATION_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
163
+ end
164
+
165
+ # Ensure requests are only served from one, canonical host name
166
+ config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")
167
+ RUBY
168
+
169
+ inject_into_file(
170
+ 'config/environments/production.rb',
171
+ config,
172
+ after: 'Rails.application.configure do'
173
+ )
174
+ end
175
+
176
+ def readme
177
+ template 'README.md.erb', 'README.md'
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ module Onotole
3
+ module Deploy
4
+ def provide_deploy_script
5
+ copy_file 'bin_deploy', 'bin/deploy'
6
+
7
+ instructions = <<-MARKDOWN
8
+
9
+ ## Deploying
10
+
11
+ If you have previously run the `./bin/setup` script,
12
+ you can deploy to staging and production with:
13
+
14
+ $ ./bin/deploy staging
15
+ $ ./bin/deploy production
16
+ MARKDOWN
17
+
18
+ append_file 'README.md', instructions
19
+ run 'chmod a+x bin/deploy'
20
+ end
21
+
22
+ def configure_automatic_deployment
23
+ deploy_command = <<-YML.strip_heredoc
24
+ deployment:
25
+ staging:
26
+ branch: master
27
+ commands:
28
+ - bin/deploy staging
29
+ YML
30
+
31
+ append_file 'circle.yml', deploy_command
32
+ end
33
+
34
+ def create_heroku_apps(flags)
35
+ create_staging_heroku_app(flags)
36
+ create_production_heroku_app(flags)
37
+ end
38
+ end
39
+ end
@@ -8,18 +8,20 @@ module Onotole
8
8
  end
9
9
 
10
10
  def choice(selector, variants)
11
- unless variants.keys[1..-1].map { |a| options[a] }.include? true
12
- values = []
13
- say "\n #{BOLDGREEN}#{selector}#{COLOR_OFF}"
14
- variants.each_with_index do |variant, i|
15
- values.push variant[0]
16
- say "#{i.to_s.rjust(5)}. #{BOLDBLUE}#{variant[1]}#{COLOR_OFF}"
17
- end
18
- answer = ask_stylish('Enter choice:') until (0...variants.length)
19
- .map(&:to_s).include? answer
20
- numeric_answer = answer.to_i
21
- numeric_answer == :none ? nil : numeric_answer
11
+ return if variant_in_options? variants
12
+ values = variants.keys
13
+ say "\n #{BOLDGREEN}#{selector}#{COLOR_OFF}"
14
+ variants.each_with_index do |variant, i|
15
+ say "#{i.to_s.rjust(5)}. #{BOLDBLUE}#{variant[1]}#{COLOR_OFF}"
22
16
  end
17
+ numeric_answers = (0...variants.length).map(&:to_s)
18
+ answer = ask_stylish('Enter choice:') until numeric_answers.include? answer
19
+ symbol_answer = values[answer.to_i]
20
+ symbol_answer == :none ? nil : symbol_answer
21
+ end
22
+
23
+ def variant_in_options?(variants)
24
+ variants.keys[1..-1].map { |a| options[a] }.include? true
23
25
  end
24
26
 
25
27
  def multiple_choice(selector, variants)
@@ -113,7 +115,7 @@ module Onotole
113
115
  end
114
116
 
115
117
  def rails_generator(command)
116
- bundle_command "exec rails generate #{command} -f"
118
+ bundle_command "exec rails generate #{command} -f #{quiet_suffix}"
117
119
  end
118
120
 
119
121
  def pgsql_db_exist?(db_name)
@@ -122,7 +124,30 @@ module Onotole
122
124
 
123
125
  def clean_by_rubocop
124
126
  return unless user_choose?(:rubocop)
125
- bundle_command 'exec rubocop --auto-correct'
127
+ bundle_command "exec rubocop --auto-correct #{quiet_suffix}"
128
+ end
129
+
130
+ def quiet_suffix
131
+ AppBuilder.quiet ? ' > /dev/null' : ''
132
+ end
133
+
134
+ def user_gems_from_args_or_default_set
135
+ gems_flags = []
136
+ options.each { |gem, usage| gems_flags.push(gem.to_sym) if usage }
137
+ gems = GEMPROCLIST & gems_flags
138
+ if gems.empty?
139
+ AppBuilder.user_choice = DEFAULT_GEMSET
140
+ else
141
+ gems.each { |gem| AppBuilder.user_choice << gem }
142
+ end
143
+ add_user_gems
144
+ end
145
+
146
+ def add_user_gems
147
+ GEMPROCLIST.each do |g|
148
+ send "add_#{g}_gem" if user_choose? g.to_sym
149
+ end
150
+ # add_foo_bar_gem if user_choose?(:foo) && user_choose?(:bar)
126
151
  end
127
152
  end
128
153
  end
@@ -2,5 +2,5 @@
2
2
  module Onotole
3
3
  RAILS_VERSION = '~> 4.2.0'
4
4
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
5
- VERSION = '1.0.8'
5
+ VERSION = '1.0.10'
6
6
  end
@@ -9,6 +9,7 @@ RSpec.describe 'Heroku' do
9
9
  end
10
10
 
11
11
  it 'suspends a project for Heroku' do
12
+ allow(Onotole::AppBuilder).to receive(:prevent_double_usage)
12
13
  app_name = OnotoleTestHelpers::APP_NAME.dasherize
13
14
 
14
15
  expect(FakeHeroku).to(
@@ -81,6 +82,7 @@ RSpec.describe 'Heroku' do
81
82
  end
82
83
 
83
84
  it 'suspends a project with extra Heroku flags' do
85
+ allow(Onotole::AppBuilder).to receive(:prevent_double_usage)
84
86
  expect(FakeHeroku).to have_created_app_for('staging', '--region eu')
85
87
  expect(FakeHeroku).to have_created_app_for('production', '--region eu')
86
88
  end
@@ -8,7 +8,20 @@ RSpec.describe 'Suspend a new project with default configuration' do
8
8
  run_onotole
9
9
  end
10
10
 
11
+ let(:secrets_file) { IO.read("#{project_path}/config/secrets.yml") }
12
+ let(:staging_file) { IO.read("#{project_path}/config/environments/staging.rb") }
13
+ let(:ruby_version_file) { IO.read("#{project_path}/.ruby-version") }
14
+ let(:secrets_file) { IO.read("#{project_path}/config/secrets.yml") }
15
+ let(:bin_setup_path) { "#{project_path}/bin/setup" }
16
+ let(:newrelic_file) { IO.read("#{project_path}/config/newrelic.yml") }
17
+ let(:application_rb) { IO.read("#{project_path}/config/application.rb") }
18
+ let(:locales_en_file) { IO.read("#{project_path}/config/locales/en.yml") }
19
+ let(:test_rb) { IO.read("#{project_path}/config/environments/test.rb") }
20
+ let(:development_rb) { IO.read("#{project_path}/config/environments/development.rb") }
21
+ let(:dev_env_file) { IO.read("#{project_path}/config/environments/development.rb") }
22
+
11
23
  it 'ensures project specs pass' do
24
+ allow(Onotole::AppBuilder).to receive(:prevent_double_usage)
12
25
  Dir.chdir(project_path) do
13
26
  Bundler.with_clean_env do
14
27
  expect(`rake`).to include('0 failures')
@@ -17,16 +30,12 @@ RSpec.describe 'Suspend a new project with default configuration' do
17
30
  end
18
31
 
19
32
  it 'inherits staging config from production' do
20
- staging_file = IO.read("#{project_path}/config/environments/staging.rb")
21
33
  config_stub = 'Rails.application.configure do'
22
-
23
34
  expect(staging_file).to match(/^require_relative ("|')production("|')/)
24
35
  expect(staging_file).to match(/#{config_stub}/), staging_file
25
36
  end
26
37
 
27
38
  it 'creates .ruby-version from Onotole .ruby-version' do
28
- ruby_version_file = IO.read("#{project_path}/.ruby-version")
29
-
30
39
  expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
31
40
  end
32
41
 
@@ -37,8 +46,6 @@ RSpec.describe 'Suspend a new project with default configuration' do
37
46
  end
38
47
 
39
48
  it 'loads secret_key_base from env' do
40
- secrets_file = IO.read("#{project_path}/config/secrets.yml")
41
-
42
49
  expect(secrets_file).to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
43
50
  end
44
51
 
@@ -47,8 +54,6 @@ RSpec.describe 'Suspend a new project with default configuration' do
47
54
  end
48
55
 
49
56
  it 'makes bin/setup executable' do
50
- bin_setup_path = "#{project_path}/bin/setup"
51
-
52
57
  expect(File.stat(bin_setup_path)).to be_executable
53
58
  end
54
59
 
@@ -71,11 +76,8 @@ RSpec.describe 'Suspend a new project with default configuration' do
71
76
  # end
72
77
 
73
78
  it 'ensures newrelic.yml reads NewRelic license from env' do
74
- newrelic_file = IO.read("#{project_path}/config/newrelic.yml")
75
-
76
79
  expect(newrelic_file).to match(
77
- /license_key: "<%= ENV\["NEW_RELIC_LICENSE_KEY"\] %>"/
78
- )
80
+ /license_key: "<%= ENV\["NEW_RELIC_LICENSE_KEY"\] %>"/)
79
81
  end
80
82
 
81
83
  it 'records pageviews through Segment if ENV variable set' do
@@ -86,34 +88,23 @@ RSpec.describe 'Suspend a new project with default configuration' do
86
88
  end
87
89
 
88
90
  it 'raises on unpermitted parameters in all environments' do
89
- result = IO.read("#{project_path}/config/application.rb")
90
-
91
- expect(result).to match(
92
- /^\s+config.action_controller.action_on_unpermitted_parameters = :raise/
93
- )
91
+ expect(application_rb).to match(
92
+ /^\s+config.action_controller.action_on_unpermitted_parameters = :raise/)
94
93
  end
95
94
 
96
95
  it 'adds explicit quiet_assets configuration' do
97
- result = IO.read("#{project_path}/config/application.rb")
98
-
99
- expect(result).to match(
100
- /^ +config.quiet_assets = true$/
101
- )
96
+ expect(application_rb).to match(/^ +config.quiet_assets = true$/)
102
97
  end
103
98
 
104
99
  it 'raises on missing translations in development and test' do
105
100
  %w(development test).each do |environment|
106
- environment_file =
107
- IO.read("#{project_path}/config/environments/#{environment}.rb")
101
+ environment_file = IO.read("#{project_path}/config/environments/#{environment}.rb")
108
102
  expect(environment_file).to match(
109
- /^ +config.action_view.raise_on_missing_translations = true$/
110
- )
103
+ /^ +config.action_view.raise_on_missing_translations = true$/)
111
104
  end
112
105
  end
113
106
 
114
107
  it 'evaluates en.yml.erb' do
115
- locales_en_file = IO.read("#{project_path}/config/locales/en.yml")
116
-
117
108
  expect(locales_en_file).to match(/application: #{app_name.humanize}/)
118
109
  end
119
110
 
@@ -122,7 +113,6 @@ RSpec.describe 'Suspend a new project with default configuration' do
122
113
  end
123
114
 
124
115
  it 'configs :test email delivery method for development' do
125
- dev_env_file = IO.read("#{project_path}/config/environments/development.rb")
126
116
  expect(dev_env_file)
127
117
  .to match(/^ +config.action_mailer.delivery_method = :test$/)
128
118
  end
@@ -140,36 +130,24 @@ RSpec.describe 'Suspend a new project with default configuration' do
140
130
  # end
141
131
 
142
132
  it 'configs active job queue adapter' do
143
- application_config = IO.read("#{project_path}/config/application.rb")
144
- test_config = IO.read("#{project_path}/config/environments/test.rb")
145
-
146
- expect(application_config).to match(
147
- /^ +config.active_job.queue_adapter = :delayed_job$/
148
- )
149
- expect(test_config).to match(
150
- /^ +config.active_job.queue_adapter = :inline$/
151
- )
133
+ expect(application_rb).to match(
134
+ /^ +config.active_job.queue_adapter = :delayed_job$/)
135
+ expect(test_rb).to match(
136
+ /^ +config.active_job.queue_adapter = :inline$/)
152
137
  end
153
138
 
154
139
  it 'configs bullet gem in development' do
155
- test_config = IO.read("#{project_path}/config/environments/development.rb")
156
-
157
- expect(test_config).to match /^ +Bullet.enable = true$/
158
- expect(test_config).to match /^ +Bullet.bullet_logger = true$/
159
- expect(test_config).to match /^ +Bullet.rails_logger = true$/
140
+ expect(development_rb).to match /^ +Bullet.enable = true$/
141
+ expect(development_rb).to match /^ +Bullet.bullet_logger = true$/
142
+ expect(development_rb).to match /^ +Bullet.rails_logger = true$/
160
143
  end
161
144
 
162
145
  it 'configs missing assets to raise in test' do
163
- test_config = IO.read("#{project_path}/config/environments/test.rb")
164
-
165
- expect(test_config).to match(
166
- /^ +config.assets.raise_runtime_errors = true$/
167
- )
146
+ expect(test_rb).to match(/^ +config.assets.raise_runtime_errors = true$/)
168
147
  end
169
148
 
170
149
  it 'adds spring to binstubs' do
171
150
  expect(File).to exist("#{project_path}/bin/spring")
172
-
173
151
  bin_stubs = %w(rake rails rspec)
174
152
  bin_stubs.each do |bin_stub|
175
153
  expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ Kaminari.configure do |config|
3
+ config.page_method_name = :per_page_kaminari
4
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onotole
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - kvokka
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-13 00:00:00.000000000 Z
12
+ date: 2016-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -90,7 +90,9 @@ files:
90
90
  - lib/onotole/add_user_gems/user_gems_menu_questions.rb
91
91
  - lib/onotole/app_builder.rb
92
92
  - lib/onotole/colors.rb
93
- - lib/onotole/frontend_default.rb
93
+ - lib/onotole/default_frontend.rb
94
+ - lib/onotole/default_scripts.rb
95
+ - lib/onotole/deploy.rb
94
96
  - lib/onotole/generators/app_generator.rb
95
97
  - lib/onotole/git.rb
96
98
  - lib/onotole/helpers.rb
@@ -140,6 +142,7 @@ files:
140
142
  - templates/hound.yml
141
143
  - templates/i18n.rb
142
144
  - templates/json_encoding.rb
145
+ - templates/kaminari.rb
143
146
  - templates/newrelic.yml.erb
144
147
  - templates/onotole_layout.html.erb.erb
145
148
  - templates/onotole_overcommit.yml