onotole 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/onotole/add_user_gems/after_install_patch.rb +14 -0
- data/lib/onotole/add_user_gems/edit_menu_questions.rb +7 -0
- data/lib/onotole/add_user_gems/user_gems_menu_questions.rb +1 -0
- data/lib/onotole/version.rb +1 -1
- data/templates/model_generator.rb +50 -0
- data/templates/support.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ed38623e2c23934c719c6ac10948a8ef180fb22
|
4
|
+
data.tar.gz: 0edf421b48ca2d6bdd3ad0319550544de078130a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73aae5a47a32ae3ffec342661e729cc75fb246567a12a457211f8b3447f90b2ea92383041f82d9608bb24069f7185bc939302bafe5ed9bdc178988ab0e5716aa
|
7
|
+
data.tar.gz: 5628a8a56133950bb53957eec4ac0a6a45474817b1a5c3423fe5be368f6b8ddd741b4c56408a0782d3d26b4f198dfb754f6d465ff18e7ce74bb91f42b6f11f52
|
data/README.md
CHANGED
@@ -356,6 +356,7 @@ improvement
|
|
356
356
|
* Made seeds organization for easy splitting data from scratch
|
357
357
|
* `Carrierwave` may be integrated with `mini_magick` and `ckeditor`, depend on
|
358
358
|
user choice
|
359
|
+
* Ability to use `AbstractModel` for easy code extension
|
359
360
|
|
360
361
|
## Heroku
|
361
362
|
|
@@ -29,6 +29,7 @@ module Onotole
|
|
29
29
|
:normalize,
|
30
30
|
:tinymce,
|
31
31
|
:rubocop,
|
32
|
+
:abstract_model_wrapper,
|
32
33
|
:create_github_repo]
|
33
34
|
install_queue.each { |g| send "after_install_#{g}" if user_choose? g }
|
34
35
|
delete_comments
|
@@ -352,5 +353,18 @@ DATA
|
|
352
353
|
def after_install_sitemap_generator
|
353
354
|
bundle_command 'exec sitemap:install'
|
354
355
|
end
|
356
|
+
|
357
|
+
def after_install_abstract_model_wrapper
|
358
|
+
path = 'lib/rails/generators/active_record/model'
|
359
|
+
run "mkdir -p #{path}"
|
360
|
+
copy_file 'model_generator.rb', "#{path}/model_generator.rb"
|
361
|
+
File.open('app/models/abstract_model.rb', 'w') do |f|
|
362
|
+
f.puts <<-ABSTRACT
|
363
|
+
class AbstractModel < ActiveRecord::Base
|
364
|
+
self.abstract_class = true
|
365
|
+
end
|
366
|
+
ABSTRACT
|
367
|
+
end
|
368
|
+
end
|
355
369
|
end
|
356
370
|
end
|
@@ -164,6 +164,13 @@ module Onotole
|
|
164
164
|
# gem_description)) unless options[gem_name]
|
165
165
|
# end
|
166
166
|
|
167
|
+
# TODO: move all this to other module
|
168
|
+
def users_abstract_model_wrapper_choice
|
169
|
+
variants = { none: 'No', abstract_model_wrapper: 'Yes' }
|
170
|
+
sel = choice 'Create abstract model wrapper for all models? ', variants
|
171
|
+
add_to_user_choise(sel) unless sel == :none
|
172
|
+
end
|
173
|
+
|
167
174
|
def users_init_commit_choice
|
168
175
|
variants = { none: 'No', gitcommit: 'Yes' }
|
169
176
|
sel = choice 'Make init commit in the end? ', variants
|
data/lib/onotole/version.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
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
|
data/templates/support.rb
CHANGED
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.
|
4
|
+
version: 1.2.7
|
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-04-
|
12
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- templates/json_encoding.rb
|
166
166
|
- templates/kaminari.rb
|
167
167
|
- templates/kill_postgress_conections.rake
|
168
|
+
- templates/model_generator.rb
|
168
169
|
- templates/newrelic.yml.erb
|
169
170
|
- templates/onotole_layout.html.erb.erb
|
170
171
|
- templates/onotole_overcommit.yml
|