wcc-data 0.2.0 → 0.3.4

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
- SHA1:
3
- metadata.gz: 1d35f47f7f6962b5ddfc75e39b1acc45b7bc0feb
4
- data.tar.gz: 88c41cc3ce1c6156456bd46df5f49dbd05310846
2
+ SHA256:
3
+ metadata.gz: b3bd1429db7b56978ac63f3805717fcdc075859c32cfe643e240224b46c33813
4
+ data.tar.gz: 436884703d75eb088bc4370acc556984c91319ee467c128af18e7cc9c375bc4f
5
5
  SHA512:
6
- metadata.gz: b6e88816534473891adfe08e0dd0b253ed2c1195b0d899f6baeb8883c60b339ea62e89f7e17b59ab9b0d50d141a28b5797492c4b92c6c27af734c8759179e0e8
7
- data.tar.gz: ae4b3f86595a1f523572e100de67386cb23d9a9d175bfc67fc367f2ba8bcbbc008c0933a631eefa9e82d0999337f0a0a87ef808f987014b032ab0a0dc17e112d
6
+ metadata.gz: b031ce45a7ec2525693be1e54915705fc9d2814346157ae203d04f437400d7414952fceea456099414580d9f10465182b0af9574513e1b3b0ee9a0229b80aa7c
7
+ data.tar.gz: 15d5fd989316c8b83e61c1f6aca6a41851c356ba0cc5ff633e951902785c0d20455f3d533b0b4e7b59978921de7049abb6283c17981378d5e0977af956866413
@@ -15,6 +15,7 @@ module WCC::Data
15
15
  private
16
16
 
17
17
  def set_default_applications
18
+ raise ArgumentError, "Missing NUCLEUS_URL environment variable" unless ENV['NUCLEUS_URL']
18
19
  applications[:nucleus].uri = ENV['NUCLEUS_URL']
19
20
  if ENV['APP_CLIENT_ID'] && ENV['APP_CLIENT_SECRET']
20
21
  applications[:nucleus].connection
@@ -5,6 +5,7 @@ module WCC::Data
5
5
  class EndpointUndefined < MapperError; end
6
6
  class InvalidResponse < MapperError; end
7
7
  class RecordNotFound < MapperError; end
8
+ class ServiceUnavailable < MapperError; end
8
9
  end
9
10
 
10
11
  end
@@ -4,6 +4,7 @@ module WCC::Data::Mapper
4
4
 
5
5
  def new_from_response(response)
6
6
  raise RecordNotFound if response.status == 404
7
+ raise ServiceUnavailable if response.status == 503
7
8
  case response.json
8
9
  when Array
9
10
  response.json.collect { |obj| new(obj) }
@@ -1,47 +1,61 @@
1
- module WCC::Data::Nucleus
1
+ # frozen_string_literal: true
2
2
 
3
+ module WCC::Data::Nucleus
3
4
  class Campus < WCC::Data::EnumeratedType
4
- attributes :id, :name, :key
5
+ attributes :id, :name, :key, :code
5
6
  attributes :street, :city, :state, :zip, :geo
6
7
 
7
8
  def matches?(value)
8
- [id, key].include?(value)
9
+ [id, key, code].include?(value)
9
10
  end
10
11
 
11
12
  def self.db
12
13
  [
13
14
  {
14
15
  id: 1,
16
+ code: 'DAL',
15
17
  name: 'Dallas',
16
18
  key: :dallas,
17
19
  street: '7540 LBJ Freeway',
18
20
  city: 'Dallas',
19
21
  state: 'TX',
20
22
  zip: '75251',
21
- geo: [32.922923, -96.7781638],
23
+ geo: [32.922923, -96.7781638]
22
24
  },
23
25
  {
24
26
  id: 2,
27
+ code: 'FTW',
25
28
  name: 'Fort Worth',
26
29
  key: :ft_worth,
27
- street: '3345 Winthrop Avenue',
30
+ street: '8000 Western Hills Blvd',
28
31
  city: 'Fort Worth',
29
32
  state: 'TX',
30
- zip: '76116',
31
- geo: [32.7280064, -97.4146727],
33
+ zip: '76108',
34
+ geo: [32.739972, -97.455414]
32
35
  },
33
36
  {
34
37
  id: 3,
38
+ code: 'PLA',
35
39
  name: 'Plano',
36
40
  key: :plano,
37
41
  street: '6400 K Avenue',
38
42
  city: 'Plano',
39
43
  state: 'TX',
40
44
  zip: '75074',
41
- geo: [33.060823, -96.688902],
45
+ geo: [33.060823, -96.688902]
42
46
  },
47
+ {
48
+ id: 4,
49
+ code: 'FRS',
50
+ name: 'Frisco',
51
+ key: :frisco,
52
+ street: '6401 Parkwood Blvd',
53
+ city: 'Frisco',
54
+ state: 'TX',
55
+ zip: '75034',
56
+ geo: [33.130761, -96.822322]
57
+ }
43
58
  ]
