nuorder 1.0.1 → 1.1.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: 82d37e7d4377f396ca1f47291784e66a8076a714
4
- data.tar.gz: 306ff612b42231526622dfcc91ae286f6ed73927
3
+ metadata.gz: 9c9905d128b4337115539c618b22c2ab5dd3509a
4
+ data.tar.gz: 96474ad261bdf5de1c0b69873ae9d5e57f98b002
5
5
  SHA512:
6
- metadata.gz: ae864fd4c94248c4075ddc346b313c6dd9b6f3a15125272e1556dcdfe1093c6a6ff6ac31a84d2ee85b93da0abdd71d6930bd9a428ce4760a835c3cfa4c765bf1
7
- data.tar.gz: 37e775c988f9f7f0e7bb464a9c2abb75891582be319d0e0afdc35e702125966bd6cb63ffb55ab99ff8468cc7a66e4366bb18ea30a086486cbf702c2b656751a6
6
+ metadata.gz: 9ee768824c8f394b75663d190253690f7c807ef2bc16839e6a0fa1c5345b2537e7cd83b01152befc917efd07b135a8fbaf7df6878f49dc6d48ccec02f0dca6d0
7
+ data.tar.gz: 9824264e27139b65bf95227590f9010b31bbf787078d1866405e47045baed6b7eced36b142c7648f137bc43174d563cf405db6cf0167d8b781e2409a396fbb65
@@ -1,3 +1,7 @@
1
+ ## v1.1.0
2
+
3
+ * Allow multiple clients to be used simultaneously
4
+
1
5
  ## v1.0.0
2
6
 
3
7
  * Initial release
data/README.md CHANGED
@@ -37,7 +37,7 @@ The following options are available when configuring NuORDER:
37
37
  6. `oauth_token_secret`
38
38
  7. `oauth_callback` Default: `'oob'`
39
39
  * NuORDER will POST the callback the `oauth_verifier` token.
40
- * If the callback is set to `'oob'`, the `oauth_verifier` token must be supplied manually by the user.
40
+ * If the callback is set to `'oob'`, the `oauth_verifier` token must be supplied manually by the user.
41
41
 
42
42
  #### Example
43
43
 
@@ -66,7 +66,7 @@ To get the oauth tokens the following methods must be called:
66
66
  * An inital call will be made in order to get the temporary tokens.
67
67
  2. `Nuorder.get_oauth_token(oauth_verifier)`
68
68
  * Call for getting the permanent tokens.
69
- * `oauth_verifier` must be supplied.
69
+ * `oauth_verifier` must be supplied.
70
70
 
71
71
  Retrieve tokens:
72
72
 
@@ -8,6 +8,10 @@ module Nuorder
8
8
  extend Nuorder::Configurable
9
9
 
10
10
  class << self
11
+ def new(options = {})
12
+ Nuorder::Client.new(options)
13
+ end
14
+
11
15
  def client
12
16
  @client = Nuorder::Client.new(options) unless defined?(@client) && @client.same_options?(options)
13
17
  @client
@@ -21,7 +25,4 @@ module Nuorder
21
25
  client.send(method_name, *args, &block)
22
26
  end
23
27
  end
24
-
25
28
  end
26
-
27
- Nuorder.setup
@@ -11,6 +11,7 @@ module Nuorder
11
11
  include Nuorder::Client::Oauth
12
12
 
13
13
  def initialize(options = {})
14
+ options = Nuorder::Default.options.merge(options)
14
15
  set_instance_variables(options)
15
16
  end
16
17
 
@@ -23,8 +24,8 @@ module Nuorder
23
24
  headers = oauth_headers('GET', '/api/initiate', addons)
24
25
  response = connection.get '/api/initiate', {}, headers
25
26
 
26
- Nuorder.oauth_token = response.body['oauth_token']
27
- Nuorder.oauth_token_secret = response.body['oauth_token_secret']
27
+ @oauth_token = response.body['oauth_token']
28
+ @oauth_token_secret = response.body['oauth_token_secret']
28
29
 
29
30
  response
30
31
  end
@@ -35,8 +36,8 @@ module Nuorder
35
36
  headers = oauth_headers('GET', '/api/token', { 'oauth_verifier' => oauth_verifier })
36
37
  response = connection.get '/api/token', {}, headers
37
38
 
38
- Nuorder.oauth_token = response.body['oauth_token']
39
- Nuorder.oauth_token_secret = response.body['oauth_token_secret']
39
+ @oauth_token = response.body['oauth_token']
40
+ @oauth_token_secret = response.body['oauth_token_secret']
40
41
 
41
42
  response
42
43
  end
@@ -65,10 +66,10 @@ module Nuorder
65
66
 
66
67
  private
67
68
 
68
- # Set instance variables passed in options, but fallback to module defaults
69
+ # Set instance variables passed in options
69
70
  def set_instance_variables(options)
70
71
  Nuorder::Configurable.keys.each do |key|
71
- instance_variable_set(:"@#{key}", options[key] || Nuorder.instance_variable_get(:"@#{key}"))
72
+ instance_variable_set(:"@#{key}", options[key])
72
73
  end
73
74
  end
74
75
 
@@ -1,3 +1,3 @@
1
1
  module Nuorder
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -1,54 +1,48 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Nuorder::Client do
4
- before do
5
- Nuorder.reset!
6
- end
7
-
8
- after do
9
- Nuorder.reset!
10
- end
11
-
12
4
  include_examples 'options client'
