artirix_data_models 0.19.2 → 0.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26d379b0521a56ea1126abf27cfc0e8bf19cb8f0
4
- data.tar.gz: 1deccaa8e4f4eca4f809e11259aa56159601bb35
3
+ metadata.gz: d6a0efe535f958e9d7c4e23504add310d21bb9a4
4
+ data.tar.gz: 3978b682cccc7694680ec9268d4a3d3f09e44c77
5
5
  SHA512:
6
- metadata.gz: f1806c29c53662ddf6ea7ebb32b274da367fc6abaf9c4bbe8a28da429ad5bd74716773fc80d35d9e1712ad8f69a8580b844990d0cec8d94d0df4477ed164df5a
7
- data.tar.gz: 22ae762e1959c0897698a1442a85e2c3da9f1656c118dd391577f85cd08f027b630614b93048341e94817e06a6ab80e69d5a3ccb5ba39bd8f39db26eddbdf32e
6
+ metadata.gz: 0af80ece0e4b1797bf39f35150fedbe5f50dbe81ae8a6dba1bad6a7a7ab1fbee31b391826450afdbaa25c555748e33f914757bb175a95cd6cbb5e322f5cfdfb8
7
+ data.tar.gz: 61f793fd6c07f5c4d3a763d29ae1810c606bf464340deffc8d749abd7e9c326c99d3edaf7f76a416ac50b3127bada35cbeba36f56d36e7cc6ef910146b2da7e2
data/.gitignore CHANGED
@@ -13,4 +13,5 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  .idea
16
- /manual_sandbox.rb
16
+ /manual_sandbox.rb
17
+ .ruby-version
data/README.md CHANGED
@@ -315,6 +315,14 @@ end
315
315
 
316
316
  ## Changes
317
317
 
318
+ ### 0.20.0
319
+ Added `ensure_relative` boolean option to the creation of a `DataGateway` (disable by default). With it enabled, it will ensure that any given `path` is relative by removing the leading `/`. This is necessary if the Gateway should call a nested endpoint and not just a host.
320
+
321
+ Example: If we have `"http://example.org/api/"` as connection's URL, and path `"/people/1"`, with this:
322
+
323
+ - `ensure_relative = true` => it will connect to `"http://example.org/api/people/1"`
324
+ - `ensure_relative = false` (default) => it will connect to `"http://example.org/people/1"`
325
+
318
326
  ### 0.19.2
319
327
  Added array support to `inspect`.
320
328
 
@@ -3,6 +3,7 @@ class ArtirixDataModels::DataGateway
3
3
 
4
4
  def initialize(connection: nil,
5
5
  post_as_json: true,
6
+ ensure_relative: false,
6
7
  timeout: nil,
7
8
  authorization_bearer: nil,
8
9
  authorization_token_hash: nil)
@@ -11,6 +12,11 @@ class ArtirixDataModels::DataGateway
11
12
  @authorization_bearer = authorization_bearer
12
13
  @authorization_token_hash = authorization_token_hash
13
14
  @timeout = timeout
15
+ @ensure_relative = !!ensure_relative
16
+ end
17
+
18
+ def ensure_relative?
19
+ !!@ensure_relative
14
20
  end
15
21
 
16
22
  def get(path, **opts)
@@ -41,6 +47,7 @@ class ArtirixDataModels::DataGateway
41
47
  authorization_bearer: nil,
42
48
  authorization_token_hash: nil,
43
49
  **_ignored_options)
50
+
44
51
  if fake
45
52
  result = fake_response.respond_to?(:call) ? fake_response.call : fake_response
46
53
 
@@ -125,6 +132,10 @@ class ArtirixDataModels::DataGateway
125
132
  authorization_bearer = authorization_bearer.nil? ? @authorization_bearer : authorization_bearer
126
133
  authorization_token_hash = authorization_token_hash.nil? ? @authorization_token_hash : authorization_token_hash
127
134
 
135
+ if ensure_relative?
136
+ path = path.to_s.start_with?('/') ? path.to_s[1..-1] : path
137
+ end
138
+
128
139
  connection.send(method, path) do |req|
129
140
 
130
141
  req.options.timeout = timeout if timeout.present?
@@ -246,7 +257,7 @@ class ArtirixDataModels::DataGateway
246
257
 
247
258
  raise InvalidConnectionError, 'no url given, nor is it present in `config.url`' unless url.present?
248
259
 
249
- Faraday.new(url: url, request: { params_encoder: Faraday::FlatParamsEncoder }) do |faraday|
260
+ Faraday.new(url: url, request: {params_encoder: Faraday::FlatParamsEncoder}) do |faraday|
250
261
  faraday.request :url_encoded # form-encode POST params
251
262
  faraday.response :logger # log requests to STDOUT
252
263
 
@@ -1,3 +1,3 @@
1
1
  module ArtirixDataModels
2
- VERSION = '0.19.2'
2
+ VERSION = '0.20.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artirix_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.2
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Turiño
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport