acts-as-taggable-on-mongoid 6.0.1.5 → 6.1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -1
- data/.rubocop.yml +8 -10
- data/.ruby-version +1 -1
- data/Gemfile.lock +76 -82
- data/README.md +102 -28
- data/acts-as-taggable-on-mongoid.gemspec +3 -4
- data/lib/acts-as-taggable-on-mongoid.rb +9 -3
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_associations.rb +12 -0
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_fields.rb +4 -1
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_methods.rb +21 -12
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_migration.rb +46 -0
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_scopes.rb +3 -2
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tag_validations.rb +1 -1
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_associations.rb +13 -1
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_fields.rb +4 -2
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_methods.rb +2 -2
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_migration.rb +46 -0
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_scopes.rb +7 -5
- data/lib/acts_as_taggable_on_mongoid/models/concerns/tagging_validations.rb +2 -6
- data/lib/acts_as_taggable_on_mongoid/tag_list.rb +91 -4
- data/lib/acts_as_taggable_on_mongoid/taggable.rb +13 -1
- data/lib/acts_as_taggable_on_mongoid/taggable/changeable.rb +5 -4
- data/lib/acts_as_taggable_on_mongoid/taggable/core.rb +156 -34
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition.rb +29 -50
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/attributes.rb +57 -6
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/changeable.rb +52 -39
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/list_methods.rb +77 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/tag_type_definition/names.rb +12 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/all_tags_query.rb +1 -1
- data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/any_tags_query.rb +1 -1
- data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/exclude_tags_query.rb +1 -1
- data/lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/match_all_tags_query.rb +1 -1
- data/lib/acts_as_taggable_on_mongoid/taggable/tagger_relation.rb +53 -0
- data/lib/acts_as_taggable_on_mongoid/taggable/utils/tag_list_diff.rb +9 -7
- data/lib/acts_as_taggable_on_mongoid/tagger.rb +67 -0
- data/lib/acts_as_taggable_on_mongoid/tagger/tag_methods.rb +74 -0
- data/lib/acts_as_taggable_on_mongoid/tagger_tag_list.rb +171 -0
- data/lib/acts_as_taggable_on_mongoid/version.rb +1 -1
- metadata +18 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3389918de3bd83bfcc3ac3f82d9413d5a0f8ec076b8ae83c226d0787dd96158
|
4
|
+
data.tar.gz: a2e731e6cf8b57d91697d3feb0fc61acca0073bbda5ef41452768bb42ffb7f57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a21b7c8cb425ce8a839411cf2bd5db8985bacf7d16b527c0f5fcc58431af787603928aa14a4c5ae9dd200836756188242b908173b69293067c4b3db1906aef4
|
7
|
+
data.tar.gz: 67918b704a7b3cdeb1c200e883e806b12562e7724daa1f67a8ebeee2ce3452339e9b84c7de5916b9715193b6496be82b802598b073f35ce8d3ef4ba0d6981d24
|
data/.circleci/config.yml
CHANGED
@@ -7,7 +7,7 @@ jobs:
|
|
7
7
|
build:
|
8
8
|
docker:
|
9
9
|
# specify the version you desire here
|
10
|
-
- image: circleci/ruby:2.
|
10
|
+
- image: circleci/ruby:2.6.3-stretch
|
11
11
|
environment:
|
12
12
|
PRONTO_GITHUB_ACCESS_TOKEN: testing
|
13
13
|
- image: mongo:3.6.7-jessie
|
@@ -33,6 +33,7 @@ jobs:
|
|
33
33
|
- run:
|
34
34
|
name: install dependencies
|
35
35
|
command: |
|
36
|
+
gem install bundler
|
36
37
|
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
37
38
|
|
38
39
|
- save_cache:
|
data/.rubocop.yml
CHANGED
@@ -57,8 +57,6 @@ Naming/PredicateName:
|
|
57
57
|
- is_
|
58
58
|
- has_
|
59
59
|
- have_
|
60
|
-
NamePrefixBlacklist:
|
61
|
-
- is_
|
62
60
|
Naming/RescuedExceptionsVariableName:
|
63
61
|
PreferredName: error
|
64
62
|
|
@@ -204,7 +202,7 @@ Lint/AssignmentInCondition:
|
|
204
202
|
AllowSafeAssignment: true
|
205
203
|
Lint/DisjunctiveAssignmentInConstructor:
|
206
204
|
Enabled: false
|
207
|
-
Layout/
|
205
|
+
Layout/ParameterAlignment:
|
208
206
|
Description: Align the parameters of a method call if they span more than one line.
|
209
207
|
Enabled: true
|
210
208
|
EnforcedStyle: with_first_parameter
|
@@ -262,14 +260,14 @@ Style/WhenThen:
|
|
262
260
|
Description: Use when x then ... for one-line cases.
|
263
261
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
264
262
|
Enabled: false
|
265
|
-
Layout/
|
263
|
+
Layout/TrailingEmptyLines:
|
266
264
|
Description: 'Checks trailing blank lines and final newline.'
|
267
265
|
StyleGuide: '#newline-eof'
|
268
266
|
Enabled: false
|
269
267
|
Lint/EachWithObjectArgument:
|
270
268
|
Description: Check for immutable argument given to each_with_object.
|
271
269
|
Enabled: true
|
272
|
-
Lint/
|
270
|
+
Lint/SuppressedException:
|
273
271
|
Description: Don't suppress exception.
|
274
272
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
275
273
|
Enabled: true
|
@@ -308,7 +306,7 @@ Layout/MultilineOperationIndentation:
|
|
308
306
|
EnforcedStyle: indented
|
309
307
|
IndentationWidth: 4
|
310
308
|
Enabled: false
|
311
|
-
|
309
|
+
Layout/LineLength:
|
312
310
|
Max: 150
|
313
311
|
Metrics/BlockLength:
|
314
312
|
Exclude:
|
@@ -318,16 +316,16 @@ Metrics/BlockLength:
|
|
318
316
|
Layout/CaseIndentation:
|
319
317
|
EnforcedStyle: case
|
320
318
|
IndentOneStep: true
|
321
|
-
Layout/
|
319
|
+
Layout/FirstArrayElementIndentation:
|
322
320
|
IndentationWidth: 4
|
323
|
-
Layout/
|
321
|
+
Layout/FirstHashElementIndentation:
|
324
322
|
IndentationWidth: 4
|
325
|
-
Layout/
|
323
|
+
Layout/FirstArgumentIndentation:
|
326
324
|
IndentationWidth: 4
|
327
325
|
Style/FrozenStringLiteralComment:
|
328
326
|
Enabled: true
|
329
327
|
|
330
|
-
Layout/
|
328
|
+
Layout/HashAlignment:
|
331
329
|
Description: >-
|
332
330
|
Align the elements of a hash literal if they span more than
|
333
331
|
one line.
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.3
|
data/Gemfile.lock
CHANGED
@@ -1,88 +1,84 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acts-as-taggable-on-mongoid (6.
|
5
|
-
activesupport (
|
6
|
-
mongoid (>=
|
4
|
+
acts-as-taggable-on-mongoid (6.1.1.7)
|
5
|
+
activesupport (>= 5.0)
|
6
|
+
mongoid (>= 6.1.1, <= 7.0.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (
|
12
|
-
activesupport (=
|
13
|
-
|
14
|
-
|
11
|
+
activemodel (5.0.0)
|
12
|
+
activesupport (= 5.0.0)
|
13
|
+
activesupport (5.0.0)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (~> 0.7)
|
16
16
|
minitest (~> 5.1)
|
17
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
18
17
|
tzinfo (~> 1.1)
|
19
|
-
addressable (2.
|
20
|
-
public_suffix (>= 2.0.2, <
|
18
|
+
addressable (2.7.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
21
20
|
ast (2.4.0)
|
22
21
|
axiom-types (0.1.1)
|
23
22
|
descendants_tracker (~> 0.0.4)
|
24
23
|
ice_nine (~> 0.11.0)
|
25
24
|
thread_safe (~> 0.3, >= 0.3.1)
|
26
|
-
brakeman (4.
|
27
|
-
bson (4.
|
28
|
-
|
29
|
-
code_analyzer (0.4.8)
|
25
|
+
brakeman (4.7.2)
|
26
|
+
bson (4.7.1)
|
27
|
+
code_analyzer (0.5.1)
|
30
28
|
sexp_processor
|
31
29
|
codeclimate-engine-rb (0.4.1)
|
32
30
|
virtus (~> 1.0)
|
33
|
-
codecov (0.1.
|
31
|
+
codecov (0.1.16)
|
34
32
|
json
|
35
33
|
simplecov
|
36
34
|
url
|
37
35
|
coercible (1.0.0)
|
38
36
|
descendants_tracker (~> 0.0.1)
|
39
37
|
colorize (0.8.1)
|
40
|
-
concurrent-ruby (1.1.
|
41
|
-
cornucopia (0.1.
|
42
|
-
activesupport (<
|
43
|
-
database_cleaner (1.
|
38
|
+
concurrent-ruby (1.1.6)
|
39
|
+
cornucopia (0.1.56)
|
40
|
+
activesupport (> 4.0, < 6.0)
|
41
|
+
database_cleaner (1.8.2)
|
44
42
|
descendants_tracker (0.0.4)
|
45
43
|
thread_safe (~> 0.3, >= 0.3.1)
|
46
44
|
diff-lcs (1.3)
|
47
|
-
docile (1.3.
|
45
|
+
docile (1.3.2)
|
48
46
|
equalizer (0.0.11)
|
49
47
|
erubis (2.7.0)
|
50
|
-
faraday (0.
|
48
|
+
faraday (1.0.0)
|
51
49
|
multipart-post (>= 1.2, < 3)
|
52
|
-
fasterer (0.
|
50
|
+
fasterer (0.8.2)
|
53
51
|
colorize (~> 0.7)
|
54
|
-
ruby_parser (>= 3.
|
55
|
-
gem-release (2.
|
56
|
-
gitlab (4.
|
52
|
+
ruby_parser (>= 3.14.1)
|
53
|
+
gem-release (2.1.1)
|
54
|
+
gitlab (4.13.1)
|
57
55
|
httparty (~> 0.14, >= 0.14.0)
|
58
56
|
terminal-table (~> 1.5, >= 1.5.1)
|
59
|
-
httparty (0.17.
|
57
|
+
httparty (0.17.3)
|
60
58
|
mime-types (~> 3.0)
|
61
59
|
multi_xml (>= 0.5.2)
|
62
60
|
i18n (0.9.5)
|
63
61
|
concurrent-ruby (~> 1.0)
|
64
62
|
ice_nine (0.11.2)
|
65
|
-
jaro_winkler (1.5.
|
66
|
-
json (2.
|
63
|
+
jaro_winkler (1.5.4)
|
64
|
+
json (2.3.0)
|
67
65
|
kwalify (0.7.2)
|
68
|
-
mime-types (3.
|
66
|
+
mime-types (3.3.1)
|
69
67
|
mime-types-data (~> 3.2015)
|
70
|
-
mime-types-data (3.2019.
|
71
|
-
minitest (5.
|
72
|
-
mongo (2.
|
68
|
+
mime-types-data (3.2019.1009)
|
69
|
+
minitest (5.14.0)
|
70
|
+
mongo (2.11.3)
|
73
71
|
bson (>= 4.4.2, < 5.0.0)
|
74
|
-
mongoid (
|
75
|
-
activemodel (~>
|
76
|
-
mongo (>= 2.
|
77
|
-
origin (~> 2.3)
|
78
|
-
tzinfo (>= 0.3.37)
|
72
|
+
mongoid (6.1.1)
|
73
|
+
activemodel (~> 5.0)
|
74
|
+
mongo (>= 2.4.1, < 3.0.0)
|
79
75
|
multi_xml (0.6.0)
|
80
|
-
multipart-post (2.
|
81
|
-
octokit (4.
|
76
|
+
multipart-post (2.1.1)
|
77
|
+
octokit (4.16.0)
|
78
|
+
faraday (>= 0.9)
|
82
79
|
sawyer (~> 0.8.0, >= 0.5.3)
|
83
|
-
|
84
|
-
|
85
|
-
parser (2.6.3.0)
|
80
|
+
parallel (1.19.1)
|
81
|
+
parser (2.7.0.2)
|
86
82
|
ast (~> 2.4.0)
|
87
83
|
pronto (0.10.0)
|
88
84
|
gitlab (~> 4.0, >= 4.0.0)
|
@@ -109,61 +105,60 @@ GEM
|
|
109
105
|
pronto (~> 0.10.0)
|
110
106
|
rubocop (~> 0.50, >= 0.49.1)
|
111
107
|
psych (3.1.0)
|
112
|
-
public_suffix (
|
113
|
-
rails_best_practices (1.19.
|
108
|
+
public_suffix (4.0.3)
|
109
|
+
rails_best_practices (1.19.5)
|
114
110
|
activesupport
|
115
|
-
code_analyzer (>= 0.
|
111
|
+
code_analyzer (>= 0.5.1)
|
116
112
|
erubis
|
117
113
|
i18n
|
118
114
|
json
|
119
|
-
require_all (~>
|
115
|
+
require_all (~> 3.0)
|
120
116
|
ruby-progressbar
|
121
117
|
rainbow (3.0.0)
|
122
|
-
rake (
|
123
|
-
reek (5.
|
118
|
+
rake (13.0.1)
|
119
|
+
reek (5.6.0)
|
124
120
|
codeclimate-engine-rb (~> 0.4.0)
|
125
121
|
kwalify (~> 0.7.0)
|
126
|
-
parser (>= 2.5.0.0, < 2.
|
122
|
+
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
127
123
|
psych (~> 3.1.0)
|
128
124
|
rainbow (>= 2.0, < 4.0)
|
129
|
-
require_all (
|
130
|
-
rspec (3.
|
131
|
-
rspec-core (~> 3.
|
132
|
-
rspec-expectations (~> 3.
|
133
|
-
rspec-mocks (~> 3.
|
134
|
-
rspec-core (3.
|
135
|
-
rspec-support (~> 3.
|
136
|
-
rspec-expectations (3.
|
125
|
+
require_all (3.0.0)
|
126
|
+
rspec (3.9.0)
|
127
|
+
rspec-core (~> 3.9.0)
|
128
|
+
rspec-expectations (~> 3.9.0)
|
129
|
+
rspec-mocks (~> 3.9.0)
|
130
|
+
rspec-core (3.9.1)
|
131
|
+
rspec-support (~> 3.9.1)
|
132
|
+
rspec-expectations (3.9.0)
|
137
133
|
diff-lcs (>= 1.2.0, < 2.0)
|
138
|
-
rspec-support (~> 3.
|
139
|
-
rspec-mocks (3.
|
134
|
+
rspec-support (~> 3.9.0)
|
135
|
+
rspec-mocks (3.9.1)
|
140
136
|
diff-lcs (>= 1.2.0, < 2.0)
|
141
|
-
rspec-support (~> 3.
|
142
|
-
rspec-support (3.
|
137
|
+
rspec-support (~> 3.9.0)
|
138
|
+
rspec-support (3.9.2)
|
143
139
|
rspec_junit_formatter (0.4.1)
|
144
140
|
rspec-core (>= 2, < 4, != 2.12.0)
|
145
|
-
rubocop (0.
|
141
|
+
rubocop (0.78.0)
|
146
142
|
jaro_winkler (~> 1.5.1)
|
147
143
|
parallel (~> 1.10)
|
148
|
-
parser (>= 2.
|
144
|
+
parser (>= 2.6)
|
149
145
|
rainbow (>= 2.2.2, < 4.0)
|
150
146
|
ruby-progressbar (~> 1.7)
|
151
|
-
unicode-display_width (>= 1.4.0, < 1.
|
152
|
-
rubocop-performance (1.2
|
153
|
-
rubocop (>= 0.
|
154
|
-
ruby-progressbar (1.10.
|
155
|
-
ruby_parser (3.
|
147
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
148
|
+
rubocop-performance (1.5.2)
|
149
|
+
rubocop (>= 0.71.0)
|
150
|
+
ruby-progressbar (1.10.1)
|
151
|
+
ruby_parser (3.14.2)
|
156
152
|
sexp_processor (~> 4.9)
|
157
|
-
rugged (0.28.1)
|
158
|
-
sawyer (0.8.
|
159
|
-
addressable (>= 2.3.5
|
160
|
-
faraday (
|
161
|
-
sexp_processor (4.
|
162
|
-
simplecov (0.
|
153
|
+
rugged (0.28.4.1)
|
154
|
+
sawyer (0.8.2)
|
155
|
+
addressable (>= 2.3.5)
|
156
|
+
faraday (> 0.8, < 2.0)
|
157
|
+
sexp_processor (4.14.1)
|
158
|
+
simplecov (0.18.1)
|
163
159
|
docile (~> 1.1)
|
164
|
-
|
165
|
-
|
166
|
-
simplecov-html (0.10.2)
|
160
|
+
simplecov-html (~> 0.11.0)
|
161
|
+
simplecov-html (0.11.0)
|
167
162
|
simplecov-rcov (0.2.3)
|
168
163
|
simplecov (>= 0.4.1)
|
169
164
|
terminal-table (1.8.0)
|
@@ -171,9 +166,9 @@ GEM
|
|
171
166
|
thor (0.20.3)
|
172
167
|
thread_safe (0.3.6)
|
173
168
|
timecop (0.9.1)
|
174
|
-
tzinfo (1.2.
|
169
|
+
tzinfo (1.2.6)
|
175
170
|
thread_safe (~> 0.1)
|
176
|
-
unicode-display_width (1.
|
171
|
+
unicode-display_width (1.6.1)
|
177
172
|
url (0.3.2)
|
178
173
|
virtus (1.0.5)
|
179
174
|
axiom-types (~> 0.1)
|
@@ -186,7 +181,6 @@ PLATFORMS
|
|
186
181
|
|
187
182
|
DEPENDENCIES
|
188
183
|
acts-as-taggable-on-mongoid!
|
189
|
-
bundler (~> 1.16)
|
190
184
|
codecov (~> 0.1.0, ~> 0.1)
|
191
185
|
cornucopia
|
192
186
|
database_cleaner
|
@@ -198,7 +192,7 @@ DEPENDENCIES
|
|
198
192
|
pronto-rails_best_practices
|
199
193
|
pronto-reek
|
200
194
|
pronto-rubocop
|
201
|
-
rake (~>
|
195
|
+
rake (~> 13.0)
|
202
196
|
rspec (~> 3.0)
|
203
197
|
rspec_junit_formatter (~> 0.4.1)
|
204
198
|
rubocop
|
@@ -208,4 +202,4 @@ DEPENDENCIES
|
|
208
202
|
timecop
|
209
203
|
|
210
204
|
BUNDLED WITH
|
211
|
-
1.
|
205
|
+
2.1.4
|
data/README.md
CHANGED
@@ -52,6 +52,13 @@ Or install it yourself as:
|
|
52
52
|
**NOTE**: Unlike the `ActsAsTaggableOn` gem, I group Tags by context. Tags with the same
|
53
53
|
name for different contexts keep separate counts and are considered different Tags.
|
54
54
|
It is simpler to combine Tags and their counts by name then it is to split them out.
|
55
|
+
* **Tagger** - A database object which is given credit for creating a Tagging. This
|
56
|
+
object is an external model from this gem. Tagger objects can be specified
|
57
|
+
as being a Tagger using the `acts_as_tagger` method which allows a
|
58
|
+
Tagger object to `tag` Taggable objects.
|
59
|
+
* **Owner** - A database object which is given ownership of a Tag object.
|
60
|
+
This object is an external model from this gem. By default when Tags
|
61
|
+
are created, the owner of a Tag is the same as the Tagger for the Tagging.
|
55
62
|
|
56
63
|
The database structure is:
|
57
64
|
```
|
@@ -559,7 +566,7 @@ ActsAsTaggableOnMongoid.default_parser = MyParser
|
|
559
566
|
@user.tag_list # => ["east", "south"]
|
560
567
|
```
|
561
568
|
|
562
|
-
###
|
569
|
+
### Tag Ownership
|
563
570
|
|
564
571
|
Tags can have owners:
|
565
572
|
|
@@ -577,45 +584,97 @@ end
|
|
577
584
|
@some_user.owned_tags
|
578
585
|
Photo.tagged_with("paris", :on => :locations, :owned_by => @some_user)
|
579
586
|
@some_photo.locations_from(@some_user) # => ["paris", "normandy"]
|
580
|
-
@some_photo.
|
581
|
-
@some_photo.
|
587
|
+
@some_photo.tagger_location_lists[@some_user] # => [#<ActsAsTaggableOnMongoid::Models::Tag id: 1, name: "paris">...]
|
588
|
+
@some_photo.tagger_location_lists[nil] # => Ownerships equivalent to saying @some_photo.locations
|
582
589
|
@some_user.tag(@some_photo, :with => "paris, normandy", :on => :locations, :skip_save => true) #won't save @some_photo object
|
583
590
|
```
|
584
591
|
|
585
592
|
#### Working with Owned Tags
|
586
|
-
Note that `tag_list` only returns tags whose taggings do not
|
593
|
+
Note that by default `tag_list` only returns tags whose taggings do not
|
594
|
+
have an owner. Continuing from the above example:
|
587
595
|
```ruby
|
588
596
|
@some_photo.tag_list # => []
|
589
597
|
```
|
590
|
-
To retrieve all tags of an object (regardless of ownership) or if only
|
598
|
+
To retrieve all tags of an object (regardless of ownership) or if only
|
599
|
+
one owner can tag the object, you can use `all_tags_list`.
|
591
600
|
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
601
|
+
Tags are stored in a Hash grouped by `Tagger`. You can access this list
|
602
|
+
using `tagger_<tag_type>_lists`. This allows you to directly access and
|
603
|
+
use the `TagList` for any owner just like you would the `<tag_type>_list`
|
604
|
+
methods.
|
605
|
+
|
606
|
+
Examples:
|
596
607
|
```ruby
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
608
|
+
tag_lists = @some_photo.tagger_location_lists
|
609
|
+
tag_lists.keys # => [@some_user]
|
610
|
+
|
611
|
+
# Add tags for @some_user
|
612
|
+
tag_lists[@some_user].add "berlin, london", parse: true
|
613
|
+
# Remove tags for @some_user
|
614
|
+
tag_lists[@some_user].remove "paris"
|
615
|
+
# Set the list for @some_user (replacing existing tags)
|
616
|
+
tag_lists[@some_user] = "new york, chicago, brussels, rome"
|
617
|
+
|
618
|
+
# Add tags for a new owner:
|
619
|
+
tag_lists[@other_user] = "moscow, bejing, tokyo"
|
620
|
+
```
|
621
|
+
#### Owned Tags and defaults
|
622
|
+
|
623
|
+
Owned Tags can be difficult to work with having to manage owners
|
624
|
+
manually. To ease that process, I have added the concept of defaults
|
625
|
+
to use when working with Owned tags.
|
626
|
+
|
627
|
+
When a tag is defined, you can also define default behavior when
|
628
|
+
creating the tag and accessing it, simplifying using the tag in
|
629
|
+
everyday access.
|
630
|
+
|
631
|
+
Options:
|
632
|
+
* tagger: true - Simply defines that a Tag definition supports
|
633
|
+
the concept of Taggers and allows setting the Tagger for a list.
|
634
|
+
* tagger: { default_tagger: :method_name} - This allows you to
|
635
|
+
specify that when a Tagging is created on a Taggable object
|
636
|
+
that the Taggable object will supply the default tagger using
|
637
|
+
the indicated method.
|
638
|
+
* tagger: { tag_list_uses_default_tagger: true } - A
|
639
|
+
shortcut/syntax sugar to treat `<tag_type>_list` to return
|
640
|
+
the tags for the `default_tagger` instead of no taggers
|
604
641
|
|
605
|
-
def stringify(tag_list)
|
606
|
-
tag_list.inject('') { |memo, tag| memo += (tag + ',') }[0..-1]
|
607
|
-
end
|
608
|
-
```
|
609
|
-
##### Removing owned tags
|
610
|
-
Similarly as above, removing will be as follows:
|
611
642
|
```ruby
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
@tag_owner.tag(@some_item, :with => stringify(owned_tag_list), :on => :tags)
|
617
|
-
@some_item.save
|
643
|
+
class Car
|
644
|
+
acts_as_taggable_on tagger: { default_tagger: :owner, tag_list_uses_default_tagger: true }
|
645
|
+
|
646
|
+
belongs_to :owner, class_name: "User"
|
618
647
|
end
|
648
|
+
|
649
|
+
class User
|
650
|
+
acts_as_tagger
|
651
|
+
|
652
|
+
has_many :cars
|
653
|
+
end
|
654
|
+
|
655
|
+
car = @some_user.cars.first
|
656
|
+
car.tag_list = "antique, warrantied, registered"
|
657
|
+
car.tag_lists[car.owner] # => ["antique", "warrantied", "registerd"]
|
658
|
+
car.tag_lists[nil] # => []
|
659
|
+
|
660
|
+
car.tag_lists[@potential_buyer] = ["inspected", "test drove", "good value"]
|
661
|
+
car.tagger_tag_list(@potential_buyer) # => ["inspected", "test drove", "good value"]
|
662
|
+
|
663
|
+
all_list = car.all_tag_list # => ["antique", "warrantied", "registerd", "inspected", "test drove", "good value"]
|
664
|
+
all_list.tagger # => @some_user
|
665
|
+
|
666
|
+
# Changing `all_list` does NOT affect/change the tags on `car`
|
667
|
+
# Changing other lists will:
|
668
|
+
all_list.remove "warrantied", "test drove"
|
669
|
+
car.tag_lists[car.owner] # => ["antique", "warrantied", "registerd"]
|
670
|
+
car.tagger_tag_list(@potential_buyer) # => ["inspected", "test drove", "good value"]
|
671
|
+
car.all_tag_list # => ["antique", "warrantied", "registerd", "inspected", "test drove", "good value"]
|
672
|
+
|
673
|
+
car.tag_lists[car.owner].add "deposit"
|
674
|
+
car.tagger_tag_list(@potential_buyer).remove "good value"
|
675
|
+
car.tag_lists[car.owner] # => ["antique", "warrantied", "registerd", "deposit"]
|
676
|
+
car.tagger_tag_list(@potential_buyer) # => ["inspected", "test drove"]
|
677
|
+
car.all_tag_list # => ["antique", "warrantied", "registerd", "deposit", "inspected", "test drove"]
|
619
678
|
```
|
620
679
|
|
621
680
|
### Dirty objects
|
@@ -634,6 +693,21 @@ end
|
|
634
693
|
@bobby.skill_list_change.should == ["jogging, diving", ["swimming"]]
|
635
694
|
```
|
636
695
|
|
696
|
+
If the object allows for Taggers, there could be multiple Taggers each
|
697
|
+
with their own changes. In this case, the changes (and corresponding
|
698
|
+
was values) will be hashes of the Tagger and the tag lists.
|
699
|
+
|
700
|
+
```ruby
|
701
|
+
@bobby = User.find_by_name("Bobby")
|
702
|
+
@bobby.skill_list_from(@teacher).add "attentive, assertive, gold star", parse: true
|
703
|
+
@bobby.skill_list_from(@parent).add "forger, standing in corner, truant", parse: true
|
704
|
+
|
705
|
+
@bobby.skill_list_change
|
706
|
+
# => [ {},
|
707
|
+
# => { @teacher => ["attentive", "assertive", "gold star"],
|
708
|
+
# => @parent => ["forger", "standing in corner", "truant"] } ]
|
709
|
+
```
|
710
|
+
|
637
711
|
### ~~Tag cloud calculations~~ Not implimented yet
|
638
712
|
|
639
713
|
To construct tag clouds, the frequency of each tag needs to be calculated.
|