13
5
 
14
6
  specify { expect { described_class.new }.not_to raise_error }
15
-
7
+
16
8
  subject(:client) do
17
9
  described_class.new(options_client)
18
10
  end
19
11
 
20
12
  describe 'module configuration' do
21
- before do
22
- Nuorder.reset!
23
- Nuorder.configure do |config|
24
- Nuorder::Configurable.keys.each do |key|
25
- config.send("#{key}=", "Some #{key}")
26
- end
27
- end
13
+ let (:opts) do
14
+ {
15
+ app_name: 'My APP',
16
+ oauth_callback: 'app.example.com/callback',
17
+ oauth_consumer_key: 'asdfa232042sdafal'
18
+ }
28
19
  end
29
20
 
30
- after do
31
- Nuorder.reset!
32
- end
21
+ describe 'with options' do
22
+ it "doesn't share state with global options" do
23
+ client = Nuorder::Client.new(opts)
33
24
 
34
- it 'inherits the module configuration' do
35
- client = Nuorder::Client.new
36
- Nuorder::Configurable.keys.each do |key|
37
- expect(client.instance_variable_get(:"@#{key}")).to eq("Some #{key}")
25
+ Nuorder.configure do |config|
26
+ config.app_name = 'Nuorder app'
27
+ end
28
+ expect(client.app_name).to eq('My APP')
38
29
  end
39
- end
40
30
 
41
- describe 'with options' do
42
- let (:opts) do
43
- {
44
- app_name: 'My APP',
45
- oauth_callback: 'app.example.com/callback',
46
- oauth_consumer_key: 'asdfa232042sdafal'
47
- }
31
+ it 'overrides module configuration' do
32
+ client = Nuorder::Client.new(opts)
33
+ expect(client.app_name).to eq('My APP')
34
+ expect(client.oauth_callback).to eq('app.example.com/callback')
35
+ expect(client.oauth_consumer_key).to eq('asdfa232042sdafal')
48
36
  end
37
+ end
49
38
 
39
+ describe '#configure' do
50
40
  it 'overrides module configuration' do
51
- client = Nuorder::Client.new(opts)
41
+ client.configure do |config|
42
+ config.app_name = opts[:app_name]
43
+ config.oauth_callback = opts[:oauth_callback]
44
+ config.oauth_consumer_key = opts[:oauth_consumer_key]
45
+ end
52
46
  expect(client.app_name).to eq('My APP')
53
47
  expect(client.oauth_callback).to eq('app.example.com/callback')
54
48
  expect(client.oauth_consumer_key).to eq('asdfa232042sdafal')
@@ -57,30 +51,29 @@ describe Nuorder::Client do
57
51
  end
58
52
 
59
53
  describe '#api_initiate' do
60
- before do
61
- Nuorder.configure do |config|
62
- config.oauth_token = nil
63
- config.oauth_token_secret = nil
64
- end
54
+ let(:client) do
55
+ described_class.new(
56
+ options_client.merge(oauth_token: nil, oauth_token_secret: nil)
57
+ )
65
58
  end
66
59
 
67
60
  it 'returns temp oauth_token and oauth_token_secret from API', :vcr do
68
61
  client.api_initiate
69
62
 
70
- expect(Nuorder.oauth_token).not_to be_nil
71
- expect(Nuorder.oauth_token_secret).not_to be_nil
63
+ expect(client.oauth_token).not_to be_nil
64
+ expect(client.oauth_token_secret).not_to be_nil
72
65
  end
73
66
  end
74
-
67
+
75
68
  describe '#get_oauth_token' do
76
69
  it 'returns real oauth_token and oauth_token_secret from API', :vcr do
77
70
  oauth_verifier = 'aKRzurszYEA9mpun'
78
- Nuorder.oauth_token = 'p5UzX46KqwdB5Bj3'
79
- Nuorder.oauth_token_secret = 'YaRS2Vy9uSEDVhwu95NaCDPQ'
80
-
71
+ client.oauth_token = 'p5UzX46KqwdB5Bj3'
72
+ client.oauth_token_secret = 'YaRS2Vy9uSEDVhwu95NaCDPQ'
73
+
81
74
  client.get_oauth_token(oauth_verifier)
82
- expect(Nuorder.oauth_token).not_to be_nil
83
- expect(Nuorder.oauth_token_secret).not_to be_nil
75
+ expect(client.oauth_token).not_to be_nil
76
+ expect(client.oauth_token_secret).not_to be_nil
84
77
  end
85
78
 
86
79
  context 'no oauth_verifier provided' do
@@ -1,17 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Nuorder do
4
- before do
5
- Nuorder.reset!
6
- end
7
-
8
- after do
9
- Nuorder.reset!
10
- end
11
-
12
- it 'sets defaults' do
13
- Nuorder::Configurable.keys.each do |key|
14
- expect(Nuorder.instance_variable_get(:"@#{key}")).to eq(Nuorder::Default.options[key])
4
+ describe '#new' do
5
+ it 'creates a Nuorder::Client' do
6
+ expect(Nuorder.new).to be_kind_of Nuorder::Client
15
7
  end
16
8
  end
17
9
 
@@ -44,5 +36,4 @@ describe Nuorder do
44
36
  end
45
37
  end
46
38
  end
47
-
48
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Springboard Retail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-06 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler