onotole 1.2.11 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19ec47116d98944d0b270d19e2145fbb3085a94f
4
- data.tar.gz: 91b6a20b4767e0b24f6652457ea82350a5711658
3
+ metadata.gz: 6d39255d6d4c5f9fd1216568030bc4b0957ff143
4
+ data.tar.gz: 48f93eb22ba177d90a4ed338034ce55bb71ff1a7
5
5
  SHA512:
6
- metadata.gz: 4f47fd889faff5bbfd373df6e50adb34cabd6129bd4a55bd8f2effce95cbabc3f6abe111fe0e91d64ea6185bd6112fc041b376da6fab381ca243a31a5eafea33
7
- data.tar.gz: 18f4ad52526d0002b1435bc96e1f3f315f0e65cbf31a805dd8c88c712662bedf655f7ac27a87835802d81da77f622c68e4cdd588d6c0949a20d95216107269ad
6
+ metadata.gz: e4314cdb62a5cadf40117dc918a791dde1dc83be4923eaa29d9fcf382e453c8bb478c7d201d1ebcb5090c79d650779cf51f7b3d416136a551e85dc1288f38102
7
+ data.tar.gz: bce53559ebbbd71a5befdc6de001678b28863eb9f64dec29be9bb5334c377aafd44d8b44afb3fe5d8a9ff54a7ead1a1f880379fd38c2180aa53d350e1a3131cf
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  /tmp
6
6
  /.idea
7
7
  /vendor
8
+ /tst
data/README.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  New Rails project wizard. Onotole will help!
6
6
 
