onotole 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -1
  3. data/.rubocop_todo.yml +100 -0
  4. data/Gemfile +1 -0
  5. data/Guardfile +1 -0
  6. data/README.md +11 -3
  7. data/Rakefile +1 -0
  8. data/lib/onotole.rb +1 -0
  9. data/lib/onotole/actions.rb +9 -0
  10. data/lib/onotole/adapters/heroku.rb +1 -0
  11. data/lib/onotole/add_user_gems/after_install_patch.rb +24 -7
  12. data/lib/onotole/add_user_gems/before_bundle_patch.rb +23 -3
  13. data/lib/onotole/add_user_gems/edit_menu_questions.rb +28 -16
  14. data/lib/onotole/add_user_gems/user_gems_menu_questions.rb +2 -0
  15. data/lib/onotole/app_builder.rb +26 -274
  16. data/lib/onotole/generators/app_generator.rb +7 -1
  17. data/lib/onotole/version.rb +1 -1
  18. data/onotole.gemspec +1 -0
  19. data/spec/adapters/heroku_spec.rb +1 -0
  20. data/spec/fakes/bin/heroku +1 -0
  21. data/spec/fakes/bin/hub +1 -0
  22. data/spec/features/github_spec.rb +1 -0
  23. data/spec/features/heroku_spec.rb +1 -0
  24. data/spec/features/new_project_spec.rb +1 -0
  25. data/spec/spec_helper.rb +1 -0
  26. data/spec/support/fake_github.rb +1 -0
  27. data/spec/support/fake_heroku.rb +1 -0
  28. data/templates/Gemfile.erb +1 -1
  29. data/templates/action_mailer.rb +1 -0
  30. data/templates/bundler_audit.rake +1 -0
  31. data/templates/capybara_webkit.rb +1 -0
  32. data/templates/database_cleaner_rspec.rb +1 -0
  33. data/templates/dev.rake +1 -0
  34. data/templates/devise_rspec.rb +1 -0
  35. data/templates/disable_xml_params.rb +1 -0
  36. data/templates/errors.rb +1 -0
  37. data/templates/factories.rb +1 -0
  38. data/templates/factory_girl_rspec.rb +1 -0
  39. data/templates/flashes_helper.rb +1 -0
  40. data/templates/i18n.rb +1 -0
  41. data/templates/json_encoding.rb +1 -0
  42. data/templates/puma.rb +1 -0
  43. data/templates/rails_helper.rb +1 -0
  44. data/templates/rubocop.yml +3 -1
  45. data/templates/shoulda_matchers_config_rspec.rb +1 -0
  46. data/templates/smtp.rb +1 -0
  47. data/templates/spec_helper.rb +1 -0
  48. data/templates/staging.rb +1 -0
  49. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2d35567d2e83680c0ecb09bdfba6d8007f9e4fd
4
- data.tar.gz: e67598e8e4dbd5ff6d38f71652b28b2dcfe75b75
3
+ metadata.gz: e21d88ceffa09a3f4b68fb44c8a5957bfbc88e5d
4
+ data.tar.gz: d51431339cdbcc01bf4a2aae22955b87c564beac
5
5
  SHA512:
6
- metadata.gz: ebb7f5871c9ed6672ad5a8c28222b65c81a9c1e6609004489d1c14dc8d3f1fb6d115c2c416ceea1da1b809a0c882dc8562a37fa2bae2d9ec6e1af6f562745f8c
7
- data.tar.gz: 123c47bcf58bea88492c2377ab2d4166fcaebab2500400856f25f86434961ed4a831bde3be6be2ad28ea2a3b23d6aea7bbfe805c92b2f1363bb496c7b44256d6
6
+ metadata.gz: 3bad941ec893d3672ddab89027c6ea631ff0e886498a5ae33b546d8388b9c242fc94e226e10b6996a4871cfe8353d490e6fa59894ea67f8791e2e7dddb2fd59e
7
+ data.tar.gz: 85735752d0db8659aa84f6133ef8798862ca73111d6f319972d0cfeecd1a8add6b6ddd54cc278754b27c5d6a60f754c22ef6b3700bd623ad1a8b11f4f68e90ad
data/.rubocop.yml CHANGED
@@ -41,4 +41,5 @@ AllCops:
41
41
  - 'bin/**/*'
42
42
  TargetRubyVersion: 2.3
43
43
  Metrics/AbcSize:
