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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4b55d54d4aa9644e1fee1055286166521f97120
4
- data.tar.gz: ed6c12846d2b859f49efdb7b5b9581184cafa4ea
3
+ metadata.gz: ad5a7f5ef0961f9e8cf3317baaf07cbb53d8e021
4
+ data.tar.gz: 394077c4817dd29106c78f02124f6c145ab6dafd
5
5
  SHA512:
6
- metadata.gz: f3a97dd8a5a618d2600d23d3259979dcf3698860c83794f0314387db616b6ca8635a15dbe7caf5bfd5082426292682241d343e7c9de39a2ab8128facf320d912
7
- data.tar.gz: 0b61ede028064fcd5e4aa8fc2a4040e2beb8f04e7b3606f723a68fd1e064472eb57faf8f39219a95f7f8b274a666f41045a7630392cc262e8a3bc161680d5249
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
@@ -2,6 +2,10 @@
2
2
 
3
3
  _description of next release_
4
4
 
5
+ ## 3.5.0
6
+
7
+ - Add support for providing an `Routemaster::APIClient` instance as part of configuration
8
+
5
9
  ## 3.4.0
6
10
 
7
11
  - Add support for providing payload into the materializer
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,5 +1,5 @@
1
1
  require_relative './configuration'
2
+ require_relative './materialist/version'
2
3
 
3
4
  module Materialist
4
- VERSION = '3.4.0'
5
5
  end
@@ -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
- Routemaster::APIClient.new(
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 || Routemaster::APIClient.new(response_class: HateoasResource)
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
@@ -0,0 +1,3 @@
1
+ module Materialist
2
+ VERSION = '3.5.0'
3
+ end
data/materialist.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'materialist'
4
+ require 'materialist/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'materialist'
@@ -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.0
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-05-24 00:00:00.000000000 Z
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