wcc-data 0.2.0 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/wcc/data/config.rb +1 -0
- data/lib/wcc/data/mapper.rb +1 -0
- data/lib/wcc/data/mapper/json_response.rb +1 -0
- data/lib/wcc/data/nucleus/campus.rb +23 -9
- data/lib/wcc/data/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/wcc/data/faraday_client_app_token_auth_spec.rb +13 -0
- data/spec/wcc/data/mapper/json_response_spec.rb +7 -0
- data/spec/wcc/data/nucleus/campus_spec.rb +20 -15
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b3bd1429db7b56978ac63f3805717fcdc075859c32cfe643e240224b46c33813
|
4
|
+
data.tar.gz: 436884703d75eb088bc4370acc556984c91319ee467c128af18e7cc9c375bc4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b031ce45a7ec2525693be1e54915705fc9d2814346157ae203d04f437400d7414952fceea456099414580d9f10465182b0af9574513e1b3b0ee9a0229b80aa7c
|
7
|
+
data.tar.gz: 15d5fd989316c8b83e61c1f6aca6a41851c356ba0cc5ff633e951902785c0d20455f3d533b0b4e7b59978921de7049abb6283c17981378d5e0977af956866413
|
data/lib/wcc/data/config.rb
CHANGED
@@ -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
|
data/lib/wcc/data/mapper.rb
CHANGED
@@ -1,47 +1,61 @@
|
|
1
|
-
|
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: '
|
30
|
+
street: '8000 Western Hills Blvd',
|
28
31
|
city: 'Fort Worth',
|
29
32
|
state: 'TX',
|
30
|
-
zip: '
|
31
|
-
geo: [32.
|
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
|
data/lib/wcc/data/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -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
|
4
|
+
it 'inherits EnumeratedType functionality' do
|
5
5
|
expect(described_class.ancestors).to include(WCC::Data::EnumeratedType)
|
6
6
|
end
|
7
7
|
|
8
|
-
context
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
expect(
|
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
|
17
|
-
|
18
|
-
expect(
|
19
|
-
expect(
|
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
|
23
|
-
|
24
|
-
expect(
|
25
|
-
expect(
|
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.
|
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:
|
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
|
-
|
176
|
-
|
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:
|