44
59
  end
45
60
  end
46
-
47
61
  end
@@ -1,5 +1,5 @@
1
1
  module WCC
2
2
  module Data
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.3.4'.freeze
4
4
  end
5
5
  end
@@ -19,4 +19,6 @@ RSpec.configure do |config|
19
19
  config.filter_run :focus
20
20
 
21
21
  config.order = 'random'
22
+
23
+ ENV['NUCLEUS_URL'] ||= 'http://login.wcc'
22
24
  end
@@ -219,6 +219,19 @@ RSpec.describe WCC::Data::FaradayClientAppTokenAuth do
219
219
  expect(cache).to receive(:[]=).with("example.com", "abc123")
220
220
  auth.token_for("example.com")
221
221
  end
222
+
223
+ it "passes error up the chain when service unavailable" do
224
+ allow(auth.token_factory)
225
+ .to receive(:call)
226
+ .and_raise(WCC::Data::Mapper::ServiceUnavailable)
227
+
228
+ expect {
229
+ auth.call({
230
+ url: URI("http://example.com"),
231
+ request_headers: {},
232
+ })
233
+ }.to raise_error(WCC::Data::Mapper::ServiceUnavailable)
234
+ end
222
235
  end
223
236
  end
224
237
  end
@@ -41,6 +41,13 @@ describe WCC::Data::Mapper::JSONResponse do
41
41
 
42
42
  end
43
43
 
44
+ it "raises ServiceUnavailable when response status is 503" do
45
+ allow(singular_response).to receive(:status).and_return(503)
46
+ expect { klass.new_from_response(singular_response) }
47
+ .to raise_error(WCC::Data::Mapper::ServiceUnavailable)
48
+
49
+ end
50
+
44
51
  it "raises InvalidResponse error for non-json objects" do
45
52
  expect { klass.new_from_response(double(json: 1, status: 200)) }
46
53
  .to raise_error(WCC::Data::Mapper::InvalidResponse)
@@ -1,29 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe WCC::Data::Nucleus::Campus do
4
- it "inherits EnumeratedType functionality" do
4
+ it 'inherits EnumeratedType functionality' do
5
5
  expect(described_class.ancestors).to include(WCC::Data::EnumeratedType)
6
6
  end
7
7
 
8
- context "with defined data" do
9
-
10
- it "defines Dallas campus" do
11
- dallas = described_class[:dallas]
12
- expect(dallas).to be_a(described_class)
13
- expect(dallas.name).to eq("Dallas")
8
+ context 'with defined data' do
9
+ it 'defines Dallas campus' do
10
+ campus = described_class[:dallas]
11
+ expect(campus).to be_a(described_class)
12
+ expect(campus.name).to eq('Dallas')
14
13
  end
15
14
 
16
- it "defines Fort Worth campus" do
17
- dallas = described_class[:ft_worth]
18
- expect(dallas).to be_a(described_class)
19
- expect(dallas.name).to eq("Fort Worth")
15
+ it 'defines Fort Worth campus' do
16
+ campus = described_class[:ft_worth]
17
+ expect(campus).to be_a(described_class)
18
+ expect(campus.name).to eq('Fort Worth')
20
19
  end
21
20
 
22
- it "defines Plano campus" do
23
- dallas = described_class[:plano]
24
- expect(dallas).to be_a(described_class)
25
- expect(dallas.name).to eq("Plano")
21
+ it 'defines Plano campus' do
22
+ campus = described_class[:plano]
23
+ expect(campus).to be_a(described_class)
24
+ expect(campus.name).to eq('Plano')
26
25
  end
27
26
 
27
+ it 'defines Frisco campus' do
28
+ campus = described_class[:frisco]
29
+ expect(campus).to be_a(described_class)
30
+ expect(campus.name).to eq('Frisco')
31
+ expect(campus.code).to eq('FRS')
32
+ end
28
33
  end
29
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -157,7 +157,7 @@ homepage: ''
157
157
  licenses:
158
158
  - MIT
159
159
  metadata: {}
160
- post_install_message:
160
+ post_install_message:
161
161
  rdoc_options: []
162
162
  require_paths:
163
163
  - lib
@@ -172,9 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.6.11
177
- signing_key:
175
+ rubygems_version: 3.1.4
176
+ signing_key:
178
177
  specification_version: 4
179
178
  summary: Watermark's library for interapp communication via APIs
180
179
  test_files: