acts-as-taggable-on-mongoid 6.1.1.7 → 6.1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/Gemfile.lock +10 -8
- data/README.md +1 -0
- data/lib/acts-as-taggable-on-mongoid.rb +1 -1
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_associations.rb +5 -1
- data/lib/acts_as_taggable_on_mongoid/taggable.rb +6 -2
- data/lib/acts_as_taggable_on_mongoid/taggable/cache.rb +30 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/core.rb +2 -1
- data/lib/acts_as_taggable_on_mongoid/taggable/list_tags.rb +1 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition.rb +12 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/attributes.rb +12 -0
- data/lib/acts_as_taggable_on_mongoid/tagger_tag_list.rb +1 -1
- data/lib/acts_as_taggable_on_mongoid/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 923975d7d231581699ec0944f7482b0b80b66071bbf042f5ef8264dd70e6f2f9
|
4
|
+
data.tar.gz: 8220f30f3cc1901e0a7d2d8182b28c6cf9f7b7175e7ddddb3ee9cef52dd6cf77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8115eb367985f2609847c95a54285a03d488f77eb5bbe390104539c7aec5fa68dc7530776371a888be68283cc77d0443ec01a0c7378532c5f73edee783ba93d1
|
7
|
+
data.tar.gz: 024c2fd74c764ab2658e1b77df1d375721c67d47fd212c4390b1494c601fe8b04cc8dd5fff65ebbe8ff7acd67572897fc3c4ab714e3122dd8cfeca24457ff66c
|
data/.rubocop.yml
CHANGED
@@ -13,6 +13,15 @@ AllCops:
|
|
13
13
|
- 'node_modules/**/*'
|
14
14
|
UseCache: false
|
15
15
|
|
16
|
+
Style/HashEachMethods:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Style/HashTransformKeys:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Style/HashTransformValues:
|
23
|
+
Enabled: true
|
24
|
+
|
16
25
|
Style/CollectionMethods:
|
17
26
|
Description: Preferred collection methods.
|
18
27
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
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.8)
|
5
5
|
activesupport (>= 5.0)
|
6
6
|
mongoid (>= 6.1.1, <= 7.0.2)
|
7
7
|
|
@@ -22,7 +22,7 @@ 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.
|
25
|
+
brakeman (4.8.0)
|
26
26
|
bson (4.7.1)
|
27
27
|
code_analyzer (0.5.1)
|
28
28
|
sexp_processor
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
gitlab (4.13.1)
|
55
55
|
httparty (~> 0.14, >= 0.14.0)
|
56
56
|
terminal-table (~> 1.5, >= 1.5.1)
|
57
|
-
httparty (0.
|
57
|
+
httparty (0.18.0)
|
58
58
|
mime-types (~> 3.0)
|
59
59
|
multi_xml (>= 0.5.2)
|
60
60
|
i18n (0.9.5)
|
@@ -123,6 +123,7 @@ GEM
|
|
123
123
|
psych (~> 3.1.0)
|
124
124
|
rainbow (>= 2.0, < 4.0)
|
125
125
|
require_all (3.0.0)
|
126
|
+
rexml (3.2.4)
|
126
127
|
rspec (3.9.0)
|
127
128
|
rspec-core (~> 3.9.0)
|
128
129
|
rspec-expectations (~> 3.9.0)
|
@@ -138,11 +139,12 @@ GEM
|
|
138
139
|
rspec-support (3.9.2)
|
139
140
|
rspec_junit_formatter (0.4.1)
|
140
141
|
rspec-core (>= 2, < 4, != 2.12.0)
|
141
|
-
rubocop (0.
|
142
|
+
rubocop (0.80.0)
|
142
143
|
jaro_winkler (~> 1.5.1)
|
143
144
|
parallel (~> 1.10)
|
144
|
-
parser (>= 2.
|
145
|
+
parser (>= 2.7.0.1)
|
145
146
|
rainbow (>= 2.2.2, < 4.0)
|
147
|
+
rexml
|
146
148
|
ruby-progressbar (~> 1.7)
|
147
149
|
unicode-display_width (>= 1.4.0, < 1.7)
|
148
150
|
rubocop-performance (1.5.2)
|
@@ -155,10 +157,10 @@ GEM
|
|
155
157
|
addressable (>= 2.3.5)
|
156
158
|
faraday (> 0.8, < 2.0)
|
157
159
|
sexp_processor (4.14.1)
|
158
|
-
simplecov (0.18.
|
160
|
+
simplecov (0.18.2)
|
159
161
|
docile (~> 1.1)
|
160
|
-
simplecov-html (~> 0.11
|
161
|
-
simplecov-html (0.
|
162
|
+
simplecov-html (~> 0.11)
|
163
|
+
simplecov-html (0.12.0)
|
162
164
|
simplecov-rcov (0.2.3)
|
163
165
|
simplecov (>= 0.4.1)
|
164
166
|
terminal-table (1.8.0)
|
data/README.md
CHANGED
@@ -11,7 +11,11 @@ module ActsAsTaggableOnMongoid
|
|
11
11
|
|
12
12
|
belongs_to :tag, counter_cache: true, inverse_of: :taggings
|
13
13
|
belongs_to :tagger, polymorphic: true, optional: true
|
14
|
-
|
14
|
+
|
15
|
+
# Tags and Taggings are created in an after_save event on taggable.
|
16
|
+
# If autosave is not false, then this will cause the taggable object
|
17
|
+
# to be saved AGAIN, that could cause a number of unwanted side-effects.
|
18
|
+
belongs_to :taggable, polymorphic: true, autosave: false
|
15
19
|
|
16
20
|
before_validation :atom_unset_blank_owner
|
17
21
|
end
|
@@ -18,7 +18,11 @@ module ActsAsTaggableOnMongoid
|
|
18
18
|
# * preserve_tag_order
|
19
19
|
# If true, the _list accessor will save and returns tags in the order they are added to the object.
|
20
20
|
# * cached_in_model
|
21
|
-
#
|
21
|
+
# If true, a field is added to de-normalize/cache the list into. Can also be a hash with options:
|
22
|
+
# field: The name of the field to cache the list in
|
23
|
+
# as_list: true/false - If the cached value should be an Array or a String. No order is guaranteed
|
24
|
+
# in either case.
|
25
|
+
# Defaults to true.
|
22
26
|
# * force_lowercase
|
23
27
|
# If true, values stored for tags will first be downcased to make the values effectively case-insensitive
|
24
28
|
# * force_parameterize
|
@@ -122,7 +126,7 @@ module ActsAsTaggableOnMongoid
|
|
122
126
|
ActsAsTaggableOnMongoid::Taggable::Changeable,
|
123
127
|
ActsAsTaggableOnMongoid::Taggable::TaggedWith,
|
124
128
|
# include Collection - not sure we will need as done here. Need to think more on this one.
|
125
|
-
|
129
|
+
ActsAsTaggableOnMongoid::Taggable::Cache,
|
126
130
|
# include Related - TODO: Add this.
|
127
131
|
ActsAsTaggableOnMongoid::Taggable::TaggerRelation,
|
128
132
|
ActsAsTaggableOnMongoid::Taggable::ListTags].each do |include_module|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActsAsTaggableOnMongoid
|
4
|
+
module Taggable
|
5
|
+
# A collection of generic methods which use the tag definition to perform actions.
|
6
|
+
#
|
7
|
+
# These methods are called by the individual tag generated methods to do their work so that
|
8
|
+
# the code can be defined in only one location and "shared" by all tags rather than putting the code
|
9
|
+
# and definitions into the dynamically defined methods directly.
|
10
|
+
#
|
11
|
+
# This module actually consists almost exclusively of utility functions
|
12
|
+
|
13
|
+
# :reek:FeatureEnvy
|
14
|
+
# :reek:UtilityFunction
|
15
|
+
module Cache
|
16
|
+
def save_cached_tag_lists
|
17
|
+
tag_types.each_value do |tag_definition|
|
18
|
+
next unless tag_definition.cached_in_model?
|
19
|
+
next unless tag_list_cache_set_on(tag_definition)
|
20
|
+
|
21
|
+
list = all_tags_list_on(tag_definition)
|
22
|
+
|
23
|
+
list = list.to_s unless tag_definition.cached_in_model_as_list?
|
24
|
+
|
25
|
+
public_send("#{tag_definition.cached_in_model_field}=", list)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -22,6 +22,7 @@ module ActsAsTaggableOnMongoid
|
|
22
22
|
# attr_writer :custom_contexts
|
23
23
|
|
24
24
|
after_save :save_tags
|
25
|
+
before_save :save_cached_tag_lists
|
25
26
|
end
|
26
27
|
|
27
28
|
class_methods do
|
@@ -171,7 +172,7 @@ module ActsAsTaggableOnMongoid
|
|
171
172
|
end
|
172
173
|
|
173
174
|
def all_tags_list_on(tag_definition)
|
174
|
-
|
175
|
+
tag_list_cache_on(tag_definition).flatten
|
175
176
|
end
|
176
177
|
|
177
178
|
##
|
@@ -58,6 +58,7 @@ module ActsAsTaggableOnMongoid
|
|
58
58
|
self.my_tag_types = new_tag_types
|
59
59
|
tag_definition = new_tag_types[tag_type] = ActsAsTaggableOnMongoid::Taggable::TagTypeDefinition.new(self, tag_type, options)
|
60
60
|
|
61
|
+
tag_definition.define_cache_field
|
61
62
|
tag_definition.define_base_relations
|
62
63
|
tag_definition.define_relations
|
63
64
|
tag_definition.add_tag_list
|
@@ -76,6 +76,18 @@ module ActsAsTaggableOnMongoid
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
def define_cache_field
|
80
|
+
tag_definition = self
|
81
|
+
|
82
|
+
return unless tag_definition.cached_in_model?
|
83
|
+
|
84
|
+
owner.class_eval do
|
85
|
+
field_type = tag_definition.cached_in_model_as_list? ? Array : String
|
86
|
+
|
87
|
+
field tag_definition.cached_in_model_field, type: field_type
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
79
91
|
def define_base_relations
|
80
92
|
tag_definition = self
|
81
93
|
|
@@ -52,6 +52,14 @@ module ActsAsTaggableOnMongoid
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
def cached_in_model_field
|
56
|
+
@cached_in_model_field ||= cache_hash.fetch(:field) { "cached_#{tag_list_name}" }
|
57
|
+
end
|
58
|
+
|
59
|
+
def cached_in_model_as_list?
|
60
|
+
@cached_in_model_as_list ||= cache_hash.fetch(:as_list) { true }
|
61
|
+
end
|
62
|
+
|
55
63
|
alias preserve_tag_order? preserve_tag_order
|
56
64
|
alias cached_in_model? cached_in_model
|
57
65
|
alias force_lowercase? force_lowercase
|
@@ -103,6 +111,10 @@ module ActsAsTaggableOnMongoid
|
|
103
111
|
|
104
112
|
private
|
105
113
|
|
114
|
+
def cache_hash
|
115
|
+
@cache_hash ||= cached_in_model.is_a?(Hash) ? cached_in_model : {}
|
116
|
+
end
|
117
|
+
|
106
118
|
def tagger_params
|
107
119
|
return @tagger_params if defined?(@tagger_params)
|
108
120
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -350,6 +350,7 @@ files:
|
|
350
350
|
- lib/acts_as_taggable_on_mongoid/models/tagging.rb
|
351
351
|
- lib/acts_as_taggable_on_mongoid/tag_list.rb
|
352
352
|
- lib/acts_as_taggable_on_mongoid/taggable.rb
|
353
|
+
- lib/acts_as_taggable_on_mongoid/taggable/cache.rb
|
353
354
|
- lib/acts_as_taggable_on_mongoid/taggable/changeable.rb
|
354
355
|
- lib/acts_as_taggable_on_mongoid/taggable/core.rb
|
355
356
|
- lib/acts_as_taggable_on_mongoid/taggable/list_tags.rb
|