materialist 3.4.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/RELEASE_NOTES.md +4 -0
- data/lib/configuration.rb +4 -1
- data/lib/materialist.rb +1 -1
- data/lib/materialist/materialized_record.rb +1 -4
- data/lib/materialist/materializer/internals/link_mapping.rb +1 -1
- data/lib/materialist/materializer/internals/materializer.rb +2 -3
- data/lib/materialist/version.rb +3 -0
- data/materialist.gemspec +1 -1
- data/spec/materialist/materializer/internals/link_mapping_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad5a7f5ef0961f9e8cf3317baaf07cbb53d8e021
|
4
|
+
data.tar.gz: 394077c4817dd29106c78f02124f6c145ab6dafd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc7dd6e7563ec9205631a5f8520c6928b8ca10c269c3c8f74cb2093080e500878b8a5220ae5fabab1a985090d8f66ffcd55dac2fdaed4253a6de679601ade13
|
7
|
+
data.tar.gz: 4d293933436137b9daf41d3de5117eeb707653d0ce73f7865356d5fe1bfad6b8354a4073ae1ecfeec3adae7ad1c4b7ad38a2713f6668ca7a7b9d77e956e1fcfa
|
data/README.md
CHANGED
@@ -73,12 +73,14 @@ Materialist.configure do |config|
|
|
73
73
|
# }
|
74
74
|
#
|
75
75
|
# config.metrics_client = STATSD
|
76
|
+
# config.api_client = Routemaster::APIClient.new(response_class: Routemaster::Responses::HateoasResponse)
|
76
77
|
end
|
77
78
|
```
|
78
79
|
|
79
80
|
- `topics` (only when using in `.subscribe`): A string array of topics to be used.
|
80
81
|
If not provided nothing would be materialized.
|
81
82
|
- `sidekiq_options` (optional, default: `{ retry: 10 }`) -- See [Sidekiq docs](https://github.com/mperham/sidekiq/wiki/Advanced-Options#workers) for list of options
|
83
|
+
- `api_client` (optional) -- You can pass your `Routemaster::APIClient` instance
|
82
84
|
- `metrics_client` (optional) -- You can pass your `STATSD` instance
|
83
85
|
- `notice_error` (optional) -- You can pass a lambda accepting two parameters (`exception` and `event`) -- Typical use case is to enrich error and send to NewRelic APM
|
84
86
|
|
data/RELEASE_NOTES.md
CHANGED
data/lib/configuration.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'routemaster/api_client'
|
2
|
+
|
1
3
|
module Materialist
|
2
4
|
class << self
|
3
5
|
def configuration
|
@@ -14,11 +16,12 @@ module Materialist
|
|
14
16
|
end
|
15
17
|
|
16
18
|
class Configuration
|
17
|
-
attr_accessor :topics, :sidekiq_options, :metrics_client, :notice_error
|
19
|
+
attr_accessor :topics, :sidekiq_options, :api_client, :metrics_client, :notice_error
|
18
20
|
|
19
21
|
def initialize
|
20
22
|
@topics = []
|
21
23
|
@sidekiq_options = {}
|
24
|
+
@api_client = Routemaster::APIClient.new(response_class: ::Routemaster::Responses::HateoasResponse)
|
22
25
|
@metrics_client = NullMetricsClient
|
23
26
|
@notice_error = nil
|
24
27
|
end
|
data/lib/materialist.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'routemaster/api_client'
|
2
1
|
require_relative './errors'
|
3
2
|
|
4
3
|
module Materialist
|
@@ -35,9 +34,7 @@ module Materialist
|
|
35
34
|
private
|
36
35
|
|
37
36
|
def source_raw
|
38
|
-
|
39
|
-
response_class: Routemaster::Responses::HateoasResponse
|
40
|
-
).get(source_url)
|
37
|
+
Materialist.configuration.api_client.get(source_url)
|
41
38
|
end
|
42
39
|
end
|
43
40
|
end
|
@@ -17,7 +17,7 @@ module Materialist
|
|
17
17
|
|
18
18
|
def linked_resource(resource)
|
19
19
|
return unless href = resource.dig(:_links, @key, :href)
|
20
|
-
resource.client.get(href, options: { enable_caching: @enable_caching })
|
20
|
+
resource.client.get(href, options: { enable_caching: @enable_caching, response_class: HateoasResource })
|
21
21
|
rescue Routemaster::Errors::ResourceNotFound
|
22
22
|
nil
|
23
23
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'routemaster/api_client'
|
2
1
|
require_relative '../../workers/event'
|
3
2
|
require_relative './resources'
|
4
3
|
|
@@ -10,7 +9,7 @@ module Materialist
|
|
10
9
|
@url = url
|
11
10
|
@instance = klass.new
|
12
11
|
@options = klass.__materialist_options
|
13
|
-
@api_client = api_client ||
|
12
|
+
@api_client = api_client || Materialist.configuration.api_client
|
14
13
|
if resource_payload
|
15
14
|
@resource = PayloadResource.new(resource_payload, client: @api_client)
|
16
15
|
end
|
@@ -124,7 +123,7 @@ module Materialist
|
|
124
123
|
end
|
125
124
|
|
126
125
|
def fetch_resource
|
127
|
-
api_client.get(url, options: { enable_caching: false })
|
126
|
+
api_client.get(url, options: { enable_caching: false, response_class: HateoasResource })
|
128
127
|
rescue Routemaster::Errors::ResourceNotFound
|
129
128
|
nil
|
130
129
|
end
|
data/materialist.gemspec
CHANGED
@@ -76,7 +76,7 @@ RSpec.describe Materialist::Materializer::Internals::LinkMapping, type: :interna
|
|
76
76
|
|
77
77
|
it 'passes on the option to client' do
|
78
78
|
expect(client).to receive(:get)
|
79
|
-
.with(url_sub, options: { enable_caching: true})
|
79
|
+
.with(url_sub, options: { enable_caching: true, response_class: HateoasResource})
|
80
80
|
perform
|
81
81
|
end
|
82
82
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,6 +8,7 @@ require 'webmock/rspec'
|
|
8
8
|
require 'dotenv'
|
9
9
|
require 'pry'
|
10
10
|
Dotenv.overload('.env.test')
|
11
|
+
require 'materialist'
|
11
12
|
|
12
13
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
13
14
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
@@ -21,7 +22,7 @@ RSpec.configure do |config|
|
|
21
22
|
|
22
23
|
config.before(:each) do
|
23
24
|
Materialist.reset_configuration!
|
24
|
-
|
25
|
+
|
25
26
|
# clear database
|
26
27
|
ActiveRecord::Base.descendants.each(&:delete_all)
|
27
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.
|
4
|
+
version: 3.5.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-
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/materialist/materializer/internals/materializer.rb
|
215
215
|
- lib/materialist/materializer/internals/resources.rb
|
216
216
|
- lib/materialist/materializer_factory.rb
|
217
|
+
- lib/materialist/version.rb
|
217
218
|
- lib/materialist/workers/event.rb
|
218
219
|
- materialist.gemspec
|
219
220
|
- spec/materialist/event_handler_spec.rb
|