cb_list 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +181 -2
- data/cb_list.gemspec +3 -3
- data/lib/cb_list.rb +19 -19
- data/lib/cb_list/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a695c725ec93aab7d324ed85fe8cf5af06507a8d
|
4
|
+
data.tar.gz: c36dfa502ad589ebc2c38697801ceabc9e53293a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56c5281a599b5cdd2ac21f62d0b14340a671fd2f5cc25035c492f3d71b0dfa2c68e7f1f7c7af3ef3d29b4dbdba1d63748cfd56c00b6bf4023ca1664cd8f1eaf5
|
7
|
+
data.tar.gz: 388262299b0914d699274d6bd77e757d2e61e480d2d7660bc795771b3ec249ab9e0f9d1d3bb055b0e69bf31c61ba574b7b0ab29b6b93eb2e739bbc8fc8c439db
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# CbList
|
2
|
-
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/cb_list.svg)](https://badge.fury.io/rb/cb_list)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/zoki/cb_list/badges/gpa.svg)](https://codeclimate.com/github/zoki/cb_list)
|
5
|
+
|
6
|
+
|
7
|
+
List Active Record callbacks for a given class
|
3
8
|
|
4
9
|
|
5
10
|
## Installation
|
@@ -7,7 +12,7 @@ List ActiveRecord callbacks for a given Class
|
|
7
12
|
Add this line to your application's Gemfile:
|
8
13
|
|
9
14
|
```ruby
|
10
|
-
gem 'cb_list'
|
15
|
+
gem 'cb_list', group: :development
|
11
16
|
```
|
12
17
|
|
13
18
|
And then execute:
|
@@ -24,6 +29,180 @@ Display callbacks for Post model:
|
|
24
29
|
$ bin/rails ar:callbacks:show[Post]
|
25
30
|
|
26
31
|
|
32
|
+
### Example
|
33
|
+
|
34
|
+
$ bin/rails ar:callbacks:show[Spree::Product]
|
35
|
+
|
36
|
+
# Spree::Product Active Record Callbacks
|
37
|
+
#
|
38
|
+
# 1. INITIALIZE
|
39
|
+
# ====================
|
40
|
+
#
|
41
|
+
# after_initialize
|
42
|
+
# --------------------
|
43
|
+
# 1. ensure_master
|
44
|
+
# 2. build_first_node
|
45
|
+
# 3. on_initialize
|
46
|
+
#
|
47
|
+
# 2. FIND
|
48
|
+
# ====================
|
49
|
+
#
|
50
|
+
# after_find
|
51
|
+
# --------------------
|
52
|
+
# Empty
|
53
|
+
#
|
54
|
+
# 3. TOUCH
|
55
|
+
# ====================
|
56
|
+
#
|
57
|
+
# after_touch
|
58
|
+
# --------------------
|
59
|
+
# 1. touch_taxons
|
60
|
+
#
|
61
|
+
# 4. VALIDATION
|
62
|
+
# ====================
|
63
|
+
#
|
64
|
+
# before_validation
|
65
|
+
# --------------------
|
66
|
+
# 1. set_slug
|
67
|
+
# 2. normalize_slug
|
68
|
+
# 3. validate_master
|
69
|
+
# 4. set_translation
|
70
|
+
#
|
71
|
+
# after_validation
|
72
|
+
# --------------------
|
73
|
+
# 1. unset_slug_if_invalid
|
74
|
+
# 2. _ensure_no_duplicate_errors
|
75
|
+
# 3. reflect_errors_messages
|
76
|
+
#
|
77
|
+
# 5. SAVE
|
78
|
+
# ====================
|
79
|
+
#
|
80
|
+
# before_save
|
81
|
+
# --------------------
|
82
|
+
# 1. autosave_associated_records_for_tax_category
|
83
|
+
# 2. autosave_associated_records_for_shipping_category
|
84
|
+
# 3. set_nodes_default_locale_and_fallback
|
85
|
+
# 4. before_save_collection_association
|
86
|
+
#
|
87
|
+
# after_save
|
88
|
+
# --------------------
|
89
|
+
# 1. create_slug
|
90
|
+
# 2. run_touch_callbacks
|
91
|
+
# 3. update_pg_search_documents
|
92
|
+
#
|
93
|
+
# around_save
|
94
|
+
# --------------------
|
95
|
+
# Empty
|
96
|
+
#
|
97
|
+
# 6. CREATE
|
98
|
+
# ====================
|
99
|
+
#
|
100
|
+
# before_create
|
101
|
+
# --------------------
|
102
|
+
# Empty
|
103
|
+
#
|
104
|
+
# after_create
|
105
|
+
# --------------------
|
106
|
+
# 1. autosave_associated_records_for_slugs
|
107
|
+
# 2. autosave_associated_records_for_product_option_types
|
108
|
+
# 3. autosave_associated_records_for_option_types
|
109
|
+
# 4. autosave_associated_records_for_product_properties
|
110
|
+
# 5. autosave_associated_records_for_properties
|
111
|
+
# 6. autosave_associated_records_for_variant_property_rules
|
112
|
+
# 7. autosave_associated_records_for_variant_property_rule_values
|
113
|
+
# 8. autosave_associated_records_for_variant_property_rule_conditions
|
114
|
+
# 9. autosave_associated_records_for_classifications
|
115
|
+
# 10. autosave_associated_records_for_taxons
|
116
|
+
# 11. autosave_associated_records_for_product_promotion_rules
|
117
|
+
# 12. autosave_associated_records_for_promotion_rules
|
118
|
+
# 13. autosave_associated_records_for_master
|
119
|
+
# 14. autosave_associated_records_for_variants
|
120
|
+
# 15. autosave_associated_records_for_variants_including_master
|
121
|
+
# 16. autosave_associated_records_for_prices
|
122
|
+
# 17. autosave_associated_records_for_stock_items
|
123
|
+
# 18. autosave_associated_records_for_line_items
|
124
|
+
# 19. autosave_associated_records_for_orders
|
125
|
+
# 20. autosave_associated_records_for_variant_images
|
126
|
+
# 21. build_variants_from_option_values_hash
|
127
|
+
# 22. autosave_associated_records_for_nodes
|
128
|
+
# 23. autosave_associated_records_for_translations
|
129
|
+
#
|
130
|
+
# around_create
|
131
|
+
# --------------------
|
132
|
+
# Empty
|
133
|
+
#
|
134
|
+
# 7. UPDATE
|
135
|
+
# ====================
|
136
|
+
#
|
137
|
+
# before_update
|
138
|
+
# --------------------
|
139
|
+
# Empty
|
140
|
+
#
|
141
|
+
# after_update
|
142
|
+
# --------------------
|
143
|
+
# 1. autosave_associated_records_for_slugs
|
144
|
+
# 2. autosave_associated_records_for_product_option_types
|
145
|
+
# 3. autosave_associated_records_for_option_types
|
146
|
+
# 4. autosave_associated_records_for_product_properties
|
147
|
+
# 5. autosave_associated_records_for_properties
|
148
|
+
# 6. autosave_associated_records_for_variant_property_rules
|
149
|
+
# 7. autosave_associated_records_for_variant_property_rule_values
|
150
|
+
# 8. autosave_associated_records_for_variant_property_rule_conditions
|
151
|
+
# 9. autosave_associated_records_for_classifications
|
152
|
+
# 10. autosave_associated_records_for_taxons
|
153
|
+
# 11. autosave_associated_records_for_product_promotion_rules
|
154
|
+
# 12. autosave_associated_records_for_promotion_rules
|
155
|
+
# 13. autosave_associated_records_for_master
|
156
|
+
# 14. autosave_associated_records_for_variants
|
157
|
+
# 15. autosave_associated_records_for_variants_including_master
|
158
|
+
# 16. autosave_associated_records_for_prices
|
159
|
+
# 17. autosave_associated_records_for_stock_items
|
160
|
+
# 18. autosave_associated_records_for_line_items
|
161
|
+
# 19. autosave_associated_records_for_orders
|
162
|
+
# 20. autosave_associated_records_for_variant_images
|
163
|
+
# 21. autosave_associated_records_for_nodes
|
164
|
+
# 22. autosave_associated_records_for_translations
|
165
|
+
#
|
166
|
+
# around_update
|
167
|
+
# --------------------
|
168
|
+
# Empty
|
169
|
+
#
|
170
|
+
# 8. DESTROY
|
171
|
+
# ====================
|
172
|
+
#
|
173
|
+
# before_destroy
|
174
|
+
# --------------------
|
175
|
+
# 1. #<Proc:0x007feb7a908cc0@/Users/zzabcic/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.2/lib/active_record/associations/builder/association.rb:140 (lambda)>
|
176
|
+
# 2. #<Proc:0x007feb7a8f1890@/Users/zzabcic/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.2/lib/active_record/associations/builder/association.rb:140 (lambda)>
|
177
|
+
# 3. #<Proc:0x007feb7a8d9768@/Users/zzabcic/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.2/lib/active_record/associations/builder/association.rb:140 (lambda)>
|
178
|
+
# 4. #<Proc:0x007feb7a8c5a10@/Users/zzabcic/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.2/lib/active_record/associations/builder/association.rb:140 (lambda)>
|
179
|
+
# 5. #<Proc:0x007feb7a888ea8@/Users/zzabcic/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.2/lib/active_record/associations/builder/association.rb:140 (lambda)>
|
180
|
+
# 6. #<Proc:0x007feb7a86caa0@/Users/zzabcic/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.2/lib/active_record/associations/builder/association.rb:140 (lambda)>
|
181
|
+
# 7. #<Proc:0x007feb793cf9a8@/Users/zzabcic/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.0.2/lib/active_record/associations/builder/association.rb:140 (lambda)>
|
182
|
+
#
|
183
|
+
# after_destroy
|
184
|
+
# --------------------
|
185
|
+
# 1 punch_slug
|
186
|
+
#
|
187
|
+
# around_destroy
|
188
|
+
# --------------------
|
189
|
+
# Empty
|
190
|
+
#
|
191
|
+
# 9. COMMIT
|
192
|
+
# ====================
|
193
|
+
#
|
194
|
+
# after_commit
|
195
|
+
# --------------------
|
196
|
+
# Empty
|
197
|
+
#
|
198
|
+
# 10. ROLLBACK
|
199
|
+
# ====================
|
200
|
+
#
|
201
|
+
# after_rollback
|
202
|
+
# --------------------
|
203
|
+
# Empty
|
204
|
+
|
205
|
+
|
27
206
|
## Development
|
28
207
|
|
29
208
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/cb_list.gemspec
CHANGED
@@ -9,15 +9,15 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Zoran Žabčić"]
|
10
10
|
spec.email = ["zoran@effectiva.hr"]
|
11
11
|
|
12
|
-
spec.summary = %q{List
|
13
|
-
spec.description = %q{List
|
12
|
+
spec.summary = %q{List Active Record callbacks.}
|
13
|
+
spec.description = %q{List Active Record callbacks for a given class.}
|
14
14
|
spec.homepage = "https://github.com/zoki/cb_list"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata['allowed_push_host'] = "
|
20
|
+
# spec.metadata['allowed_push_host'] = "http://mygemserver.com"
|
21
21
|
else
|
22
22
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
23
|
"public gem pushes."
|
data/lib/cb_list.rb
CHANGED
@@ -7,13 +7,15 @@ module CbList
|
|
7
7
|
def self.show klass
|
8
8
|
klass = klass.constantize if klass.is_a? String
|
9
9
|
names = ActiveRecord::Callbacks::CALLBACKS.map { |cb| cb.to_s.split('_').last }.uniq
|
10
|
+
delimiter_1 = "=" * 20
|
11
|
+
delimiter_2 = "-" * 20
|
10
12
|
|
11
|
-
print_out "#{klass.name}
|
13
|
+
print_out "#{klass.name} Active Record Callbacks".red
|
12
14
|
|
13
15
|
names.each.with_index(1) do |name, name_index|
|
14
16
|
print_out
|
15
17
|
print_out "#{name_index}. #{name.upcase}".light_blue
|
16
|
-
print_out
|
18
|
+
print_out delimiter_1.light_blue
|
17
19
|
|
18
20
|
ActiveSupport::Callbacks::CALLBACK_FILTER_TYPES.each do |kind|
|
19
21
|
kind_name = "#{kind}_#{name}".to_sym
|
@@ -22,30 +24,28 @@ module CbList
|
|
22
24
|
if ActiveRecord::Callbacks::CALLBACKS.include?(kind_name)
|
23
25
|
print_out
|
24
26
|
print_out "#{kind_name}".blue
|
25
|
-
print_out
|
27
|
+
print_out delimiter_2.blue
|
26
28
|
kind_callbacks.each.with_index(1) do |callback, callback_index|
|
27
|
-
print_out "#{callback_index} #{callback.raw_filter}".green
|
29
|
+
print_out "#{callback_index}. #{callback.raw_filter}".green
|
28
30
|
end.presence || print_out("Empty")
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
puts result
|
40
|
-
end
|
36
|
+
def self.print_out str=nil
|
37
|
+
prefix = "# "
|
38
|
+
result = str ? prefix + str : prefix
|
39
|
+
puts result
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
def self.name_callbacks_for klass, name
|
43
|
+
klass.public_send("_#{name}_callbacks")
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
def self.name_kind_callbacks_for klass, name, kind
|
47
|
+
name_callbacks = name_callbacks_for(klass, name).select { |name_callback| name_callback.kind.eql?(kind) }
|
48
|
+
name_callbacks.reverse! if kind == :after
|
49
|
+
name_callbacks
|
50
|
+
end
|
51
51
|
end
|
data/lib/cb_list/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cb_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoran Žabčić
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '5.0'
|
97
|
-
description: List
|
97
|
+
description: List Active Record callbacks for a given class.
|
98
98
|
email:
|
99
99
|
- zoran@effectiva.hr
|
100
100
|
executables: []
|
@@ -138,5 +138,5 @@ rubyforge_project:
|
|
138
138
|
rubygems_version: 2.6.11
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
|
-
summary: List
|
141
|
+
summary: List Active Record callbacks.
|
142
142
|
test_files: []
|