44
- Max: 25
44
+ Max: 30
45
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,100 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-02-10 17:38:44 +0100 using RuboCop version 0.37.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ Lint/AmbiguousRegexpLiteral:
11
+ Exclude:
12
+ - 'spec/features/new_project_spec.rb'
13
+
14
+ # Offense count: 1
15
+ Lint/DuplicateMethods:
16
+ Exclude:
17
+ - 'lib/onotole/generators/app_generator.rb'
18
+
19
+ # Offense count: 1
20
+ Lint/ParenthesesAsGroupedExpression:
21
+ Exclude:
22
+ - 'spec/spec_helper.rb'
23
+
24
+ # Offense count: 1
25
+ Lint/UnreachableCode:
26
+ Exclude:
27
+ - 'lib/onotole/app_builder.rb'
28
+
29
+ # Offense count: 3
30
+ Lint/UselessAssignment:
31
+ Exclude:
32
+ - 'lib/onotole/add_user_gems/after_install_patch.rb'
33
+
34
+ # Offense count: 1
35
+ Metrics/AbcSize:
36
+ Max: 27
37
+
38
+ # Offense count: 1
39
+ # Configuration parameters: CountComments.
40
+ Metrics/ClassLength:
41
+ Max: 537
42
+
43
+ # Offense count: 1
44
+ Metrics/CyclomaticComplexity:
45
+ Max: 8
46
+
47
+ # Offense count: 1
48
+ Metrics/PerceivedComplexity:
49
+ Max: 9
50
+
51
+ # Offense count: 1
52
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
53
+ # SupportedStyles: strict, flexible
54
+ Rails/Date:
55
+ Exclude:
56
+ - 'onotole.gemspec'
57
+
58
+ # Offense count: 1
59
+ # Configuration parameters: Include.
60
+ # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
61
+ Rails/Output:
62
+ Exclude:
63
+ - 'lib/onotole/adapters/heroku.rb'
64
+
65
+ # Offense count: 1
66
+ Style/AccessorMethodName:
67
+ Exclude:
68
+ - 'lib/onotole/generators/app_generator.rb'
69
+
70
+ # Offense count: 1
71
+ Style/AutoResourceCleanup:
72
+ Exclude:
73
+ - 'spec/support/fake_heroku.rb'
74
+
75
+ # Offense count: 5
76
+ # Configuration parameters: MinBodyLength.
77
+ Style/GuardClause:
78
+ Exclude:
79
+ - 'lib/onotole/app_builder.rb'
80
+ - 'lib/onotole/generators/app_generator.rb'
81
+ - 'spec/support/onotole.rb'
82
+
83
+ # Offense count: 6
84
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
85
+ # NamePrefix: is_, has_, have_
86
+ # NamePrefixBlacklist: is_, has_, have_
87
+ # NameWhitelist: is_a?
88
+ Style/PredicateName:
89
+ Exclude:
90
+ - 'spec/adapters/heroku_spec.rb'
91
+ - 'spec/support/fake_github.rb'
92
+ - 'spec/support/fake_heroku.rb'
93
+
94
+ # Offense count: 1
95
+ # Cop supports --auto-correct.
96
+ # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
97
+ # SupportedStyles: slashes, percent_r, mixed
98
+ Style/RegexpLiteral:
99
+ Exclude:
100
+ - 'lib/onotole/app_builder.rb'
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gemspec
data/Guardfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # A sample Guardfile
2
3
  # More info at https://github.com/guard/guard#readme
3
4
 
data/README.md CHANGED
@@ -18,11 +18,14 @@ As default uses the latest Ruby version and Rails '~> 4.2.0'
18
18
 
19
19
  This user gem pack are available for custom installation (you will choose only
20
20
  what you need) all of this will be available in customization menu with `-c`
21
- flag usage (no default selected gems will be installed). Gems with `*` mark
21
+ flag usage (no default selected gems will be installed), otherwise will be
22
+ installed default gem list. Gems with `*` mark
22
23
  will be installed as addition like default, if start `onotole` with out `-c`
23
- flag.
24
+ flag. You can provide automatic install with options, like `--haml`. Default
25
+ pack will not be installed with any gem option.
24
26
 
