ngp_van 0.1.4 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc4179ff3f02740356fc7b67f96675d5b325f926e823f0e6f7812c9a41ff9bd1
4
- data.tar.gz: 7da8f49cae19986672767a7b22c9fa946b2c3dd058890d7780a382af9cb84180
3
+ metadata.gz: 49541631c032128c94d612b0934327512578a7f49e0ed7d0c143ffdcd4a9db71
4
+ data.tar.gz: 4965a5ac2d4fee4079a605870904745f6a6249fc6d6d4a44a484bc2bb8e33fe1
5
5
  SHA512:
6
- metadata.gz: 555ec264ed44993358407638765b7a9706bd44054873c5fcb2680967b6a2759c57f5ae1253c0b5c3b0c1c087ab7cf204cdd7a0ea8239f8083185a1db4378a6dd
7
- data.tar.gz: c953469ca7ced2c3303619bd48097b64528f633740a8a8d2449c56179281c29d43547c19e25092c13bd02d7fba3b5ba52c736777ea26c155dca34d741c9f0a59
6
+ metadata.gz: 03ab10c4f055ce52c29e9e463a55a52e3fcf6e1ec55fdf52d25b08affd9a7d17e78922df2d783638635c2faedf19d41c9b6f841fbdc72922d39c3fa6ab3a151a
7
+ data.tar.gz: a64f5bb442fb98d4be32de10a892fc69536a1e096683e288bde9b61403ba092f69ef31415115b982faa29d5d4dd98729a52d49e0743c50d8b6adf1c31719e13d
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -60,6 +60,17 @@ Options can also be set on the configuration object:
60
60
  # => "de286a1a-f2e7-421a-91b8-f8cc8201558f|1"
61
61
  ```
62
62
 
63
+ In a multi-threaded environment you may want to use multiple configurations simultaneously.
64
+ In that case, pass an appropriately setup configuration class to the client object.
65
+
66
+ ```ruby
67
+ configuration = NgpVan::Configuration.new
68
+ configuration.api_key = 'de286a1a-f2e7-421a-91b8-f8cc8201558f|1'
69
+ client = NgpVan::Client.new(configuration)
70
+ client.district_fields
71
+
72
+ ```
73
+
63
74
  ## Making requests
64
75
 
65
76
  API Methods can be called as module methods or as instance methods on the client.
@@ -20,6 +20,15 @@ require 'ngp_van/client/users'
20
20
 
21
21
  module NgpVan
22
22
  class Client
23
+
24
+ def initialize(configuration = nil)
25
+ @config = configuration
26
+ end
27
+
28
+ def config
29
+ @config || NgpVan.configuration
30
+ end
31
+
23
32
  include NgpVan::Connection
24
33
  include NgpVan::Request
25
34
  include NgpVan::Response
@@ -10,17 +10,17 @@ module NgpVan
10
10
  # rubocop:disable Metrics/MethodLength
11
11
  def connection
12
12
  options = {
13
- url: NgpVan.configuration.api_endpoint,
13
+ url: config.api_endpoint,
14
14
  headers: {
15
15
  'Accept' => 'application/json; charset=utf-8',
16
- 'User-Agent' => NgpVan.configuration.user_agent
16
+ 'User-Agent' => config.user_agent
17
17
  }
18
18
  }
19
19
 
20
20
  Faraday::Connection.new(options) do |connection|
21
21
  connection.basic_auth(
22
- NgpVan.configuration.application_name,
23
- NgpVan.configuration.api_key
22
+ config.application_name,
23
+ config.api_key
24
24
  )
25
25
 
26
26
  connection.request(:json)
@@ -7,11 +7,11 @@ module NgpVan
7
7
 
8
8
  # Current minor release.
9
9
  # @return [Integer]
10
- MINOR = 1
10
+ MINOR = 2
11
11
 
12
12
  # Current patch level.
13
13
  # @return [Integer]
14
- PATCH = 4
14
+ PATCH = 0
15
15
 
16
16
  # Full release version.
17
17
  # @return [String]
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ module NgpVan
6
+ RSpec.describe Client do
7
+ describe 'initialization' do
8
+ describe 'with a specified configuration' do
9
+ let(:config) { NgpVan::Configuration.new }
10
+
11
+ subject { NgpVan::Client.new(config) }
12
+
13
+ it 'should accept and store as config' do
14
+ expect(subject.config).to eq(config)
15
+ end
16
+ end
17
+
18
+ describe 'without a specified config' do
19
+ it 'should get the default' do
20
+ expect(subject.config).to eq(NgpVan.configuration)
21
+ end
22
+ end
23
+ end
24
+
25
+ describe 'usage' do
26
+ it 'should be possible to build a config and use it per client' do
27
+ configuration = NgpVan::Configuration.new
28
+ configuration.user_agent = 'test agent'
29
+ client = NgpVan::Client.new(configuration)
30
+ expect(client.config.user_agent).to eq('test agent')
31
+ end
32
+ end
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ngp_van
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Styles
@@ -36,7 +36,7 @@ cert_chain:
36
36
  uZ9aI1c3Tt/pkw9HxXwDo1m/+BQOZkAhEZu6LQQgBPAX8hlUyDw54SoJtfnFp0FI
37
37
  Hje6PutFGypAA8f9kmLl8X2Eu74D8PI9ywc=
38
38
  -----END CERTIFICATE-----
39
- date: 2018-05-02 00:00:00.000000000 Z
39
+ date: 2018-11-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday
@@ -124,6 +124,7 @@ files:
124
124
  - spec/ngp_van/client/signups_spec.rb
125
125
  - spec/ngp_van/client/survey_questions_spec.rb
126
126
  - spec/ngp_van/client/users_spec.rb
127
+ - spec/ngp_van/client_spec.rb
127
128
  - spec/ngp_van/configuration_spec.rb
128
129
  - spec/ngp_van/request_spec.rb
129
130
  - spec/ngp_van_spec.rb
@@ -195,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  version: '0'
196
197
  requirements: []
197
198
  rubyforge_project:
198
- rubygems_version: 2.7.2
199
+ rubygems_version: 2.7.6
199
200
  signing_key:
200
201
  specification_version: 4
201
202
  summary: Ruby wrapper for the NGP VAN API
metadata.gz.sig CHANGED
Binary file