pattern_bibz 1.0.0 → 1.1.0

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
  SHA256:
3
- metadata.gz: 7fe8d6514ef5de5b312c58f18a744eb8eaef8fbd0647f3fb3109816d4a30396e
4
- data.tar.gz: 021efc4f47bc1b8134c668c261092661abbecd38b44e2c9c0900691a0efb9b86
3
+ metadata.gz: 204e90306d1dc45d8667ac9131c0befc58d4657cd4e94929bd148d1daa85547b
4
+ data.tar.gz: b13a012f55a17cc77f170c3da9d405170289f4fc54c3c1d3e45277dec5f0e536
5
5
  SHA512:
6
- metadata.gz: ad8fc41cbd8aeab76cf96740fd80b620aca8aa5dc7ed9882b519581015b7e4757677b54aefa358f67334739970d3bc614e6763b8ac9b332f936b90da87ab1264
7
- data.tar.gz: 6a4c5ed8ef6869723bd944418e946dc97df9e5134cda9a4762b3e5f54c039919ec77a37c7dcfe0109f9efd2152eb6857463014cae42734ffd462f29de3da2798
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 -%>
@@ -1,3 +1,3 @@
1
1
  module PatternBibz
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
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.0.0
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