7
+ At this monent, i found unworking this gems:
8
+ * ActiveAdmin
9
+ * WillPaginane
10
+
11
+ I hope Rails 5 support willl be added there soon, or you may easyly find monkey patches for fixes.
12
+ Feel free to edit this list.
13
+
7
14
  [![Onotole](http://i.imgur.com/8VsFFvy.jpg?1)](https://www.youtube.com/watch?v=wAuqhLpV2DY)
8
15
 
9
16
  Read more [ENG](https://en.wikipedia.org/wiki/Anatoly_Wasserman) |
@@ -156,6 +163,8 @@ it through a dream. http://mailcatcher.me
156
163
  for ruby 2.1+
157
164
  * [active_record_doctor](https://github.com/gregnavis/active_record_doctor)
158
165
  Active Record Doctor helps to index unindexed foreign keys
166
+ * [git_up](https://github.com/aanand/git-up) Fetch and rebase all locally-tracked
167
+ remote branches
159
168
 
160
169
 
161
170
  #### Misc
@@ -252,8 +261,6 @@ generated projectname/Gemfile. This gem will be installed anyway.
252
261
  * [Autoprefixer Rails](https://github.com/ai/autoprefixer-rails) for CSS vendor prefixes
253
262
  * [Delayed Job](https://github.com/collectiveidea/delayed_job) for background
254
263
  processing
255
- * [Flutie](https://github.com/thoughtbot/flutie) for `page_title` and `body_class` view
256
- helpers
257
264
  * [High Voltage](https://github.com/thoughtbot/high_voltage) for static pages
258
265
  * [jQuery Rails](https://github.com/rails/jquery-rails) for jQuery
259
266
  * [Normalize](https://necolas.github.io/normalize.css/) for resetting browser styles
@@ -1,6 +1,6 @@
1
1
  ### Mailcatcher on load error
2
2
 
3
- I got in love in `Mailcather` project, but there is one dizzy feature in it- if
3
+ I've got in love in `Mailcather` project, but there is one dizzy feature in it- if
4
4
  in your controller must be sent some mail and `Mailcatcher` daemon is not running
5
5
  you will have an error (and it is oblivious). The is a sample code
6
6
 
@@ -0,0 +1,47 @@
1
+ ## Service Object
2
+
3
+ The is a pretty standard pattern in `Ruby`, when you use standard classes for
4
+ some purposes, and this pattern usually is called as Service Object.
5
+
6
+ There are 2 types of it: which will be instantiated, and witch will be like some
7
+ methods bag. In this article I'll talk about second type only. The easiest way to
8
+ implement it is to use standard `Ruby` class, like
9
+ ```
10
+ class Foo
11
+ def self.call
12
+ puts 42
13
+ end
14
+ end
15
+ ```
16
+ but it can be instantiated. It is not right! So we should `include Singleton`
17
+ module from `stdlib`, or do this work manually, mainly move #new method to
18
+ private group or undefine it.
19
+
20
+ The second way is to go upper and use `Module` as descendant, so code will be
21
+ like
22
+ ```
23
+ module Foo
24
+ def self.call
25
+ puts 42
26
+ end
27
+ end
28
+ ```
29
+ Now we have no problems with instances, but we still have `Module` methods, which
30
+ are unused in this approach. So, we can dig dipper and inherit from Object
31
+ ```
32
+ class << FOO ||= Object.new
33
+ def call
34
+ puts 42
35
+ end
36
+ end
37
+ ```
38
+ So we have no unused behavior and get cleaner code. Just new `Object` with pack
39
+ of singleton methods, and because it have class name, we use `||=` for preventing
40
+ multiple assigns, which will boost our code. Perfect!
41
+
42
+ Of course the is some feature on this approach. If you change `FOO#call` method
43
+ later, and then `require` again file with initial code of `FOO` it will not
44
+ restore method to initial state. But it is weeery unusual.
45
+
46
+ You may call it `Foo`, of course, but you will avoid the convention in this
47
+ case.
@@ -21,8 +21,9 @@ module Onotole
21
21
  :annotate,
22
22
  :overcommit,
23
23
  :activeadmin, :active_admin_theme, :acive_skin, :flattened_active_admin,
24
- :face_of_active_admin, :active_admin_bootstrap, :active_admin_simple_life,
24
+ :face_of_active_admin, :active_admin_bootstrap,
25
25
  :rails_admin,
26
+ :pundit,
26
27
  :guard, :guard_rubocop,
27
28
  :bootstrap3_sass, :bootstrap3, :devise_bootstrap_views,
28
29
  :active_admin_theme,
@@ -30,7 +31,6 @@ module Onotole
30
31
  :normalize,
31
32
  :tinymce,
32
33
  :rubocop,
33
- :abstract_model_wrapper,
34
34
  :create_github_repo]
35
35
  install_queue.each { |g| send "after_install_#{g}" if user_choose? g }
36
36
  delete_comments
@@ -297,18 +297,6 @@ end
297
297
  end
298
298
  end
299
299
 
300
- def after_install_active_admin_simple_life
301
- config = <<-DATA
302
- include ActiveAdminSimpleLife
303
- ActiveAdmin.setup do |config|
304
- include ActiveAdminSimpleLife::SimpleElements
305
-
306
- DATA
307
-
308
- replace_in_file 'config/initializers/active_admin.rb',
309
- 'ActiveAdmin.setup do |config|', config
310
- end
311
-
312
300
  def after_install_redis
313
301
  config = %q(
314
302
  config.cache_store = :redis_store, "#{ENV['REDIS_PATH']}/cache", { expires_in: 90.minutes }
@@ -355,16 +343,19 @@ DATA
355
343
  bundle_command 'exec sitemap:install'
356
344
  end
357
345
 
358
- def after_install_abstract_model_wrapper
359
- path = 'lib/rails/generators/active_record/model'
360
- run "mkdir -p #{path}"
361
- copy_file 'model_generator.rb', "#{path}/model_generator.rb"
362
- File.open('app/models/abstract_model.rb', 'w') do |f|
363
- f.puts <<-ABSTRACT
364
- class AbstractModel < ActiveRecord::Base
365
- self.abstract_class = true
366
- end
367
- ABSTRACT
346
+ def after_install_pundit
347
+ rails_generator 'pundit:install'
348
+ if user_choose? :activeadmin
349
+ initializer_path = 'config/initializers/active_admin.rb'
350
+ config = %(
351
+ config.authentication_method = :authenticate_admin_user!
352
+ config.authorization_adapter = ActiveAdmin::PunditAdapter
353
+ config.pundit_default_policy = "ApplicationPolicy"
354
+ )
355
+ inject_into_file initializer_path, config, after: 'ActiveAdmin.setup do |config|'
356
+ mkdir_and_touch 'app/policies/active_admin'
357
+ copy_file 'pundit/active_admin/comment_policy.rb', 'app/policies/active_admin/comment_policy.rb'
358
+ copy_file 'pundit/active_admin/page_policy.rb', 'app/policies/active_admin/page_policy.rb'
368
359
  end
369
360
  end
370
361
 
@@ -354,5 +354,13 @@ module Onotole
354
354
  def add_therubyracer_gem
355
355
  inject_into_file('Gemfile', "\n gem 'therubyracer'", after: '# user_choice')
356
356
  end
357
+
358
+ def add_pundit_gem
359
+ inject_into_file('Gemfile', "\n gem 'pundit'", after: '# user_choice')
360
+ end
361
+
362
+ def add_git_up_gem
363
+ inject_into_file('Gemfile', "\n gem 'git-up'", after: 'group :development do')
364
+ end
357
365
  end
358
366
  end
@@ -27,6 +27,12 @@ module Onotole
27
27
  add_to_user_choise(gem) if gem
28
28
  end
29
29
 
30
+ def choose_authorization_engine
31
+ variants = { none: 'None', pundit: 'Pundit' }
32
+ gem = choice 'Select authorization engine: ', variants
33
+ add_to_user_choise(gem) if gem
34
+ end
35
+
30
36
  def choose_cms_engine
31
37
  variants = { none: 'None',
32
38
  activeadmin: 'Activeadmin CMS (if devise selected Admin model will create automatic)',
@@ -89,6 +95,7 @@ module Onotole
89
95
  rack_mini_profiler: 'Middleware that displays speed badge for every html page.',
90
96
  flamegraph: 'Rack_mini_profiler awesome graphics generator. Need stackprof gem',
91
97
  stackprof: 'A sampling call-stack profiler for ruby 2.1+',
98
+ git_up: 'git-up(1) -- fetch and rebase all locally-tracked remote branches',
92
99
  meta_request: 'Rails meta panel in chrome console.'\
93
100
  " Very usefull in\n#{' ' * 24}AJAX debugging. Link for chrome"\
94
101
  " add-on in Gemfile.\n#{' ' * 24}Do not delete comments if you need this link",
@@ -163,11 +170,6 @@ module Onotole
163
170
  # end
164
171
 
165
172
  # TODO: move all this to other module
166
- def users_abstract_model_wrapper_choice
167
- variants = { none: 'No', abstract_model_wrapper: 'Yes' }
168
- sel = choice 'Create abstract model wrapper for all models? ', variants
169
- add_to_user_choise(sel) unless sel == :none
170
- end
171
173
 
172
174
  def users_init_commit_choice
173
175
  variants = { none: 'No', gitcommit: 'Yes' }
@@ -6,6 +6,7 @@ module Onotole
6
6
  choose_template_engine
7
7
  choose_frontend
8
8
  choose_authenticate_engine
9
+ choose_authorization_engine
9
10
  choose_pagimation
10
11
  choose_wysiwyg
11
12
  choose_develoder_tools
@@ -16,7 +17,6 @@ module Onotole
16
17
 
17
18
  choose_undroup_gems
18
19
  ask_cleanup_commens
19
- users_abstract_model_wrapper_choice
20
20
  users_init_commit_choice
21
21
  add_github_repo_creation_choice
22
22
  setup_default_gems
@@ -95,6 +95,7 @@ module Onotole
95
95
  end
96
96
 
97
97
  def configure_puma
98
+ remove_file 'config/puma.rb'
98
99
  template 'puma.rb.erb', 'config/puma.rb'
99
100
  end
100
101
 
@@ -139,11 +139,6 @@ end
139
139
  "Rails.application.routes.draw do\nend"
140
140
  end
141
141
 
142
- def disable_xml_params
143
- copy_file 'disable_xml_params.rb',
144
- 'config/initializers/disable_xml_params.rb'
145
- end
146
-
147
142
  def setup_default_rake_task
148
143
  append_file 'Rakefile' do
149
144
  <<-EOS
@@ -228,5 +223,9 @@ end
228
223
  f.write "\nend"
229
224
  end
230
225
  end
226
+
227
+ def copy_application_record
228
+ copy_file 'application_record.rb', 'app/models/application_record.rb'
229
+ end
231
230
  end
232
231
  end
@@ -173,7 +173,6 @@ module Onotole
173
173
  build :configure_action_mailer
174
174
  build :configure_active_job
175
175
  build :configure_time_formats
176
- build :disable_xml_params
177
176
  build :fix_i18n_deprecation_warning
178
177
  build :setup_default_rake_task
179
178
  build :configure_puma
@@ -182,6 +181,7 @@ module Onotole
182
181
  build :add_vendor_css_path
183
182
  build :add_fonts_autoload
184
183
  build :add_custom_formbuilder
184
+ build :copy_application_record
185
185
  end
186
186
 
187
187
  # def setup_stylesheets
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Onotole
3
- RAILS_VERSION = '~> 4.2.0'
3
+ RAILS_VERSION = '~> 5.0.0'
4
4
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
5
- VERSION = '1.2.11'
5
+ VERSION = '2.0.0'
6
6
  end
@@ -5,27 +5,27 @@ ruby "<%= Onotole::RUBY_VERSION %>"
5
5
  gem "delayed_job_active_record"
6
6
  gem "high_voltage"
7
7
  gem "jquery-rails"
8
- gem 'normalize-rails', '~> 3.0.0'
8
+ gem 'normalize-rails'
9
9
  gem "pg"
10
10
  gem "puma"
11
11
  gem "rack-canonical-host"
12
12
  gem "rails", "<%= Onotole::RAILS_VERSION %>"
13
13
  gem "simple_form"
14
14
  gem "title"
15
- gem 'rake', '~> 11.1.0'
15
+ gem 'rake', '~> 11.2.0'
16
16
  gem "awesome_print", :require=>"ap"
17
17
  gem "dotenv-rails"
18
18
  # user_choice
19
19
 
20
20
  group :assets do
21
- gem "sass-rails", "~> 5.0"
21
+ gem "sass-rails"
22
22
  gem "autoprefixer-rails"
23
- gem "coffee-rails", "~> 4.1.0"
23
+ gem "coffee-rails"
24
24
  gem "uglifier"
25
25
  end
26
26
 
27
27
  group :development do
28
- gem "quiet_assets"
28
+ # gem "quiet_assets"
29
29
  gem "spring"
30
30
  gem "spring-commands-rspec"
31
31
  gem "web-console"
@@ -35,6 +35,7 @@ group :development do
35
35
  gem 'pry-doc'
36
36
  gem 'pry-rescue'
37
37
  gem 'pry-state'
38
+ gem 'pry-stack_explorer'
38
39
  gem 'better_errors'
39
40
  gem 'binding_of_caller'
40
41
  gem "hirb"
@@ -43,7 +44,7 @@ end
43
44
  group :development, :test do
44
45
  gem "factory_girl_rails"
45
46
  gem "bundler-audit", require: false
46
- gem "rspec-rails", "~> 3.4.0"
47
+ gem "rspec-rails"
47
48
  end
48
49
 
49
50
  group :test do
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -13,10 +13,12 @@
13
13
  # Starting with a low number of workers and threads provides adequate
14
14
  # performance for most applications, even under load, while maintaining a low
15
15
  # risk of overusing memory.
16
- workers Integer(ENV.fetch('<%= "#{app_name.upcase}_WEB_CONCURRENCY" %>', 2))
17
- threads_count = Integer(ENV.fetch('<%= "#{app_name.upcase}_MAX_THREADS" %>', 2))
16
+ workers Integer(ENV.fetch('<%= "#{app_name.upcase}_WEB_CONCURRENCY" %>', 5))
17
+ threads_count = Integer(ENV.fetch('<%= "#{app_name.upcase}_MAX_THREADS" %>', 5))
18
18
  threads(2, threads_count)
19
19
 
20
+ port ENV.fetch("<%= "#{app_name.upcase}_PORT" %>") { 3000 }
21
+
20
22
  preload_app!
21
23
 
22
24
  rackup DefaultRackup
@@ -29,3 +31,5 @@ on_worker_boot do
29
31
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
30
32
  ActiveRecord::Base.establish_connection
31
33
  end
34
+
35
+ plugin :tmp_restart
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ module ActiveAdmin
3
+ class CommentPolicy < ApplicationPolicy
4
+ class Scope < ApplicationPolicy::Scope
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ module ActiveAdmin
3
+ class PagePolicy < ApplicationPolicy
4
+ class Scope < ApplicationPolicy::Scope
5
+ end
6
+
7
+ def show?
8
+ case record.name
9
+ when 'Dashboard'
10
+ true
11
+ else
12
+ false
13
+ end
14
+ end
15
+ end
16
+ 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.2.11
4
+ version: 2.0.0
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-05-19 00:00:00.000000000 Z
12
+ date: 2016-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 4.2.0
34
+ version: 5.0.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 4.2.0
41
+ version: 5.0.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,7 @@ files:
88
88
  - goodies/form_builder_extension.md
89
89
  - goodies/mailcatcher_loading_patch.md
90
90
  - goodies/seeds_organization.md
91
+ - goodies/service_object.md
91
92
  - goodies/tests_speed_up_hack.md
92
93
  - lib/onotole.rb
93
94
  - lib/onotole/actions.rb
@@ -132,6 +133,7 @@ files:
132
133
  - templates/admin_bootstrap.scss
133
134
  - templates/app.json.erb
134
135
  - templates/application.scss
136
+ - templates/application_record.rb
135
137
  - templates/bin_deploy
136
138
  - templates/bin_setup
137
139
  - templates/bin_setup_review_app.erb
@@ -149,7 +151,6 @@ files:
149
151
  - templates/dev.rake
150
152
  - templates/devise.ru.yml
151
153
  - templates/devise_rspec.rb
152
- - templates/disable_xml_params.rb
153
154
  - templates/dotenv.erb
154
155
  - templates/dotenv_production.erb
155
156
  - templates/dotfiles/.ctags
@@ -166,12 +167,13 @@ files:
166
167
  - templates/json_encoding.rb
167
168
  - templates/kaminari.rb
168
169
  - templates/kill_postgress_conections.rake
169
- - templates/model_generator.rb
170
170
  - templates/newrelic.yml.erb
171
171
  - templates/onotole_layout.html.erb.erb
172
172
  - templates/onotole_overcommit.yml
173
173
  - templates/postgresql_database.yml.erb
174
174
  - templates/puma.rb.erb
175
+ - templates/pundit/active_admin/comment_policy.rb
176
+ - templates/pundit/active_admin/page_policy.rb
175
177
  - templates/rack_mini_profiler.rb
176
178
  - templates/rails_helper.rb
177
179
  - templates/redis.rake
@@ -1,2 +0,0 @@
1
- # frozen_string_literal: true
2
- ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rails/generators/active_record'
3
- module ActiveRecord
4
- module Generators # :nodoc:
5
- class ModelGenerator < Base # :nodoc:
6
- argument :attributes, type: :array, default: [], banner: 'field[:type][:index] field[:type][:index]'
7
-
8
- check_class_collision
9
-
10
- class_option :migration, type: :boolean
11
- class_option :timestamps, type: :boolean
12
- class_option :parent, type: :string, desc: 'The parent class for the generated model'
13
- class_option :indexes, type: :boolean, default: true, desc: 'Add indexes for references and belongs_to columns'
14
-
15
- # creates the migration file for the model.
16
-
17
- def create_migration_file
18
- return unless options[:migration] && options[:parent].nil?
19
- attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false
20
- migration_template '../../migration/templates/create_table_migration.rb', "db/migrate/create_#{table_name}.rb"
21
- end
22
-
23
- def create_model_file
24
- template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
25
- end
26
-
27
- def create_module_file
28
- return if regular_class_path.empty?
29
- template 'module.rb', File.join('app/models', "#{class_path.join('/')}.rb") if behavior == :invoke
30
- end
31
-
32
- def attributes_with_index
33
- attributes.select { |a| !a.reference? && a.has_index? }
34
- end
35
-
36
- def accessible_attributes
37
- attributes.reject(&:reference?)
38
- end
39
-
40
- hook_for :test_framework
41
-
42
- protected
43
-
44
- # Used by the migration template to determine the parent name of the model
45
- def parent_class_name
46
- options[:parent] || 'AbstractModel'
47
- end
48
- end
49
- end
50
- end