25
- * [Airbrake](https://github.com/airbrake/airbrake) for exception notification
27
+
28
+ * [Airbrake](https://github.com/airbrake/airbrake) For exception notification
26
29
  * [bootstrap3](https://github.com/seyhunak/twitter-bootstrap-rails) Bootstrap
27
30
  with asset pipeline support
28
31
  * [bootstrap3_sass](https://github.com/twbs/bootstrap-sass) Bootstrap sass
@@ -66,6 +69,11 @@ flag.
66
69
  with schema and routes info
67
70
  * `*`[overcommit](https://github.com/brigade/overcommit) A fully configurable
68
71
  and extendable Git hook manager
72
+ * [rails_admin](https://github.com/sferik/rails_admin) Rails engine that
73
+ provides an easy-to-use interface for managing your data
74
+ * [activeadmin](https://github.com/activeadmin/activeadmin) Rails framework for
75
+ creating elegant backends for website administration.
76
+
69
77
 
70
78
  Mandatory installation gem list you will find in `Gemfile` section
71
79
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/setup'
2
3
  require 'bundler/gem_tasks'
3
4
  require 'rspec/core/rake_task'
data/lib/onotole.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'onotole/version'
2
3
  require 'onotole/colors'
3
4
  require 'onotole/generators/app_generator'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Onotole
2
3
  module Actions
3
4
  def replace_in_file(relative_path, find, replace, quiet_err = false)
@@ -29,5 +30,13 @@ module Onotole
29
30
  before: "\nend"
30
31
  )
31
32
  end
33
+
34
+ def ask_stylish(str)
35
+ ask "#{BOLDGREEN} #{str} #{COLOR_OFF}".rjust(10)
36
+ end
37
+
38
+ def say_color(color, str)
39
+ say "#{color}#{str}#{COLOR_OFF}".rjust(4)
40
+ end
32
41
  end
33
42
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Onotole
2
3
  module Adapters
3
4
  class Heroku
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
1
2
  module Onotole
2
3
  module AfterInstallPatch
3
4
  def post_init
4
5
  install_queue = [:responders,
5
6
  :annotate,
6
7
  :overcommit,
8
+ :activeadmin,
9
+ :administrate,
10
+ :rails_admin,
7
11
  :guard,
8
12
  :guard_rubocop,
9
13
  :bootstrap3_sass,
@@ -20,19 +24,20 @@ module Onotole
20
24
  def after_install_devise
21
25
  bundle_command 'exec rails generate devise:install'
22
26
  if AppBuilder.devise_model
23
- bundle_command "exec rails generate devise #{AppBuilder.devise_model.titleize}"
27
+ rails_generator "devise #{AppBuilder.devise_model.titleize}"
24
28
  inject_into_file('app/controllers/application_controller.rb',
25
29
  "\nbefore_action :authenticate_#{AppBuilder.devise_model.titleize}!",
26
30
  after: 'before_action :configure_permitted_parameters, if: :devise_controller?')
27
31
  end
28
32
  if user_choose?(:bootstrap3)
29
- bundle_command 'exec rails generate devise:views:bootstrap_templates'
33
+ rails_generator 'devise:views:bootstrap_templates'
30
34
  else
31
- bundle_command 'exec rails generate devise:views'
35
+ rails_generator 'devise:views'
32
36
  end
33
37
  end
34
38
 
35
39
  def after_install_rubocop
40
+ run 'touch .rubocop_todo.yml'
36
41
  t = <<-TEXT
37
42
 
38
43
  if ENV['RAILS_ENV'] == 'test' || ENV['RAILS_ENV'] == 'development'
@@ -77,8 +82,8 @@ end
77
82
  def after_install_bootstrap3
78
83
  AppBuilder.use_asset_pipelline = true
79
84
  remove_file 'app/views/layouts/application.html.erb'
80
- bundle_command 'exec rails generate bootstrap:install static'
81
- bundle_command 'exec rails generate bootstrap:layout'
85
+ rails_generator 'bootstrap:install static'
86
+ rails_generator 'bootstrap:layout'
82
87
  inject_into_file('app/assets/stylesheets/bootstrap_and_overrides.css',
83
88
  " =require devise_bootstrap_views\n",
84
89
  before: ' */')
@@ -100,7 +105,7 @@ end
100
105
  end
101
106
 
102
107
  def after_install_responders
103
- bundle_command 'exec rails generate responders:install'
108
+ rails_generator 'responders:install'
104
109
  end
105
110
 
106
111
  def after_install_create_github_repo
@@ -108,12 +113,24 @@ end
108
113
  end
109
114
 
110
115
  def after_install_annotate
111
- bundle_command 'exec rails generate annotate:install'
116
+ rails_generator 'annotate:install'
112
117
  end
113
118
 
114
119
  def after_install_overcommit
115
120
  bundle_command 'exec overcommit --install'
116
121
  bundle_command 'exec overcommit --sign'
117
122
  end
123
+
124
+ def after_install_activeadmin
125
+ if user_choose? :devise
126
+ rails_generator 'active_admin:install'
127
+ else
128
+ rails_generator 'active_admin:install --skip-users'
129
+ end
130
+ end
131
+
132
+ def after_install_rails_admin
133
+ rails_generator 'rails_admin:install'
134
+ end
118
135
  end
119
136
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Onotole
2
3
  module BeforeBundlePatch
3
4
  def setup_default_gems
@@ -27,8 +28,7 @@ module Onotole
27
28
  end
28
29
 
29
30
  def add_rails_db_gem
30
- inject_into_file('Gemfile', "\n gem 'rails_db'\n gem 'axlsx_rails'",
31
- after: 'group :development do')
31
+ inject_into_file('Gemfile', "\n gem 'rails_db'\n gem 'axlsx_rails'", after: '# user_choice')
32
32
  end
33
33
 
34
34
  def add_rubocop_gem
@@ -61,7 +61,10 @@ module Onotole
61
61
  end
62
62
 
63
63
  def add_meta_request_gem
64
- inject_into_file('Gemfile', "\n gem 'meta_request' # link for chrome add-on. https://chrome.google.com/webstore/detail/railspanel/gjpfobpafnhjhbajcjgccbbdofdckggg",
64
+ inject_into_file('Gemfile',
65
+ "\n gem 'meta_request' # link for chrome add-on. "\
66
+ 'https://chrome.google.com/webstore/detail/'\
67
+ 'railspanel/gjpfobpafnhjhbajcjgccbbdofdckggg',
65
68
  after: 'group :development do')
66
69
  end
67
70
 
@@ -162,5 +165,22 @@ module Onotole
162
165
  OVER
163
166
  append_file '.overcommit.yml', rubocop_overcommit if user_choose?(:rubocop)
164
167
  end
168
+
169
+ def add_ar_import_gem
170
+ inject_into_file('Gemfile', "\ngem 'activerecord-import'", after: '# user_choice')
171
+ end
172
+
173
+ def add_activeadmin_gem
174
+ inject_into_file('Gemfile', "\ngem 'activeadmin', github: 'activeadmin'", after: '# user_choice')
175
+ end
176
+
177
+ # def add_administrate_gem
178
+ # inject_into_file('Gemfile', "\ngem 'administrate'", after: '# user_choice')
179
+ # end
180
+
181
+ def add_rails_admin_gem
182
+ inject_into_file('Gemfile', "\ngem 'rails_admin'", after: '# user_choice')
183
+ puts
184
+ end
165
185
  end
166
186
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Onotole
2
3
  module EditMenuQuestions
3
4
  def choose_frontend
@@ -26,23 +27,34 @@ module Onotole
26
27
  add_to_user_choise(gem) if gem
27
28
  end
28
29
 
30
+ def choose_cms_engine
31
+ variants = { none: 'None',
32
+ activeadmin: 'Activeadmin CMS',
33
+ rails_admin: 'Rails admin CMS',
34
+ rails_db: 'Rails DB. Simple pretty view in browser & xls export for models' }
35
+ gem = choice 'Select CMS: ', variants
36
+ add_to_user_choise(gem) if gem
37
+ end
38
+
29
39
  def choose_undroup_gems
30
- variants = { none: 'None',
31
- will_paginate: 'Easy pagination implement',
32
- rails_db: 'For pretty view in browser & xls export for models',
33
- faker: 'Gem for generate fake data in testing',
34
- rubocop: 'Code inspector and code formatting tool',
35
- guard: 'Guard (with RSpec, livereload, rails, migrate, bundler)',
36
- guard_rubocop: 'Auto-declare code miss in guard',
37
- bundler_audit: 'Extra possibilities for gems version control',
38
- airbrake: 'Airbrake error logging',
39
- responders: 'A set of responders modules to dry up your Rails 4.2+ app.',
40
- hirbunicode: 'Hirb unicode support',
41
- dotenv_heroku: 'dotenv-heroku support',
42
- tinymce: 'Integration of TinyMCE with the Rails asset pipeline',
43
- annotate: 'Annotate Rails classes with schema and routes info',
44
- overcommit: 'A fully configurable and extendable Git hook manager',
45
- meta_request: "Rails meta panel in chrome console. Very usefull in AJAX debugging.\n#{' ' * 24}Link for chrome add-on in Gemfile.\n#{' ' * 24}Do not delete comments if you need this link"
40
+ variants = { none: 'None',
41
+ will_paginate: 'Easy pagination implement',
42
+ faker: 'Gem for generate fake data in testing',
43
+ rubocop: 'Code inspector and code formatting tool',
44
+ guard: 'Guard (with RSpec, livereload, rails, migrate, bundler)',
45
+ guard_rubocop: 'Auto-declare code miss in guard',
46
+ bundler_audit: 'Extra possibilities for gems version control',
47
+ airbrake: 'Airbrake error logging',
48
+ responders: 'A set of responders modules to dry up your Rails 4.2+ app.',
49
+ hirbunicode: 'Hirb unicode support',
50
+ dotenv_heroku: 'dotenv-heroku support',
51
+ tinymce: 'Integration of TinyMCE with the Rails asset pipeline',
52
+ annotate: 'Annotate Rails classes with schema and routes info',
53
+ overcommit: 'A fully configurable and extendable Git hook manager',
54
+ activerecord_import: 'A library for bulk inserting data using ActiveRecord.',
55
+ meta_request: 'Rails meta panel in chrome console.'\
56
+ " Very usefull in\n#{' ' * 24}AJAX debugging. Link for chrome"\
57
+ " add-on in Gemfile.\n#{' ' * 24}Do not delete comments if you need this link"
46
58
  }
47
59
  multiple_choice('Write numbers of all preferred gems.', variants).each do |gem|
48
60
  add_to_user_choise gem
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Onotole
2
3
  module UserGemsMenu
3
4
  def users_gems
4
5
  choose_authenticate_engine
5
6
  choose_template_engine
6
7
  choose_frontend
8
+ choose_cms_engine
7
9
  # Placeholder for other gem additions
8
10
  # menu description in add_gems_in_menu.rb
9
11
 
@@ -1,8 +1,13 @@
1
+ # frozen_string_literal: true
1
2
  require 'forwardable'
2
3
  require 'onotole/add_user_gems/user_gems_menu_questions'
3
4
  require 'onotole/add_user_gems/edit_menu_questions'
4
5
  require 'onotole/add_user_gems/before_bundle_patch'
5
6
  require 'onotole/add_user_gems/after_install_patch'
7
+ require 'onotole/helpers'
8
+ require 'onotole/git'
9
+ require 'onotole/tests'
10
+ require 'onotole/mail'
6
11
 
7
12
  module Onotole
8
13
  class AppBuilder < Rails::AppBuilder
@@ -11,6 +16,10 @@ module Onotole
11
16
  include Onotole::EditMenuQuestions
12
17
  include Onotole::BeforeBundlePatch
13
18
  include Onotole::AfterInstallPatch
19
+ include Onotole::Helpers
20
+ include Onotole::Git
21
+ include Onotole::Tests
22
+ include Onotole::Mail
14
23
  extend Forwardable
15
24
 
16
25
  @use_asset_pipelline = true
@@ -40,27 +49,11 @@ module Onotole
40
49
  template 'README.md.erb', 'README.md'
41
50
  end
42
51
 
43
- def raise_on_missing_assets_in_test
44
- inject_into_file(
45
- 'config/environments/test.rb',
46
- "\n config.assets.raise_runtime_errors = true",
47
- after: 'Rails.application.configure do'
48
- )
49
- end
50
-
51
52
  def raise_on_delivery_errors
52
53
  replace_in_file 'config/environments/development.rb',
53
54
  'raise_delivery_errors = false', 'raise_delivery_errors = true'
54
55
  end
55
56
 
56
- def set_test_delivery_method
57
- inject_into_file(
58
- 'config/environments/development.rb',
59
- "\n config.action_mailer.delivery_method = :test",
60
- after: 'config.action_mailer.raise_delivery_errors = true'
61
- )
62
- end
63
-
64
57
  def add_bullet_gem_configuration
65
58
  config = <<-RUBY
66
59
  config.after_initialize do
@@ -97,33 +90,6 @@ module Onotole
97
90
  copy_file 'dev.rake', 'lib/tasks/dev.rake'
98
91
  end
99
92
 
100
- def configure_generators
101
- config = <<-RUBY
102
-
103
- config.generators do |generate|
104
- generate.helper false
105
- generate.javascript_engine false
106
- generate.request_specs false
107
- generate.routing_specs false
108
- generate.stylesheets false
109
- generate.test_framework :rspec
110
- generate.view_specs false
111
- generate.fixture_replacement :factory_girl
112
- end
113
-
114
- RUBY
115
-
116
- inject_into_class 'config/application.rb', 'Application', config
117
- end
118
-
119
- def set_up_factory_girl_for_rspec
120
- copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
121
- end
122
-
123
- def generate_factories_file
124
- copy_file 'factories.rb', 'spec/factories.rb'
125
- end
126
-
127
93
  def set_up_hound
128
94
  copy_file 'hound.yml', '.hound.yml'
129
95
  end
@@ -132,22 +98,6 @@ module Onotole
132
98
  template 'newrelic.yml.erb', 'config/newrelic.yml'
133
99
  end
134
100
 
135
- def configure_smtp
136
- copy_file 'smtp.rb', 'config/smtp.rb'
137
-
138
- prepend_file 'config/environments/production.rb',
139
- %{require Rails.root.join("config/smtp")\n}
140
-
141
- config = <<-RUBY
142
-
143
- config.action_mailer.delivery_method = :smtp
144
- config.action_mailer.smtp_settings = SMTP_SETTINGS
145
- RUBY
146
-
147
- inject_into_file 'config/environments/production.rb', config,
148
- after: 'config.action_mailer.raise_delivery_errors = false'
149
- end
150
-
151
101
  def enable_rack_canonical_host
152
102
  config = <<-RUBY
153
103
 
@@ -257,52 +207,17 @@ end
257
207
  create_file '.ruby-version', "#{Onotole::RUBY_VERSION}\n"
258
208
  end
259
209
 
260
- def enable_database_cleaner
261
- copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
262
- end
263
-
264
- def provide_shoulda_matchers_config
265
- copy_file(
266
- 'shoulda_matchers_config_rspec.rb',
267
- 'spec/support/shoulda_matchers.rb'
268
- )
269
- end
270
-
271
- def configure_spec_support_features
272
- empty_directory_with_keep_file 'spec/features'
273
- empty_directory_with_keep_file 'spec/support/features'
274
- end
275
-
276
- def configure_rspec
277
- remove_file 'spec/rails_helper.rb'
278
- remove_file 'spec/spec_helper.rb'
279
- copy_file 'rails_helper.rb', 'spec/rails_helper.rb'
280
- copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
281
- end
282
-
283
210
  def configure_ci
284
211
  template 'circle.yml.erb', 'circle.yml'
285
212
  end
286
213
 
287
- def configure_i18n_for_test_environment
288
- copy_file 'i18n.rb', 'spec/support/i18n.rb'
289
- end
290
-
291
214
  def configure_i18n_for_missing_translations
292
215
  raise_on_missing_translations_in('development')
293
216
  raise_on_missing_translations_in('test')
294
217
  end
295
218
 
296
219
  def configure_background_jobs_for_rspec
297
- bundle_command 'exec rails generate delayed_job:active_record'
298
- end
299
-
300
- def configure_action_mailer_in_specs
301
- copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
302
- end
303
-
304
- def configure_capybara_webkit
305
- copy_file 'capybara_webkit.rb', 'spec/support/capybara_webkit.rb'
220
+ rails_generator 'delayed_job:active_record'
306
221
  end
307
222
 
308
223
  def configure_time_formats
@@ -317,18 +232,12 @@ end
317
232
 
318
233
  def configure_simple_form
319
234
  if user_choose?(:bootstrap3_sass) || user_choose?(:bootstrap3)
320
- bundle_command 'exec rails generate simple_form:install --bootstrap'
235
+ rails_generator 'simple_form:install --bootstrap'
321
236
  else
322
- bundle_command 'exec rails generate simple_form:install'
237
+ rails_generator 'simple_form:install'
323
238
  end
324
239
  end
325
240
 
326
- def configure_action_mailer
327
- action_mailer_host 'development', %("localhost:3000")
328
- action_mailer_host 'test', %("www.example.com")
329
- action_mailer_host 'production', %{ENV.fetch("APPLICATION_HOST")}
330
- end
331
-
332
241
  def configure_active_job
333
242
  configure_application_file(
334
243
  'config.active_job.queue_adapter = :delayed_job'
@@ -341,10 +250,6 @@ end
341
250
  inject_into_class 'config/application.rb', 'Application', config
342
251
  end
343
252
 
344
- def generate_rspec
345
- bundle_command 'exec rails generate rspec:install'
346
- end
347
-
348
253
  def configure_puma
349
254
  copy_file 'puma.rb', 'config/puma.rb'
350
255
  end
@@ -360,7 +265,7 @@ end
360
265
  end
361
266
 
362
267
  def install_refills
363
- bundle_command 'exec rails generate refills:import flashes'
268
+ rails_generator 'refills:import flashes'
364
269
  run 'rm app/views/refills/_flashes.html.erb'
365
270
  run 'rmdir app/views/refills'
366
271
  end
@@ -369,39 +274,10 @@ end
369
274
  bundle_command 'exec bitters install --path app/assets/stylesheets'
370
275
  end
371
276
 
372
- def gitignore_files
373
- remove_file '.gitignore'
374
- copy_file 'gitignore_file', '.gitignore'
375
- [
376
- 'app/views/pages',
377
- 'spec/lib',
378
- 'spec/controllers',
379
- 'spec/helpers',
380
- 'spec/support/matchers',
381
- 'spec/support/mixins',
382
- 'spec/support/shared_examples'
383
- ].each do |dir|
384
- run "mkdir #{dir}"
385
- run "touch #{dir}/.keep"
386
- end
387
- end
388
-
389
277
  def copy_dotfiles
390
278
  directory 'dotfiles', '.', force: true
391
279
  end
392
280
 
393
- def init_git
394
- run 'git init'
395
- end
396
-
397
- def git_init_commit
398
- if user_choose?(:gitcommit)
399
- say 'Init commit'
400
- run 'git add .'
401
- run 'git commit -m "Init commit"'
402
- end
403
- end
404
-
405
281
  def create_heroku_apps(flags)
406
282
  create_staging_heroku_app(flags)
407
283
  create_production_heroku_app(flags)
@@ -437,10 +313,6 @@ you can deploy to staging and production with:
437
313
  append_file 'circle.yml', deploy_command
438
314
  end
439
315
 
440
- def create_github_repo(repo_name)
441
- system "hub create #{repo_name}"
442
- end
443
-
444
316
  def setup_segment
445
317
  copy_file '_analytics.html.erb',
446
318
  'app/views/application/_analytics.html.erb'
@@ -511,13 +383,6 @@ end
511
383
  end
512
384
  end
513
385
 
514
- def install_user_gems_from_github
515
- File.readlines('Gemfile').each do |l|
516
- possible_gem_name = l.match(/(?:github:\s+)(?:'|")\w+\/(.*)(?:'|")/i)
517
- install_from_github possible_gem_name[1] if possible_gem_name
518
- end
519
- end
520
-
521
386
  # def rvm_bundler_stubs_install
522
387
  # if system "rvm -v | grep 'rvm.io'"
523
388
  # run 'chmod +x $rvm_path/hooks/after_cd_bundler'
@@ -544,134 +409,21 @@ end
544
409
  say_color YELLOW, "Remember to run 'rails generate airbrake' with your API key." if user_choose? :airbrake
545
410
  end
546
411
 
547
- private
548
-
549
- def yes_no_question(gem_name, gem_description)
550
- gem_name_color = "#{gem_name.capitalize}.\n"
551
- variants = { none: 'No', gem_name.to_sym => gem_name_color }
552
- choice "Use #{gem_name}? #{gem_description}", variants
553
- end
554
-
555
- def choice(selector, variants)
556
- unless variants.keys[1..-1].map { |a| options[a] }.include? true
557
- values = []
558
- say "\n #{BOLDGREEN}#{selector}#{COLOR_OFF}"
559
- variants.each_with_index do |variant, i|
560
- values.push variant[0]
561
- say "#{i.to_s.rjust(5)}. #{BOLDBLUE}#{variant[1]}#{COLOR_OFF}"
562
- end
563
- answer = ask_stylish('Enter choice:') until (0...variants.length)
564
- .map(&:to_s).include? answer
565
- values[answer.to_i] == :none ? nil : values[answer.to_i]
566
- end
567
- end
568
-
569
- def multiple_choice(selector, variants)
570
- values = []
571
- result = []
572
- answers = ''
573
- say "\n #{BOLDGREEN}#{selector} Use space as separator#{COLOR_OFF}"
574
- variants.each_with_index do |variant, i|
575
- values.push variant[0]
576
- say "#{i.to_s.rjust(5)}. #{BOLDBLUE}#{variant[0]
577
- .to_s.ljust(15)}-#{COLOR_OFF} #{variant[1]}"
578
- end
579
- loop do
580
- answers = ask_stylish('Enter choices:').split ' '
581
- break if answers.any? && (answers - (0...variants.length)
582
- .to_a.map(&:to_s)).empty?
583
- end
584
- answers.delete '0'
585
- answers.uniq.each { |a| result.push values[a.to_i] }
586
- result
587
- end
588
-
589
- def ask_stylish(str)
590
- ask "#{BOLDGREEN} #{str} #{COLOR_OFF}".rjust(10)
591
- end
592
-
593
- def say_color(color, str)
594
- say "#{color}#{str}#{COLOR_OFF}".rjust(4)
595
- end
596
-
597
- def raise_on_missing_translations_in(environment)
598
- config = 'config.action_view.raise_on_missing_translations = true'
599
- uncomment_lines("config/environments/#{environment}.rb", config)
600
- end
601
-
602
- def heroku_adapter
603
- @heroku_adapter ||= Adapters::Heroku.new(self)
604
- end
605
-
606
- def serve_static_files_line
607
- "config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n"
608
- end
609
-
610
- def add_gems_from_args
611
- ARGV.each do |g|
612
- next unless g[0] == '-' && g[1] == '-'
613
- add_to_user_choise g[2..-1].to_sym
614
- end
615
- end
616
-
617
- def cleanup_comments(file)
618
- accepted_content = File.readlines(file).reject do |line|
619
- line =~ /^\s*#.*$/ || line =~ /^$\n/
620
- end
621
-
622
- File.open(file, 'w') do |f|
623
- accepted_content.each { |line| f.puts line }
624
- end
625
- end
626
-
627
- def delete_comments
628
- if options[:clean_comments] || user_choose?(:clean_comments)
629
- cleanup_comments 'Gemfile'
630
- remove_config_comment_lines
631
- remove_routes_comment_lines
632
- end
633
- end
634
-
635
- # does not recognize variable nesting, but now it does not matter
636
- def cover_def_by(file, lookup_str, external_def)
637
- expect_end = 0
638
- found = false
639
- accepted_content = ''
640
- File.readlines(file).each do |line|
641
- expect_end += 1 if found && line =~ /\sdo\s/
642
- expect_end -= 1 if found && line =~ /(\s+end|^end)/
643
- if line =~ Regexp.new(lookup_str)
644
- accepted_content += "#{external_def}\n#{line}"
645
- expect_end += 1
646
- found = true
647
- else
648
- accepted_content += line
649
- end
650
- if found && expect_end == 0
651
- accepted_content += "\nend"
652
- found = false
653
- end
654
- end
655
- File.open(file, 'w') do |f|
656
- f.puts accepted_content
657
- end
658
- end
659
-
660
- def install_from_github(gem_name)
661
- # TODO: in case of bundler update `bundle show` do now work any more
662
- return true
663
-
664
- return nil unless gem_name
665
- path = `cd #{Dir.pwd} && bundle show #{gem_name}`.chomp
666
- run "cd #{path} && bundle exec gem build #{gem_name}.gemspec && bundle exec gem install *.gem"
667
- end
668
-
669
- def user_choose?(g)
670
- AppBuilder.user_choice.include? g
412
+ def delete_comments
413
+ if options[:clean_comments] || user_choose?(:clean_comments)
414
+ cleanup_comments 'Gemfile'
415
+ remove_config_comment_lines
416
+ remove_routes_comment_lines
671
417
  end
418
+ end
672
419
 
673
- def add_to_user_choise(g)
674
- AppBuilder.user_choice.push g
420
+ def prevent_double_usage
421
+ if pgsql_db_exist?("#{app_name}_test") || pgsql_db_exist?("#{app_name}_development")
422
+ say_color RED, " YOU HAVE EXISTING DB WITH #{app_name.upcase}!!!"
423
+ say_color RED, " WRITE 'Y' TO CONTINUE WITH DELETION OF ALL DATA"
424
+ say_color RED, ' ANY OTHER INPUT FOR EXIT'
425
+ exit 0 unless STDIN.gets.chomp == 'Y'
675
426
  end
427
+ end
676
428
  end
677
429
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
  require 'rails/generators/rails/app/app_generator'
3
4
  module Onotole
@@ -43,6 +44,7 @@ module Onotole
43
44
  end
44
45
 
45
46
  def onotole_customization
47
+ invoke :prevent_double_usage
46
48
  invoke :customize_gemfile
47
49
  invoke :custom_gems_setup
48
50
  # invoke :bundler_stubs_install
@@ -108,7 +110,6 @@ module Onotole
108
110
  build :raise_on_missing_assets_in_test
109
111
  build :raise_on_delivery_errors
110
112
  build :set_test_delivery_method
111
- build :add_bullet_gem_configuration
112
113
  build :raise_on_unpermitted_parameters
113
114
  build :provide_setup_script
114
115
  build :provide_dev_prime_task
@@ -284,6 +285,11 @@ module Onotole
284
285
 
285
286
  def post_init
286
287
  build :post_init
288
+ build :add_bullet_gem_configuration
289
+ end
290
+
291
+ def prevent_double_usage
292
+ build :prevent_double_usage
287
293
  end
288
294
 
289
295
  protected
@@ -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.2'
5
+ VERSION = '1.0.4'
6
6
  end
data/onotole.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
4
  require 'onotole/version'
4
5
  require 'date'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  module Onotole
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require File.expand_path(File.join('..', '..', 'support', 'fake_heroku'), File.dirname(__FILE__))
4
5
 
data/spec/fakes/bin/hub CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require File.expand_path(File.join('..', '..', 'support', 'fake_github'), File.dirname(__FILE__))
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'GitHub' do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Heroku' do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe 'Suspend a new project with default configuration' do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/setup'
2
3
 
3
4
  Bundler.require(:default, :test)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class FakeGithub
2
3
  RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'hub_commands'), File.dirname(__FILE__))
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class FakeHeroku
2
3
  RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'heroku_commands'), File.dirname(__FILE__))
3
4
 
@@ -28,11 +28,11 @@ group :development do
28
28
  gem "spring"
29
29
  gem "spring-commands-rspec"
30
30
  gem "web-console"
31
+ gem "bullet"
31
32
  end
32
33
 
33
34
  group :development, :test do
34
35
  gem "hirb"
35
- gem "bullet"
36
36
  gem "bundler-audit", require: false
37
37
  gem "dotenv-rails"
38
38
  gem "factory_girl_rails"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.configure do |config|
2
3
  config.before(:each) do
3
4
  ActionMailer::Base.deliveries.clear
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  if Rails.env.development? || Rails.env.test?
2
3
  require 'bundler/audit/cli'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Capybara.javascript_driver = :webkit
2
3
 
3
4
  Capybara::Webkit.configure(&:block_unknown_urls)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.configure do |config|
2
3
  config.before(:suite) do
3
4
  DatabaseCleaner.clean_with(:deletion)
data/templates/dev.rake CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  if Rails.env.development? || Rails.env.test?
2
3
  require 'factory_girl'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.configure do |config|
2
3
  config.include Devise::TestHelpers, type: :controller
3
4
  end
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
data/templates/errors.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'net/http'
2
3
  require 'net/smtp'
3
4
 
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  FactoryGirl.define do
2
3
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.configure do |config|
2
3
  config.include FactoryGirl::Syntax::Methods
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module FlashesHelper
2
3
  def user_facing_flashes
3
4
  flash.to_hash.slice('alert', 'error', 'notice', 'success')
data/templates/i18n.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.configure do |config|
2
3
  config.include ActionView::Helpers::TranslationHelper
3
4
  end
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  ActiveSupport::JSON::Encoding.time_precision = 0
data/templates/puma.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server
2
3
 
3
4
  # The environment variable WEB_CONCURRENCY may be set to a default value based
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ENV['RAILS_ENV'] = 'test'
2
3
 
3
4
  require File.expand_path('../../config/environment', __FILE__)
@@ -25,7 +25,8 @@ Metrics/MethodLength:
25
25
  CountComments: false # count full line comments?
26
26
  Max: 40
27
27
  Style/StringLiterals:
28
- EnforcedStyle: single_quotes
28
+ EnforcedStyle: double_quotes
29
+ ConsistentQuotesInMultiline: true
29
30
  Style/StringLiteralsInInterpolation:
30
31
  EnforcedStyle: single_quotes
31
32
  NumericLiterals:
@@ -42,3 +43,4 @@ AllCops:
42
43
  TargetRubyVersion: 2.3
43
44
  Metrics/AbcSize:
44
45
  Max: 25
46
+ inherit_from: .rubocop_todo.yml
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Shoulda::Matchers.configure do |config|
2
3
  config.integrate do |with|
3
4
  with.test_framework :rspec
data/templates/smtp.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  SMTP_SETTINGS = {
2
3
  address: ENV.fetch('SMTP_ADDRESS'), # example: "smtp.sendgrid.net"
3
4
  authentication: :plain,
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  if ENV.fetch('COVERAGE', false)
2
3
  require 'simplecov'
3
4
  SimpleCov.start 'rails'
data/templates/staging.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'production'
2
3
 
3
4
  Mail.register_interceptor(
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.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kvokka
@@ -67,6 +67,7 @@ files:
67
67
  - ".gitignore"
68
68
  - ".overcommit.yml"
69
69
  - ".rubocop.yml"
70
+ - ".rubocop_todo.yml"
70
71
  - ".ruby-version"
71
72
  - ".travis.yml"
72
73
  - Gemfile