mongoid-cached-json 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +80 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +85 -0
- data/CONTRIBUTING.md +118 -0
- data/Gemfile +21 -0
- data/README.md +49 -52
- data/Rakefile +34 -0
- data/lib/mongoid-cached-json.rb +0 -1
- data/lib/mongoid-cached-json/array.rb +1 -3
- data/lib/mongoid-cached-json/cached_json.rb +52 -50
- data/lib/mongoid-cached-json/config.rb +20 -21
- data/lib/mongoid-cached-json/hash.rb +1 -3
- data/lib/mongoid-cached-json/key_references.rb +0 -3
- data/lib/mongoid-cached-json/mongoid_criteria.rb +1 -3
- data/lib/mongoid-cached-json/version.rb +1 -2
- data/mongoid-cached-json.gemspec +17 -0
- data/spec/array_spec.rb +48 -0
- data/spec/benchmark_spec.rb +115 -0
- data/spec/cached_json_spec.rb +501 -0
- data/spec/config_spec.rb +21 -0
- data/spec/dalli_spec.rb +37 -0
- data/spec/hash_spec.rb +66 -0
- data/spec/mongoid_criteria_spec.rb +78 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/awesome_artwork.rb +11 -0
- data/spec/support/awesome_image.rb +14 -0
- data/spec/support/fast_json_artwork.rb +15 -0
- data/spec/support/fast_json_image.rb +12 -0
- data/spec/support/fast_json_url.rb +12 -0
- data/spec/support/json_embedded_foobar.rb +5 -0
- data/spec/support/json_employee.rb +12 -0
- data/spec/support/json_foobar.rb +19 -0
- data/spec/support/json_manager.rb +14 -0
- data/spec/support/json_math.rb +9 -0
- data/spec/support/json_parent_foobar.rb +11 -0
- data/spec/support/json_polymorphic_embedded_foobar.rb +9 -0
- data/spec/support/json_polymorphic_referenced_foobar.rb +9 -0
- data/spec/support/json_referenced_foobar.rb +5 -0
- data/spec/support/json_supervisor.rb +13 -0
- data/spec/support/json_transform.rb +13 -0
- data/spec/support/matchers/invalidate.rb +22 -0
- data/spec/support/person.rb +20 -0
- data/spec/support/poly_company.rb +10 -0
- data/spec/support/poly_person.rb +10 -0
- data/spec/support/poly_post.rb +9 -0
- data/spec/support/prison_cell.rb +11 -0
- data/spec/support/prison_inmate.rb +12 -0
- data/spec/support/secret_parent.rb +11 -0
- data/spec/support/sometimes_secret.rb +11 -0
- data/spec/support/tool.rb +11 -0
- data/spec/support/tool_box.rb +10 -0
- metadata +62 -137
@@ -0,0 +1,22 @@
|
|
1
|
+
RSpec::Matchers.define :invalidate do |target|
|
2
|
+
supports_block_expectations
|
3
|
+
|
4
|
+
match do |block|
|
5
|
+
call_counts = 0
|
6
|
+
Array(target).each do |cached_model|
|
7
|
+
allow(cached_model).to receive(:expire_cached_json) do
|
8
|
+
call_counts += 1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
block.call if block.is_a?(Proc)
|
12
|
+
call_counts == Array(target).count
|
13
|
+
end
|
14
|
+
|
15
|
+
failure_message do
|
16
|
+
'target cache to be invalidated, but it was not'
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do
|
20
|
+
'target cache to be invalidated, but it was not'
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Person
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::CachedJson
|
4
|
+
|
5
|
+
field :first, type: String
|
6
|
+
field :last, type: String
|
7
|
+
field :middle, type: String
|
8
|
+
field :born, type: String
|
9
|
+
|
10
|
+
def name
|
11
|
+
[first, middle, last].compact.join(' ')
|
12
|
+
end
|
13
|
+
|
14
|
+
json_fields \
|
15
|
+
first: { versions: [:v2, :v3] },
|
16
|
+
last: { versions: [:v2, :v3] },
|
17
|
+
middle: { versions: [:v2, :v3] },
|
18
|
+
born: { versions: :v3 },
|
19
|
+
name: { definition: :name }
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class SometimesSecret
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::CachedJson
|
4
|
+
|
5
|
+
field :secret, default: 'Afraid of the dark'
|
6
|
+
field :should_tell_secret, type: Boolean
|
7
|
+
belongs_to :secret_parent
|
8
|
+
|
9
|
+
json_fields hide_as_child_json_when: lambda { |x| !x.should_tell_secret },
|
10
|
+
secret: {}
|
11
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-cached-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
5
|
-
prerelease:
|
4
|
+
version: 1.5.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Aaron Windsor
|
@@ -11,144 +10,39 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 2014-12-29 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: activesupport
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
|
-
requirements:
|
21
|
-
- - ! '>='
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '0'
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
|
-
requirements:
|
29
|
-
- - ! '>='
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: '0'
|
32
15
|
- !ruby/object:Gem::Dependency
|
33
16
|
name: mongoid
|
34
17
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
|
-
requirements:
|
37
|
-
- - ! '>='
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 3.0.0
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.0.0
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: hpricot
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
18
|
requirements:
|
53
|
-
- -
|
19
|
+
- - ">="
|
54
20
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
21
|
+
version: '3.0'
|
56
22
|
type: :runtime
|
57
23
|
prerelease: false
|
58
24
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
|
-
requirements:
|
61
|
-
- - ! '>='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: rspec
|
66
|
-
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- - ~>
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '2.5'
|
72
|
-
type: :development
|
73
|
-
prerelease: false
|
74
|
-
version_requirements: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ~>
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '2.5'
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: bundler
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
25
|
requirements:
|
85
|
-
- -
|
26
|
+
- - ">="
|
86
27
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
88
|
-
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ~>
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '1.0'
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
|
-
name: jeweler
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.6'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
|
-
requirements:
|
109
|
-
- - ~>
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '1.6'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: yard
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
|
-
requirements:
|
117
|
-
- - ~>
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '0.6'
|
120
|
-
type: :development
|
121
|
-
prerelease: false
|
122
|
-
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
|
-
requirements:
|
125
|
-
- - ~>
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '0.6'
|
128
|
-
- !ruby/object:Gem::Dependency
|
129
|
-
name: dalli
|
130
|
-
requirement: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
|
-
requirements:
|
133
|
-
- - ~>
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
version: '2.6'
|
136
|
-
type: :development
|
137
|
-
prerelease: false
|
138
|
-
version_requirements: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
|
-
requirements:
|
141
|
-
- - ~>
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '2.6'
|
144
|
-
description: Cached-json is a DSL for describing JSON representations of Mongoid models.
|
28
|
+
version: '3.0'
|
29
|
+
description:
|
145
30
|
email: dblock@dblock.org
|
146
31
|
executables: []
|
147
32
|
extensions: []
|
148
|
-
extra_rdoc_files:
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- ".rspec"
|
37
|
+
- ".rubocop.yml"
|
38
|
+
- ".rubocop_todo.yml"
|
39
|
+
- ".travis.yml"
|
40
|
+
- CHANGELOG.md
|
41
|
+
- CONTRIBUTING.md
|
42
|
+
- Gemfile
|
149
43
|
- LICENSE.md
|
150
44
|
- README.md
|
151
|
-
|
45
|
+
- Rakefile
|
152
46
|
- lib/mongoid-cached-json.rb
|
153
47
|
- lib/mongoid-cached-json/array.rb
|
154
48
|
- lib/mongoid-cached-json/cached_json.rb
|
@@ -157,34 +51,65 @@ files:
|
|
157
51
|
- lib/mongoid-cached-json/key_references.rb
|
158
52
|
- lib/mongoid-cached-json/mongoid_criteria.rb
|
159
53
|
- lib/mongoid-cached-json/version.rb
|
160
|
-
-
|
161
|
-
-
|
54
|
+
- mongoid-cached-json.gemspec
|
55
|
+
- spec/array_spec.rb
|
56
|
+
- spec/benchmark_spec.rb
|
57
|
+
- spec/cached_json_spec.rb
|
58
|
+
- spec/config_spec.rb
|
59
|
+
- spec/dalli_spec.rb
|
60
|
+
- spec/hash_spec.rb
|
61
|
+
- spec/mongoid_criteria_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- spec/support/awesome_artwork.rb
|
64
|
+
- spec/support/awesome_image.rb
|
65
|
+
- spec/support/fast_json_artwork.rb
|
66
|
+
- spec/support/fast_json_image.rb
|
67
|
+
- spec/support/fast_json_url.rb
|
68
|
+
- spec/support/json_embedded_foobar.rb
|
69
|
+
- spec/support/json_employee.rb
|
70
|
+
- spec/support/json_foobar.rb
|
71
|
+
- spec/support/json_manager.rb
|
72
|
+
- spec/support/json_math.rb
|
73
|
+
- spec/support/json_parent_foobar.rb
|
74
|
+
- spec/support/json_polymorphic_embedded_foobar.rb
|
75
|
+
- spec/support/json_polymorphic_referenced_foobar.rb
|
76
|
+
- spec/support/json_referenced_foobar.rb
|
77
|
+
- spec/support/json_supervisor.rb
|
78
|
+
- spec/support/json_transform.rb
|
79
|
+
- spec/support/matchers/invalidate.rb
|
80
|
+
- spec/support/person.rb
|
81
|
+
- spec/support/poly_company.rb
|
82
|
+
- spec/support/poly_person.rb
|
83
|
+
- spec/support/poly_post.rb
|
84
|
+
- spec/support/prison_cell.rb
|
85
|
+
- spec/support/prison_inmate.rb
|
86
|
+
- spec/support/secret_parent.rb
|
87
|
+
- spec/support/sometimes_secret.rb
|
88
|
+
- spec/support/tool.rb
|
89
|
+
- spec/support/tool_box.rb
|
162
90
|
homepage: http://github.com/dblock/mongoid-cached-json
|
163
91
|
licenses:
|
164
92
|
- MIT
|
93
|
+
metadata: {}
|
165
94
|
post_install_message:
|
166
95
|
rdoc_options: []
|
167
96
|
require_paths:
|
168
97
|
- lib
|
169
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
-
none: false
|
171
99
|
requirements:
|
172
|
-
- -
|
100
|
+
- - ">="
|
173
101
|
- !ruby/object:Gem::Version
|
174
102
|
version: '0'
|
175
|
-
segments:
|
176
|
-
- 0
|
177
|
-
hash: -698501965
|
178
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
104
|
requirements:
|
181
|
-
- -
|
105
|
+
- - ">="
|
182
106
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
107
|
+
version: 1.3.6
|
184
108
|
requirements: []
|
185
109
|
rubyforge_project:
|
186
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.4.5
|
187
111
|
signing_key:
|
188
|
-
specification_version:
|
189
|
-
summary:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Cached-json is a DSL for describing JSON representations of Mongoid models.
|
190
114
|
test_files: []
|
115
|
+
has_rdoc:
|