mongoid-cached-json 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop_todo.yml +198 -21
- data/.travis.yml +25 -2
- data/CHANGELOG.md +14 -1
- data/CONTRIBUTING.md +4 -4
- data/Gemfile +6 -3
- data/README.md +5 -6
- data/Rakefile +1 -1
- data/lib/mongoid-cached-json/cached_json.rb +7 -1
- data/lib/mongoid-cached-json/config.rb +0 -1
- data/lib/mongoid-cached-json/version.rb +1 -1
- data/mongoid-cached-json.gemspec +2 -2
- data/spec/cached_json_spec.rb +6 -6
- data/spec/support/fast_json_image.rb +5 -1
- data/spec/support/json_manager.rb +6 -1
- data/spec/support/tool.rb +6 -1
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4e75b4ba09bfba7f6c52d44ea4bc7e7287765c3679107435b27afabf910c51ac
|
4
|
+
data.tar.gz: 1160dc6600d6ef6b18aa063ace9eddeac0ce5fe89902f15fd6855943f1989306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c1470b1e65cc3212a576b522fd54a2ef9851d917b967a3f5e17c404a23b292e168a7d7b8eb99ccd999064aa2e51f367b7bcb0daa3d805d682719128602d7bbc
|
7
|
+
data.tar.gz: 8edc758906ee5b088c101babfd2cb2a4d54802cff2141baa16d223788c1e317cefcc16964081c07548346a202a38450c22a4d6087d876be4bc467900bf137794
|
data/.rubocop_todo.yml
CHANGED
@@ -1,11 +1,64 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2019-05-30 22:27:20 -0400 using RuboCop version 0.71.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 5
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
12
|
+
Bundler/DuplicatedGem:
|
13
|
+
Exclude:
|
14
|
+
- 'Gemfile'
|
15
|
+
|
16
|
+
# Offense count: 3
|
17
|
+
# Cop supports --auto-correct.
|
18
|
+
Layout/EmptyLineAfterGuardClause:
|
19
|
+
Exclude:
|
20
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
21
|
+
|
22
|
+
# Offense count: 4
|
23
|
+
# Cop supports --auto-correct.
|
24
|
+
Layout/EmptyLineAfterMagicComment:
|
25
|
+
Exclude:
|
26
|
+
- 'lib/mongoid-cached-json.rb'
|
27
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
28
|
+
- 'lib/mongoid-cached-json/config.rb'
|
29
|
+
- 'lib/mongoid-cached-json/key_references.rb'
|
30
|
+
|
31
|
+
# Offense count: 16
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
# Configuration parameters: IndentationWidth.
|
34
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
|
35
|
+
Layout/IndentFirstArrayElement:
|
36
|
+
EnforcedStyle: consistent
|
37
|
+
|
38
|
+
# Offense count: 1
|
39
|
+
# Cop supports --auto-correct.
|
40
|
+
# Configuration parameters: EnforcedStyle.
|
41
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
42
|
+
Layout/MultilineArrayBraceLayout:
|
43
|
+
Exclude:
|
44
|
+
- 'spec/cached_json_spec.rb'
|
45
|
+
|
46
|
+
# Offense count: 4
|
47
|
+
# Cop supports --auto-correct.
|
48
|
+
# Configuration parameters: EnforcedStyle.
|
49
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
50
|
+
Layout/MultilineHashBraceLayout:
|
51
|
+
Exclude:
|
52
|
+
- 'spec/cached_json_spec.rb'
|
53
|
+
|
54
|
+
# Offense count: 2
|
55
|
+
# Cop supports --auto-correct.
|
56
|
+
# Configuration parameters: EnforcedStyle.
|
57
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
58
|
+
Layout/MultilineMethodCallBraceLayout:
|
59
|
+
Exclude:
|
60
|
+
- 'spec/cached_json_spec.rb'
|
61
|
+
|
9
62
|
# Offense count: 1
|
10
63
|
# Configuration parameters: AllowSafeAssignment.
|
11
64
|
Lint/AssignmentInCondition:
|
@@ -13,6 +66,7 @@ Lint/AssignmentInCondition:
|
|
13
66
|
- 'lib/mongoid-cached-json/cached_json.rb'
|
14
67
|
|
15
68
|
# Offense count: 1
|
69
|
+
# Configuration parameters: AllowKeywordBlockArguments.
|
16
70
|
Lint/UnderscorePrefixedVariableName:
|
17
71
|
Exclude:
|
18
72
|
- 'lib/mongoid-cached-json/cached_json.rb'
|
@@ -25,9 +79,16 @@ Lint/UselessAssignment:
|
|
25
79
|
|
26
80
|
# Offense count: 5
|
27
81
|
Metrics/AbcSize:
|
28
|
-
Max:
|
82
|
+
Max: 45
|
83
|
+
|
84
|
+
# Offense count: 22
|
85
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
86
|
+
# ExcludedMethods: refine
|
87
|
+
Metrics/BlockLength:
|
88
|
+
Max: 488
|
29
89
|
|
30
90
|
# Offense count: 2
|
91
|
+
# Configuration parameters: CountBlocks.
|
31
92
|
Metrics/BlockNesting:
|
32
93
|
Max: 4
|
33
94
|
|
@@ -35,28 +96,54 @@ Metrics/BlockNesting:
|
|
35
96
|
Metrics/CyclomaticComplexity:
|
36
97
|
Max: 15
|
37
98
|
|
38
|
-
# Offense count:
|
39
|
-
# Configuration parameters:
|
40
|
-
Metrics/LineLength:
|
41
|
-
Max: 202
|
42
|
-
|
43
|
-
# Offense count: 10
|
44
|
-
# Configuration parameters: CountComments.
|
99
|
+
# Offense count: 9
|
100
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
45
101
|
Metrics/MethodLength:
|
46
|
-
Max:
|
102
|
+
Max: 41
|
47
103
|
|
48
104
|
# Offense count: 1
|
49
105
|
# Configuration parameters: CountComments.
|
50
106
|
Metrics/ModuleLength:
|
51
|
-
Max:
|
107
|
+
Max: 124
|
52
108
|
|
53
109
|
# Offense count: 4
|
54
110
|
Metrics/PerceivedComplexity:
|
55
111
|
Max: 16
|
56
112
|
|
57
|
-
# Offense count:
|
113
|
+
# Offense count: 1
|
114
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
115
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
116
|
+
Naming/FileName:
|
117
|
+
Exclude:
|
118
|
+
- 'lib/mongoid-cached-json.rb'
|
119
|
+
|
120
|
+
# Offense count: 1
|
121
|
+
# Cop supports --auto-correct.
|
122
|
+
# Configuration parameters: EnforcedStyle.
|
123
|
+
# SupportedStyles: prefer_alias, prefer_alias_method
|
124
|
+
Style/Alias:
|
125
|
+
Exclude:
|
126
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
127
|
+
|
128
|
+
# Offense count: 1
|
129
|
+
# Cop supports --auto-correct.
|
130
|
+
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
131
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
132
|
+
Style/ConditionalAssignment:
|
133
|
+
Exclude:
|
134
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
135
|
+
|
136
|
+
# Offense count: 7
|
58
137
|
Style/Documentation:
|
59
|
-
|
138
|
+
Exclude:
|
139
|
+
- 'spec/**/*'
|
140
|
+
- 'test/**/*'
|
141
|
+
- 'lib/mongoid-cached-json/array.rb'
|
142
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
143
|
+
- 'lib/mongoid-cached-json/config.rb'
|
144
|
+
- 'lib/mongoid-cached-json/hash.rb'
|
145
|
+
- 'lib/mongoid-cached-json/key_references.rb'
|
146
|
+
- 'lib/mongoid-cached-json/mongoid_criteria.rb'
|
60
147
|
|
61
148
|
# Offense count: 2
|
62
149
|
Style/DoubleNegation:
|
@@ -64,18 +151,42 @@ Style/DoubleNegation:
|
|
64
151
|
- 'lib/mongoid-cached-json/cached_json.rb'
|
65
152
|
|
66
153
|
# Offense count: 1
|
154
|
+
# Cop supports --auto-correct.
|
67
155
|
Style/EachWithObject:
|
68
156
|
Exclude:
|
69
157
|
- 'lib/mongoid-cached-json/hash.rb'
|
70
158
|
|
71
|
-
# Offense count:
|
72
|
-
#
|
73
|
-
Style/
|
159
|
+
# Offense count: 3
|
160
|
+
# Cop supports --auto-correct.
|
161
|
+
Style/Encoding:
|
74
162
|
Exclude:
|
75
163
|
- 'lib/mongoid-cached-json.rb'
|
164
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
165
|
+
- 'lib/mongoid-cached-json/config.rb'
|
166
|
+
|
167
|
+
# Offense count: 1
|
168
|
+
Style/EvalWithLocation:
|
169
|
+
Exclude:
|
170
|
+
- 'lib/mongoid-cached-json/config.rb'
|
171
|
+
|
172
|
+
# Offense count: 46
|
173
|
+
# Cop supports --auto-correct.
|
174
|
+
# Configuration parameters: EnforcedStyle.
|
175
|
+
# SupportedStyles: always, never
|
176
|
+
Style/FrozenStringLiteralComment:
|
177
|
+
Enabled: false
|
178
|
+
|
179
|
+
# Offense count: 3
|
180
|
+
# Cop supports --auto-correct.
|
181
|
+
Style/IfUnlessModifier:
|
182
|
+
Exclude:
|
183
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
184
|
+
- 'spec/cached_json_spec.rb'
|
76
185
|
|
77
186
|
# Offense count: 5
|
78
187
|
# Cop supports --auto-correct.
|
188
|
+
# Configuration parameters: EnforcedStyle.
|
189
|
+
# SupportedStyles: line_count_dependent, lambda, literal
|
79
190
|
Style/Lambda:
|
80
191
|
Exclude:
|
81
192
|
- 'lib/mongoid-cached-json/cached_json.rb'
|
@@ -85,17 +196,83 @@ Style/Lambda:
|
|
85
196
|
- 'spec/support/sometimes_secret.rb'
|
86
197
|
|
87
198
|
# Offense count: 1
|
199
|
+
# Cop supports --auto-correct.
|
200
|
+
# Configuration parameters: EnforcedStyle, Autocorrect.
|
201
|
+
# SupportedStyles: module_function, extend_self
|
88
202
|
Style/ModuleFunction:
|
89
203
|
Exclude:
|
90
204
|
- 'lib/mongoid-cached-json/config.rb'
|
91
205
|
|
92
206
|
# Offense count: 1
|
93
|
-
#
|
207
|
+
# Cop supports --auto-correct.
|
208
|
+
# Configuration parameters: EnforcedStyle.
|
209
|
+
# SupportedStyles: literals, strict
|
210
|
+
Style/MutableConstant:
|
211
|
+
Exclude:
|
212
|
+
- 'lib/mongoid-cached-json/version.rb'
|
213
|
+
|
214
|
+
# Offense count: 2
|
215
|
+
# Cop supports --auto-correct.
|
216
|
+
Style/OrAssignment:
|
217
|
+
Exclude:
|
218
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
219
|
+
|
220
|
+
# Offense count: 2
|
221
|
+
# Cop supports --auto-correct.
|
222
|
+
# Configuration parameters: PreferredDelimiters.
|
223
|
+
Style/PercentLiteralDelimiters:
|
224
|
+
Exclude:
|
225
|
+
- 'spec/array_spec.rb'
|
226
|
+
|
227
|
+
# Offense count: 1
|
228
|
+
# Cop supports --auto-correct.
|
229
|
+
# Configuration parameters: EnforcedStyle.
|
230
|
+
# SupportedStyles: compact, exploded
|
94
231
|
Style/RaiseArgs:
|
95
|
-
|
232
|
+
Exclude:
|
233
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
234
|
+
|
235
|
+
# Offense count: 1
|
236
|
+
# Cop supports --auto-correct.
|
237
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
|
238
|
+
# Whitelist: present?, blank?, presence, try, try!
|
239
|
+
Style/SafeNavigation:
|
240
|
+
Exclude:
|
241
|
+
- 'lib/mongoid-cached-json/key_references.rb'
|
96
242
|
|
97
243
|
# Offense count: 2
|
98
|
-
#
|
99
|
-
|
244
|
+
# Cop supports --auto-correct.
|
245
|
+
# Configuration parameters: EnforcedStyle.
|
246
|
+
# SupportedStyles: only_raise, only_fail, semantic
|
247
|
+
Style/SignalException:
|
248
|
+
Exclude:
|
249
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
250
|
+
- 'spec/cached_json_spec.rb'
|
251
|
+
|
252
|
+
# Offense count: 13
|
253
|
+
# Cop supports --auto-correct.
|
254
|
+
# Configuration parameters: MinSize.
|
255
|
+
# SupportedStyles: percent, brackets
|
256
|
+
Style/SymbolArray:
|
257
|
+
EnforcedStyle: brackets
|
258
|
+
|
259
|
+
# Offense count: 1
|
260
|
+
# Cop supports --auto-correct.
|
261
|
+
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
|
262
|
+
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
|
263
|
+
Style/TernaryParentheses:
|
264
|
+
Exclude:
|
265
|
+
- 'lib/mongoid-cached-json/cached_json.rb'
|
266
|
+
|
267
|
+
# Offense count: 1
|
268
|
+
# Cop supports --auto-correct.
|
269
|
+
Style/UnneededInterpolation:
|
100
270
|
Exclude:
|
101
|
-
- 'spec/
|
271
|
+
- 'spec/cached_json_spec.rb'
|
272
|
+
|
273
|
+
# Offense count: 200
|
274
|
+
# Cop supports --auto-correct.
|
275
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
276
|
+
# URISchemes: http, https
|
277
|
+
Metrics/LineLength:
|
278
|
+
Max: 202
|
data/.travis.yml
CHANGED
@@ -1,17 +1,40 @@
|
|
1
1
|
sudo: false
|
2
2
|
|
3
|
+
script: bundle exec rake spec
|
4
|
+
|
3
5
|
services:
|
4
6
|
- mongodb
|
5
7
|
- memcache
|
6
8
|
|
7
9
|
rvm:
|
8
|
-
- 1.9.3
|
9
10
|
- 2.0.0
|
10
|
-
- 2.
|
11
|
+
- 2.1.10
|
12
|
+
- 2.2.10
|
13
|
+
- 2.3.7
|
14
|
+
- 2.4.6
|
15
|
+
- 2.5.5
|
16
|
+
- 2.6.3
|
11
17
|
|
12
18
|
env:
|
13
19
|
- MONGOID_VERSION=3
|
14
20
|
- MONGOID_VERSION=4
|
15
21
|
- MONGOID_VERSION=5
|
22
|
+
- MONGOID_VERSION=6
|
23
|
+
- MONGOID_VERSION=7
|
16
24
|
|
17
25
|
cache: bundler
|
26
|
+
|
27
|
+
matrix:
|
28
|
+
include:
|
29
|
+
- rvm: 2.6.3
|
30
|
+
env: RUBOCOP=true
|
31
|
+
script: bundle exec rake rubocop
|
32
|
+
exclude:
|
33
|
+
- rvm: 2.0.0
|
34
|
+
env: MONGOID_VERSION=6
|
35
|
+
- rvm: 2.1.10
|
36
|
+
env: MONGOID_VERSION=6
|
37
|
+
- rvm: 2.0.0
|
38
|
+
env: MONGOID_VERSION=7
|
39
|
+
- rvm: 2.1.10
|
40
|
+
env: MONGOID_VERSION=7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
1.6.1 (Next)
|
2
|
+
------------
|
3
|
+
|
4
|
+
* Your contribution here.
|
5
|
+
|
6
|
+
1.6.0 (2019/05/31)
|
7
|
+
------------
|
8
|
+
|
9
|
+
* [#20](https://github.com/mongoid/mongoid-cached-json/pull/20): Compatibility with Ruby 2.3, 2.4, 2.5 and 2.6 - [@yuki24](http://github.com/yuki24).
|
10
|
+
* [#20](https://github.com/mongoid/mongoid-cached-json/pull/20): Compatibility with Mongoid 6 - [@yuki24](http://github.com/yuki24).
|
11
|
+
* [#20](https://github.com/mongoid/mongoid-cached-json/pull/20): No longer test against Ruby 1.9.3 - [@yuki24](http://github.com/yuki24).
|
12
|
+
* [#22](https://github.com/mongoid/mongoid-cached-json/pull/22): Compatibility with Mongoid 7 - [@yuki24](https://github.com/yuki24)
|
13
|
+
|
1
14
|
1.5.3 (2015/09/17)
|
2
15
|
------------------
|
3
16
|
|
@@ -58,7 +71,7 @@
|
|
58
71
|
1.2.2 (2012/07/03)
|
59
72
|
------------------
|
60
73
|
|
61
|
-
* Fix [#6](https://github.com/
|
74
|
+
* Fix [#6](https://github.com/mongoid/mongoid-cached-json/issues/6): including parent in `json_fields` within a polymorphic reference fails with an "uninitialized constant" error - [@dblock](http://github.com/dblock).
|
62
75
|
|
63
76
|
1.2.1 (2012/06/12)
|
64
77
|
------------------
|
data/CONTRIBUTING.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
Contributing to Mongoid::CachedJson
|
2
2
|
===================================
|
3
3
|
|
4
|
-
Mongoid::CachedJson is work of [many of contributors](https://github.com/
|
4
|
+
Mongoid::CachedJson is work of [many of contributors](https://github.com/mongoid/mongoid-cached-json/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/mongoid/mongoid-cached-json/pulls), [propose features and discuss issues](https://github.com/mongoid/mongoid-cached-json/issues). When in doubt, ask a question in the [Google Group](http://groups.google.com/group/mongoid-cached-json).
|
5
5
|
|
6
6
|
#### Fork the Project
|
7
7
|
|
8
|
-
Fork the [project on Github](https://github.com/
|
8
|
+
Fork the [project on Github](https://github.com/mongoid/mongoid-cached-json) and check out your copy.
|
9
9
|
|
10
10
|
```
|
11
11
|
git clone https://github.com/contributor/mongoid-cached-json.git
|
12
12
|
cd mongoid-cached-json
|
13
|
-
git remote add upstream https://github.com/
|
13
|
+
git remote add upstream https://github.com/mongoid/mongoid-cached-json.git
|
14
14
|
```
|
15
15
|
|
16
16
|
#### Create a Topic Branch
|
@@ -104,7 +104,7 @@ git push origin my-feature-branch -f
|
|
104
104
|
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
105
105
|
|
106
106
|
```
|
107
|
-
* [#123](https://github.com/
|
107
|
+
* [#123](https://github.com/mongoid/mongoid-cached-json/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
108
108
|
```
|
109
109
|
|
110
110
|
Amend your previous commit and force push the changes.
|
data/Gemfile
CHANGED
@@ -3,6 +3,10 @@ source 'http://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
case version = ENV['MONGOID_VERSION'] || '~> 5.0'
|
6
|
+
when /7/
|
7
|
+
gem 'mongoid', '~> 7.0'
|
8
|
+
when /6/
|
9
|
+
gem 'mongoid', '~> 6.0'
|
6
10
|
when /5/
|
7
11
|
gem 'mongoid', '~> 5.0'
|
8
12
|
when /4/
|
@@ -14,11 +18,10 @@ else
|
|
14
18
|
end
|
15
19
|
|
16
20
|
group :development do
|
21
|
+
gem 'dalli', '~> 2.6'
|
17
22
|
gem 'rake'
|
18
|
-
gem '
|
23
|
+
gem 'rubocop'
|
19
24
|
gem 'yard', '~> 0.6'
|
20
|
-
gem 'dalli', '~> 2.6'
|
21
|
-
gem 'rubocop', '0.33.0'
|
22
25
|
end
|
23
26
|
|
24
27
|
group :test do
|
data/README.md
CHANGED
@@ -2,9 +2,8 @@ Mongoid::CachedJson
|
|
2
2
|
===================
|
3
3
|
|
4
4
|
[](http://badge.fury.io/rb/mongoid-cached-json)
|
5
|
-
[](https://codeclimate.com/github/dblock/mongoid-cached-json)
|
5
|
+
[](https://travis-ci.org/mongoid/mongoid-cached-json)
|
6
|
+
[](https://codeclimate.com/github/mongoid/mongoid-cached-json)
|
8
7
|
|
9
8
|
Typical `as_json` definitions may involve lots of database point queries and method calls. When returning collections of objects, a single call may yield hundreds of database queries that can take seconds. This library mitigates the problem by implementing a module called `CachedJson`.
|
10
9
|
|
@@ -15,13 +14,13 @@ Using `Mongoid::CachedJson` we were able to cut our JSON API average response ti
|
|
15
14
|
Compatibility
|
16
15
|
-------------
|
17
16
|
|
18
|
-
This gem is compatible with Mongoid 3, 4 and
|
17
|
+
This gem is compatible with Mongoid 3, 4, 5, 6, and 7.
|
19
18
|
|
20
19
|
Resources
|
21
20
|
---------
|
22
21
|
|
23
22
|
* [Need Help? Google Group](http://groups.google.com/group/mongoid-cached-json)
|
24
|
-
* [Source Code](http://github.com/
|
23
|
+
* [Source Code](http://github.com/mongoid/mongoid-cached-json)
|
25
24
|
|
26
25
|
Quickstart
|
27
26
|
----------
|
@@ -293,6 +292,6 @@ See [CONTRIBUTING](CONTRIBUTING.md).
|
|
293
292
|
Copyright and License
|
294
293
|
---------------------
|
295
294
|
|
296
|
-
MIT License, see [LICENSE](https://github.com/
|
295
|
+
MIT License, see [LICENSE](https://github.com/mongoid/mongoid-cached-json/blob/master/LICENSE.md) for details.
|
297
296
|
|
298
297
|
(c) 2012-2014 [Artsy](https://artsy.net) and [Contributors](CHANGELOG.md)
|
data/Rakefile
CHANGED
@@ -126,7 +126,13 @@ module Mongoid
|
|
126
126
|
else
|
127
127
|
clazz = reference_def[:metadata].class_name.constantize
|
128
128
|
end
|
129
|
-
|
129
|
+
relation_class = if Mongoid::Compatibility::Version.mongoid7_or_newer?
|
130
|
+
Mongoid::Association::Referenced::HasAndBelongsToMany::Proxy
|
131
|
+
else
|
132
|
+
Mongoid::Relations::Referenced::ManyToMany
|
133
|
+
end
|
134
|
+
|
135
|
+
if reference_def[:metadata].relation == relation_class
|
130
136
|
object_ids = object.send(key)
|
131
137
|
if object_ids
|
132
138
|
reference_json = object_ids.map do |id|
|
data/mongoid-cached-json.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
$LOAD_PATH.push File.expand_path('
|
1
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
2
2
|
require 'mongoid-cached-json/version'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.required_rubygems_version = '>= 1.3.6'
|
11
11
|
s.files = `git ls-files`.split("\n")
|
12
12
|
s.require_paths = ['lib']
|
13
|
-
s.homepage = 'http://github.com/
|
13
|
+
s.homepage = 'http://github.com/mongoid/mongoid-cached-json'
|
14
14
|
s.licenses = ['MIT']
|
15
15
|
s.summary = 'Cached-json is a DSL for describing JSON representations of Mongoid models.'
|
16
16
|
s.add_dependency 'mongoid', '>= 3.0'
|
data/spec/cached_json_spec.rb
CHANGED
@@ -88,10 +88,10 @@ describe Mongoid::CachedJson do
|
|
88
88
|
end
|
89
89
|
context 'many-to-one relationships' do
|
90
90
|
it 'uses the correct properties on the base object and passes :short or :all as appropriate' do
|
91
|
-
manager = JsonManager.create(name: 'Boss')
|
92
|
-
peon = manager.json_employees.create(name: 'Peon')
|
93
|
-
manager.json_employees.create(name: 'Indentured servant')
|
94
|
-
manager.json_employees.create(name: 'Serf', nickname: 'Vince')
|
91
|
+
manager = JsonManager.create!(name: 'Boss')
|
92
|
+
peon = manager.json_employees.create!(name: 'Peon')
|
93
|
+
manager.json_employees.create!(name: 'Indentured servant')
|
94
|
+
manager.json_employees.create!(name: 'Serf', nickname: 'Vince')
|
95
95
|
3.times do
|
96
96
|
3.times do
|
97
97
|
manager_short_json = manager.as_json(properties: :short)
|
@@ -129,8 +129,8 @@ describe Mongoid::CachedJson do
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
it 'correctly updates fields when either the parent or child class changes' do
|
132
|
-
manager = JsonManager.create(name: 'JsonManager')
|
133
|
-
employee = manager.json_employees.create(name: 'JsonEmployee')
|
132
|
+
manager = JsonManager.create!(name: 'JsonManager')
|
133
|
+
employee = manager.json_employees.create!(name: 'JsonEmployee')
|
134
134
|
3.times do
|
135
135
|
expect(manager.as_json(properties: :short)).to eq(name: 'JsonManager', employees: [{ name: 'JsonEmployee' }])
|
136
136
|
expect(employee.as_json(properties: :short)).to eq(name: 'JsonEmployee')
|
@@ -3,7 +3,11 @@ class FastJsonImage
|
|
3
3
|
include Mongoid::CachedJson
|
4
4
|
|
5
5
|
field :name, default: 'Image'
|
6
|
-
|
6
|
+
if Mongoid::Compatibility::Version.mongoid5_or_older?
|
7
|
+
belongs_to :fast_json_artwork
|
8
|
+
else
|
9
|
+
belongs_to :fast_json_artwork, required: false
|
10
|
+
end
|
7
11
|
has_and_belongs_to_many :fast_json_urls
|
8
12
|
|
9
13
|
json_fields \
|
@@ -5,7 +5,12 @@ class JsonManager
|
|
5
5
|
field :name
|
6
6
|
field :ssn, default: '123-45-6789'
|
7
7
|
has_many :json_employees
|
8
|
-
|
8
|
+
|
9
|
+
if Mongoid::Compatibility::Version.mongoid5_or_older?
|
10
|
+
belongs_to :supervisor, class_name: 'JsonSupervisor'
|
11
|
+
else
|
12
|
+
belongs_to :supervisor, class_name: 'JsonSupervisor', required: false
|
13
|
+
end
|
9
14
|
|
10
15
|
json_fields \
|
11
16
|
name: {},
|
data/spec/support/tool.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-cached-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Windsor
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-06-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mongoid
|
@@ -87,7 +87,7 @@ files:
|
|
87
87
|
- spec/support/sometimes_secret.rb
|
88
88
|
- spec/support/tool.rb
|
89
89
|
- spec/support/tool_box.rb
|
90
|
-
homepage: http://github.com/
|
90
|
+
homepage: http://github.com/mongoid/mongoid-cached-json
|
91
91
|
licenses:
|
92
92
|
- MIT
|
93
93
|
metadata: {}
|
@@ -106,10 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: 1.3.6
|
108
108
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.2.2
|
109
|
+
rubygems_version: 3.0.3
|
111
110
|
signing_key:
|
112
111
|
specification_version: 4
|
113
112
|
summary: Cached-json is a DSL for describing JSON representations of Mongoid models.
|
114
113
|
test_files: []
|
115
|
-
has_rdoc:
|