materialist 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99e85711c6de342809785430291c11d6a11b3379
4
- data.tar.gz: d6b3f3bfecd9ce4b20ee699c3a75028294f7ab5f
3
+ metadata.gz: 8665cde57cae1468db10b2d04ca02ee83baccef5
4
+ data.tar.gz: a2fe18fbfdb6e1aa039b3c1dc9a5c7150e67acf0
5
5
  SHA512:
6
- metadata.gz: 498ac330b0331c78ab2ce69aa71dbc0c3ddb0e5277711c0f9f1b4c836f4c810c9ae1f9df4e46c2a83ba1690817fe07cc97d694f10f3718728619c26719fd4ffe
7
- data.tar.gz: d5e784ae7827bdc7defff614a3d47601efc4035f965e679c9ea4ad639ebc558440c1740556fead09f6788f66f3045b9ab9b037c822101ed95a41b6147263d986
6
+ metadata.gz: c630af56d05969a23fc7a19149b588eeda385e4d30f494f123ef7cc8f4971f7352fab65b81b6d92cbba919fe3d3e4a68bfa886638854b3997bff05836a224cc8
7
+ data.tar.gz: 330d44afc53a5214e4e95a3a5335f0fb83c3559fbdfd79d1ae215a030337269a6db68c48f277f216eb8fda2ce76144b742dda34290a37fd4559b8147765781b5
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.4.4
data/.travis.yml CHANGED
@@ -1,9 +1,8 @@
1
1
  language: ruby
2
- cache: bundler
3
2
  services:
4
3
  - redis-server
5
4
  rvm:
6
- - 2.4.0
7
- - 2.5.0
5
+ - 2.4.4
6
+ - 2.5.1
8
7
  script:
9
8
  - bundle exec rspec
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(resource_at(resource.send(m.key).url), m.mapping || [])) :
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 resource_at(url)
146
- api_client.get(url, options: { enable_caching: false })
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
@@ -1,5 +1,5 @@
1
1
  require_relative './configuration'
2
2
 
3
3
  module Materialist
4
- VERSION = '3.1.0'
4
+ VERSION = '3.2.0'
5
5
  end
@@ -22,7 +22,7 @@ RSpec.describe Materialist::Materializer do
22
22
  link :city do
23
23
  capture :timezone
24
24
 
25
- link :country do
25
+ link :country, enable_caching: true do
26
26
  capture :tld, as: :country_tld
27
27
  end
28
28
  end
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.1.0
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-04 00:00:00.000000000 Z
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.13
247
+ rubygems_version: 2.6.14.1
248
248
  signing_key:
249
249
  specification_version: 4
250
250
  summary: Utilities to materialize routemaster topics