materialist 3.1.0 → 3.2.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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -3
- data/README.md +3 -1
- data/RELEASE_NOTES.md +17 -0
- data/lib/materialist/materializer/internals/dsl.rb +2 -2
- data/lib/materialist/materializer/internals/link_mapping.rb +3 -2
- data/lib/materialist/materializer/internals/materializer.rb +7 -3
- data/lib/materialist.rb +1 -1
- data/spec/materialist/materializer_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8665cde57cae1468db10b2d04ca02ee83baccef5
|
4
|
+
data.tar.gz: a2fe18fbfdb6e1aa039b3c1dc9a5c7150e67acf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c630af56d05969a23fc7a19149b588eeda385e4d30f494f123ef7cc8f4971f7352fab65b81b6d92cbba919fe3d3e4a68bfa886638854b3997bff05836a224cc8
|
7
|
+
data.tar.gz: 330d44afc53a5214e4e95a3a5335f0fb83c3559fbdfd79d1ae215a030337269a6db68c48f277f216eb8fda2ce76144b742dda34290a37fd4559b8147765781b5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -180,11 +180,13 @@ describes mapping a resource key to a database column.
|
|
180
180
|
#### `capture_link_href <key>, as: <column>`
|
181
181
|
describes mapping a link href (as it appears on the hateous response) to a database column.
|
182
182
|
|
183
|
-
#### `link <key
|
183
|
+
#### `link <key>, enable_caching: <enable_caching> (default: false)`
|
184
184
|
describes materializing from a relation of the resource. This can be nested to any depth as shown above.
|
185
185
|
|
186
186
|
When inside the block of a `link` any other part of DSL can be used and will be evaluated in the context of the relation resource.
|
187
187
|
|
188
|
+
`<enable_caching>` is optional and false by default. If `true` then Routemaster cache will be used when available for linked resources.
|
189
|
+
|
188
190
|
### `materialize_link <key>, topic: <topic> (default: key)`
|
189
191
|
describes materializing the linked entity.
|
190
192
|
This simulates a `:noop` event on the given topic and the `url` of the
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 3.2.0
|
2
|
+
|
3
|
+
Features:
|
4
|
+
- For linked resources specified by `link` an option to `enable_caching` can now be explicitly set. This
|
5
|
+
tells Routemaster to use or not use the drain cache.
|
6
|
+
|
7
|
+
## 3.1.0
|
8
|
+
|
9
|
+
Features:
|
10
|
+
- Allow sidekiq options to be specified per materializer
|
11
|
+
- Materialist::EventHandler will infer the correct materializer class from the incoming topic
|
12
|
+
|
13
|
+
Notes:
|
14
|
+
|
15
|
+
Materialist::EventWorker has been moved to Materialist::Workers::Event, but the original has
|
16
|
+
been left there for backwards compatibility. It will be removed in a later major release.
|
17
|
+
|
1
18
|
## 3.0.0
|
2
19
|
|
3
20
|
Breaking change:
|
@@ -14,8 +14,8 @@ module Materialist
|
|
14
14
|
__materialist_dsl_mapping_stack.last << LinkHrefMapping.new(key: key, as: as)
|
15
15
|
end
|
16
16
|
|
17
|
-
def link(key)
|
18
|
-
link_mapping = LinkMapping.new(key: key)
|
17
|
+
def link(key, enable_caching: false)
|
18
|
+
link_mapping = LinkMapping.new(key: key, enable_caching: enable_caching)
|
19
19
|
__materialist_dsl_mapping_stack.last << link_mapping
|
20
20
|
__materialist_dsl_mapping_stack << link_mapping.mapping
|
21
21
|
yield
|
@@ -2,12 +2,13 @@ module Materialist
|
|
2
2
|
module Materializer
|
3
3
|
module Internals
|
4
4
|
class LinkMapping
|
5
|
-
def initialize(key:)
|
5
|
+
def initialize(key:, enable_caching: false)
|
6
6
|
@key = key
|
7
|
+
@enable_caching = enable_caching
|
7
8
|
@mapping = []
|
8
9
|
end
|
9
10
|
|
10
|
-
attr_reader :key, :mapping
|
11
|
+
attr_reader :key, :enable_caching, :mapping
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -134,7 +134,7 @@ module Materialist
|
|
134
134
|
end
|
135
135
|
when LinkMapping
|
136
136
|
resource.body._links.include?(m.key) ?
|
137
|
-
result.merge(build_attributes(
|
137
|
+
result.merge(build_attributes(linked_resource(resource, m), m.mapping || [])) :
|
138
138
|
result
|
139
139
|
else
|
140
140
|
result
|
@@ -142,8 +142,12 @@ module Materialist
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
def
|
146
|
-
|
145
|
+
def linked_resource(resource, mapping)
|
146
|
+
resource_at(resource.send(mapping.key).url, enable_caching: mapping.enable_caching)
|
147
|
+
end
|
148
|
+
|
149
|
+
def resource_at(url, enable_caching: false)
|
150
|
+
api_client.get(url, options: { enable_caching: enable_caching })
|
147
151
|
rescue Routemaster::Errors::ResourceNotFound
|
148
152
|
# this is due to a race condition between an upsert event
|
149
153
|
# and a :delete event
|
data/lib/materialist.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: materialist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mo Valipour
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
244
|
version: '0'
|
245
245
|
requirements: []
|
246
246
|
rubyforge_project:
|
247
|
-
rubygems_version: 2.6.
|
247
|
+
rubygems_version: 2.6.14.1
|
248
248
|
signing_key:
|
249
249
|
specification_version: 4
|
250
250
|
summary: Utilities to materialize routemaster topics
|