acts-as-taggable-on-mongoid 6.1.1.8 → 6.1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +28 -28
- data/lib/acts-as-taggable-on-mongoid.rb +1 -0
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_hooks.rb +68 -0
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb +16 -14
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_model.rb +1 -0
- data/lib/acts_as_taggable_on_mongoid/taggable.rb +3 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition.rb +2 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/attributes.rb +1 -0
- data/lib/acts_as_taggable_on_mongoid/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d45c548b71b63a3387393c91cee4d02f0e7531aa608e0ff5d70622361d2a796c
|
4
|
+
data.tar.gz: 5e565201e0be8bd6fdecba7f441acbe51c7b38af301b58ed6bcf75217dd1f587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe813547f33c204e03aca29c728ea4e860738471d4b96dddce26f21161a25dd51f70c20c3b125501d79618a0bef4e7001cd1d160b03c160bbdc58e8265aae9aa
|
7
|
+
data.tar.gz: eeb852d2b50a68591381a864b04ba3e36280c0cdea769ebd646ce1864f1c5eaca5593dfb222227e0eb34cb02dca454c64f0beb373e374bc2c26706cb3db3383e
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require: rubocop-performance
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.7.1
|
5
5
|
Exclude:
|
6
6
|
- 'vendor/**/*'
|
7
7
|
- 'db/schema.rb'
|
@@ -409,3 +409,15 @@ Layout/HashAlignment:
|
|
409
409
|
- always_ignore
|
410
410
|
- ignore_implicit
|
411
411
|
- ignore_explicit
|
412
|
+
|
413
|
+
Layout/SpaceAroundMethodCallOperator:
|
414
|
+
Enabled: true
|
415
|
+
|
416
|
+
Lint/RaiseException:
|
417
|
+
Enabled: true
|
418
|
+
|
419
|
+
Lint/StructNewOverride:
|
420
|
+
Enabled: true
|
421
|
+
|
422
|
+
Style/ExponentialNotation:
|
423
|
+
Enabled: true
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acts-as-taggable-on-mongoid (6.1.1.
|
4
|
+
acts-as-taggable-on-mongoid (6.1.1.10)
|
5
5
|
activesupport (>= 5.0)
|
6
6
|
mongoid (>= 6.1.1, <= 7.0.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (5.
|
12
|
-
activesupport (= 5.
|
13
|
-
activesupport (5.
|
11
|
+
activemodel (5.2.4.2)
|
12
|
+
activesupport (= 5.2.4.2)
|
13
|
+
activesupport (5.2.4.2)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (
|
15
|
+
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
17
17
|
tzinfo (~> 1.1)
|
18
18
|
addressable (2.7.0)
|
@@ -22,8 +22,8 @@ GEM
|
|
22
22
|
descendants_tracker (~> 0.0.4)
|
23
23
|
ice_nine (~> 0.11.0)
|
24
24
|
thread_safe (~> 0.3, >= 0.3.1)
|
25
|
-
brakeman (4.8.
|
26
|
-
bson (4.
|
25
|
+
brakeman (4.8.1)
|
26
|
+
bson (4.8.2)
|
27
27
|
code_analyzer (0.5.1)
|
28
28
|
sexp_processor
|
29
29
|
codeclimate-engine-rb (0.4.1)
|
@@ -38,26 +38,26 @@ GEM
|
|
38
38
|
concurrent-ruby (1.1.6)
|
39
39
|
cornucopia (0.1.56)
|
40
40
|
activesupport (> 4.0, < 6.0)
|
41
|
-
database_cleaner (1.8.
|
41
|
+
database_cleaner (1.8.4)
|
42
42
|
descendants_tracker (0.0.4)
|
43
43
|
thread_safe (~> 0.3, >= 0.3.1)
|
44
44
|
diff-lcs (1.3)
|
45
45
|
docile (1.3.2)
|
46
46
|
equalizer (0.0.11)
|
47
47
|
erubis (2.7.0)
|
48
|
-
faraday (1.0.
|
48
|
+
faraday (1.0.1)
|
49
49
|
multipart-post (>= 1.2, < 3)
|
50
|
-
fasterer (0.8.
|
50
|
+
fasterer (0.8.3)
|
51
51
|
colorize (~> 0.7)
|
52
52
|
ruby_parser (>= 3.14.1)
|
53
53
|
gem-release (2.1.1)
|
54
|
-
gitlab (4.
|
54
|
+
gitlab (4.14.1)
|
55
55
|
httparty (~> 0.14, >= 0.14.0)
|
56
56
|
terminal-table (~> 1.5, >= 1.5.1)
|
57
57
|
httparty (0.18.0)
|
58
58
|
mime-types (~> 3.0)
|
59
59
|
multi_xml (>= 0.5.2)
|
60
|
-
i18n (
|
60
|
+
i18n (1.8.2)
|
61
61
|
concurrent-ruby (~> 1.0)
|
62
62
|
ice_nine (0.11.2)
|
63
63
|
jaro_winkler (1.5.4)
|
@@ -65,20 +65,20 @@ GEM
|
|
65
65
|
kwalify (0.7.2)
|
66
66
|
mime-types (3.3.1)
|
67
67
|
mime-types-data (~> 3.2015)
|
68
|
-
mime-types-data (3.
|
68
|
+
mime-types-data (3.2020.0425)
|
69
69
|
minitest (5.14.0)
|
70
|
-
mongo (2.11.
|
70
|
+
mongo (2.11.4)
|
71
71
|
bson (>= 4.4.2, < 5.0.0)
|
72
|
-
mongoid (
|
73
|
-
activemodel (
|
74
|
-
mongo (>= 2.
|
72
|
+
mongoid (7.0.2)
|
73
|
+
activemodel (>= 5.1, < 6.0.0)
|
74
|
+
mongo (>= 2.5.1, < 3.0.0)
|
75
75
|
multi_xml (0.6.0)
|
76
76
|
multipart-post (2.1.1)
|
77
|
-
octokit (4.
|
77
|
+
octokit (4.18.0)
|
78
78
|
faraday (>= 0.9)
|
79
79
|
sawyer (~> 0.8.0, >= 0.5.3)
|
80
80
|
parallel (1.19.1)
|
81
|
-
parser (2.7.
|
81
|
+
parser (2.7.1.1)
|
82
82
|
ast (~> 2.4.0)
|
83
83
|
pronto (0.10.0)
|
84
84
|
gitlab (~> 4.0, >= 4.0.0)
|
@@ -105,8 +105,8 @@ GEM
|
|
105
105
|
pronto (~> 0.10.0)
|
106
106
|
rubocop (~> 0.50, >= 0.49.1)
|
107
107
|
psych (3.1.0)
|
108
|
-
public_suffix (4.0.
|
109
|
-
rails_best_practices (1.
|
108
|
+
public_suffix (4.0.4)
|
109
|
+
rails_best_practices (1.20.0)
|
110
110
|
activesupport
|
111
111
|
code_analyzer (>= 0.5.1)
|
112
112
|
erubis
|
@@ -130,7 +130,7 @@ GEM
|
|
130
130
|
rspec-mocks (~> 3.9.0)
|
131
131
|
rspec-core (3.9.1)
|
132
132
|
rspec-support (~> 3.9.1)
|
133
|
-
rspec-expectations (3.9.
|
133
|
+
rspec-expectations (3.9.1)
|
134
134
|
diff-lcs (>= 1.2.0, < 2.0)
|
135
135
|
rspec-support (~> 3.9.0)
|
136
136
|
rspec-mocks (3.9.1)
|
@@ -139,28 +139,28 @@ GEM
|
|
139
139
|
rspec-support (3.9.2)
|
140
140
|
rspec_junit_formatter (0.4.1)
|
141
141
|
rspec-core (>= 2, < 4, != 2.12.0)
|
142
|
-
rubocop (0.
|
142
|
+
rubocop (0.82.0)
|
143
143
|
jaro_winkler (~> 1.5.1)
|
144
144
|
parallel (~> 1.10)
|
145
145
|
parser (>= 2.7.0.1)
|
146
146
|
rainbow (>= 2.2.2, < 4.0)
|
147
147
|
rexml
|
148
148
|
ruby-progressbar (~> 1.7)
|
149
|
-
unicode-display_width (>= 1.4.0, <
|
149
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
150
150
|
rubocop-performance (1.5.2)
|
151
151
|
rubocop (>= 0.71.0)
|
152
152
|
ruby-progressbar (1.10.1)
|
153
153
|
ruby_parser (3.14.2)
|
154
154
|
sexp_processor (~> 4.9)
|
155
|
-
rugged (0.
|
155
|
+
rugged (0.99.0)
|
156
156
|
sawyer (0.8.2)
|
157
157
|
addressable (>= 2.3.5)
|
158
158
|
faraday (> 0.8, < 2.0)
|
159
159
|
sexp_processor (4.14.1)
|
160
|
-
simplecov (0.18.
|
160
|
+
simplecov (0.18.5)
|
161
161
|
docile (~> 1.1)
|
162
162
|
simplecov-html (~> 0.11)
|
163
|
-
simplecov-html (0.12.
|
163
|
+
simplecov-html (0.12.2)
|
164
164
|
simplecov-rcov (0.2.3)
|
165
165
|
simplecov (>= 0.4.1)
|
166
166
|
terminal-table (1.8.0)
|
@@ -170,7 +170,7 @@ GEM
|
|
170
170
|
timecop (0.9.1)
|
171
171
|
tzinfo (1.2.6)
|
172
172
|
thread_safe (~> 0.1)
|
173
|
-
unicode-display_width (1.
|
173
|
+
unicode-display_width (1.7.0)
|
174
174
|
url (0.3.2)
|
175
175
|
virtus (1.0.5)
|
176
176
|
axiom-types (~> 0.1)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActsAsTaggableOnMongoid
|
4
|
+
module Models
|
5
|
+
module Concerns
|
6
|
+
# Update and Destroy hooks for tags to update denormalized data.
|
7
|
+
#
|
8
|
+
# NOTE: If the tag is cached AND owned, assumptions are made about the
|
9
|
+
# relationship of a Tag to the Taggings and the taggable_type.
|
10
|
+
#
|
11
|
+
# Specifically, the taggable_type is assumed to have an ID field that
|
12
|
+
# matches the owner. This field can be specified in the tag_definition
|
13
|
+
# as owner_id_field.
|
14
|
+
#
|
15
|
+
# If there isn't a simple relationship like this then override the following
|
16
|
+
# methods to update the cached data properly:
|
17
|
+
# * remove_cached_taggings
|
18
|
+
# * update_cached_taggings
|
19
|
+
module TagHooks
|
20
|
+
extend ActiveSupport::Concern
|
21
|
+
|
22
|
+
included do
|
23
|
+
after_update :denormalize_tag_name
|
24
|
+
after_destroy :remove_cached_taggings
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def denormalize_tag_name
|
30
|
+
return unless name_changed?
|
31
|
+
|
32
|
+
update_taggings
|
33
|
+
update_cached_taggings
|
34
|
+
end
|
35
|
+
|
36
|
+
def update_taggings
|
37
|
+
taggings.update_all(tag_name: name)
|
38
|
+
end
|
39
|
+
|
40
|
+
def remove_cached_taggings
|
41
|
+
return if tag_definition.blank?
|
42
|
+
return unless tag_definition.cached_in_model?
|
43
|
+
|
44
|
+
cached_fields_query(name).update_all("$pull" => { "cached_#{tag_definition.tag_list_name}" => name })
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_cached_taggings
|
48
|
+
return if tag_definition.blank?
|
49
|
+
return unless tag_definition.cached_in_model?
|
50
|
+
|
51
|
+
cached_fields_query(name_was).update_all("$set" => { "cached_#{tag_definition.tag_list_name}.$" => name })
|
52
|
+
end
|
53
|
+
|
54
|
+
def cached_fields_query(chached_field_value)
|
55
|
+
query = { "cached_#{tag_definition.tag_list_name}" => chached_field_value }
|
56
|
+
|
57
|
+
if owner_id.present?
|
58
|
+
id_field = tag_definition.owner_id_field || "#{owner_type.underscore}_id"
|
59
|
+
|
60
|
+
query[id_field] = owner_id
|
61
|
+
end
|
62
|
+
|
63
|
+
taggable_type.constantize.unscoped.where(query)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -22,19 +22,17 @@ module ActsAsTaggableOnMongoid
|
|
22
22
|
return [] if list.empty?
|
23
23
|
|
24
24
|
list.map do |tag_name|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
retry
|
33
|
-
end
|
34
|
-
|
35
|
-
raise ActsAsTaggableOnMongoid::Errors::DuplicateTagError.new, "'#{tag_name}' has already been taken"
|
36
|
-
# :nocov:
|
25
|
+
tries ||= 3
|
26
|
+
|
27
|
+
find_or_create_tag(tag_name, tag_definition, owner)
|
28
|
+
rescue Mongoid::Errors::Validations
|
29
|
+
# :nocov:
|
30
|
+
if (tries -= 1).positive?
|
31
|
+
retry
|
37
32
|
end
|
33
|
+
|
34
|
+
raise ActsAsTaggableOnMongoid::Errors::DuplicateTagError.new, "'#{tag_name}' has already been taken"
|
35
|
+
# :nocov:
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
@@ -52,8 +50,6 @@ module ActsAsTaggableOnMongoid
|
|
52
50
|
string.mb_chars
|
53
51
|
end
|
54
52
|
|
55
|
-
private
|
56
|
-
|
57
53
|
def find_or_create_tag(tag_name, tag_definition, owner)
|
58
54
|
existing_tag = tag_definition.tags_table.for_tag(tag_definition).named(tag_name).owned_by(owner).first
|
59
55
|
|
@@ -75,6 +71,12 @@ module ActsAsTaggableOnMongoid
|
|
75
71
|
def to_s
|
76
72
|
name
|
77
73
|
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def tag_definition
|
78
|
+
@tag_definition ||= taggable_type.constantize.tag_types[context]
|
79
|
+
end
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -12,6 +12,7 @@ module ActsAsTaggableOnMongoid
|
|
12
12
|
include ActsAsTaggableOnMongoid::Models::Concerns::TagAssociations
|
13
13
|
include ActsAsTaggableOnMongoid::Models::Concerns::TagValidations
|
14
14
|
include ActsAsTaggableOnMongoid::Models::Concerns::TagScopes
|
15
|
+
include ActsAsTaggableOnMongoid::Models::Concerns::TagHooks
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -23,6 +23,9 @@ module ActsAsTaggableOnMongoid
|
|
23
23
|
# as_list: true/false - If the cached value should be an Array or a String. No order is guaranteed
|
24
24
|
# in either case.
|
25
25
|
# Defaults to true.
|
26
|
+
# * owner_id_field
|
27
|
+
# If cached_in_model is true, if a tag is owned, this is the field that will be checked for a matching
|
28
|
+
# owner ID for tag updates and deletes.
|
26
29
|
# * force_lowercase
|
27
30
|
# If true, values stored for tags will first be downcased to make the values effectively case-insensitive
|
28
31
|
# * force_parameterize
|
@@ -37,6 +37,7 @@ module ActsAsTaggableOnMongoid
|
|
37
37
|
cached_in_model
|
38
38
|
force_lowercase
|
39
39
|
force_parameterize
|
40
|
+
owner_id_field
|
40
41
|
remove_unused_tags
|
41
42
|
tags_table
|
42
43
|
taggings_table].each_with_object({}) { |dup_key, opts_hash| opts_hash[dup_key] = tag_definition.public_send(dup_key) }
|
@@ -189,6 +190,7 @@ module ActsAsTaggableOnMongoid
|
|
189
190
|
:cached_in_model,
|
190
191
|
:force_lowercase,
|
191
192
|
:force_parameterize,
|
193
|
+
:owner_id_field,
|
192
194
|
:remove_unused_tags,
|
193
195
|
:tags_table,
|
194
196
|
:taggings_table,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-on-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.1.
|
4
|
+
version: 6.1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -334,6 +334,7 @@ files:
|
|
334
334
|
- lib/acts_as_taggable_on_mongoid/generic_parser.rb
|
335
335
|
- lib/acts_as_taggable_on_mongoid/models/concerns/tag_associations.rb
|
336
336
|
- lib/acts_as_taggable_on_mongoid/models/concerns/tag_fields.rb
|
337
|
+
- lib/acts_as_taggable_on_mongoid/models/concerns/tag_hooks.rb
|
337
338
|
- lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb
|
338
339
|
- lib/acts_as_taggable_on_mongoid/models/concerns/tag_migration.rb
|
339
340
|
- lib/acts_as_taggable_on_mongoid/models/concerns/tag_model.rb
|
@@ -391,7 +392,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
391
392
|
- !ruby/object:Gem::Version
|
392
393
|
version: '0'
|
393
394
|
requirements: []
|
394
|
-
rubygems_version: 3.
|
395
|
+
rubygems_version: 3.1.2
|
395
396
|
signing_key:
|
396
397
|
specification_version: 4
|
397
398
|
summary: A partial mongoid implementation of tagging based on/inspired by acts-as-taggable-on.
|