pattern_bibz 1.0.0 → 1.1.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 204e90306d1dc45d8667ac9131c0befc58d4657cd4e94929bd148d1daa85547b
|
4
|
+
data.tar.gz: b13a012f55a17cc77f170c3da9d405170289f4fc54c3c1d3e45277dec5f0e536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3368207250e5a166cb731dc2f0e7160c5caa7a60529c8a6994d2bc4f5c12d0131a577f2d6836d61c12cc9f30466129a493c3f82b6f8ab1ae596882093042f1f9
|
7
|
+
data.tar.gz: 5858316afa7976d15b572cbca0b71d4914c17e1620e894b82340f5a31ec285eba3ae1cf3fa173eba2b9ab2bb2b616aaca175501c6409165298196f52ea3c85a7
|
data/README.md
CHANGED
@@ -35,6 +35,17 @@ Or install it yourself as:
|
|
35
35
|
$ gem install pattern_bibz
|
36
36
|
```
|
37
37
|
|
38
|
+
## Utils
|
39
|
+
To extend your Rails model generator:
|
40
|
+
```bash
|
41
|
+
rails g pattern_bibz:extend_model
|
42
|
+
```
|
43
|
+
|
44
|
+
Then you can generate your model:
|
45
|
+
```bash
|
46
|
+
rails g model MyModel title:string ...
|
47
|
+
```
|
48
|
+
|
38
49
|
## Contributing
|
39
50
|
Contribution directions go here.
|
40
51
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
module PatternBibz
|
5
|
+
module Generators
|
6
|
+
# Extend the Rails model generator
|
7
|
+
class ExtendModelGenerator < ::Rails::Generators::Base
|
8
|
+
source_root File.expand_path('templates', __dir__)
|
9
|
+
desc 'Extend Rails Model generator'
|
10
|
+
|
11
|
+
def copy_initializer
|
12
|
+
directory File.join(File.dirname(__dir__), 'pattern_bibz/templates'),
|
13
|
+
Rails.root.join('lib/templates/active_record/model'), mode: :preserve
|
14
|
+
|
15
|
+
puts 'Install complete in lib/templates/active_record/model.rb'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %> < <%= parent_class_name.classify %>
|
3
|
+
# Scopes
|
4
|
+
|
5
|
+
# Constants
|
6
|
+
|
7
|
+
# Callbacks
|
8
|
+
|
9
|
+
# Attr_accessors
|
10
|
+
|
11
|
+
# Associations
|
12
|
+
<% attributes.select(&:reference?).each do |attribute|-%>
|
13
|
+
belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? -%>
|
14
|
+
<% end %>
|
15
|
+
<% attributes.select(&:rich_text?).each do |attribute| -%>
|
16
|
+
has_rich_text :<%= attribute.name %>
|
17
|
+
<% end -%>
|
18
|
+
<% attributes.select(&:attachment?).each do |attribute| -%>
|
19
|
+
has_one_attached :<%= attribute.name %>
|
20
|
+
<% end -%>
|
21
|
+
<% attributes.select(&:attachments?).each do |attribute| -%>
|
22
|
+
has_many_attached :<%= attribute.name %>
|
23
|
+
<% end -%>
|
24
|
+
|
25
|
+
# Enums
|
26
|
+
|
27
|
+
# Validations
|
28
|
+
|
29
|
+
# Delegations
|
30
|
+
|
31
|
+
# Methods
|
32
|
+
<% attributes.select(&:token?).each do |attribute| -%>
|
33
|
+
has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
|
34
|
+
<% end -%>
|
35
|
+
<% if attributes.any?(&:password_digest?) -%>
|
36
|
+
has_secure_password
|
37
|
+
<% end -%>
|
38
|
+
end
|
39
|
+
<% end -%>
|
data/lib/pattern_bibz/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pattern_bibz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas HUMMEL
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- Rakefile
|
86
86
|
- lib/generators/pattern/USAGE
|
87
87
|
- lib/generators/pattern/pattern_generator.rb
|
88
|
+
- lib/generators/pattern_bibz/extend_model_generator.rb
|
89
|
+
- lib/generators/pattern_bibz/templates/model.rb
|
88
90
|
- lib/pattern_bibz.rb
|
89
91
|
- lib/pattern_bibz/railtie.rb
|
90
92
|
- lib/pattern_bibz/version.rb
|