wcc-data 0.3.0 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de49f3e6cc7c8a7fa683659f77a77937fb06056f
4
- data.tar.gz: 6114a2ecf6df061a1f3d8872564ee040c014c89d
3
+ metadata.gz: 39a665f64fbf3ac5462d30ee8cddb5b731bee873
4
+ data.tar.gz: 8f03627d504911d6fe1042367d0eae6822f5b43f
5
5
  SHA512:
6
- metadata.gz: ae688de645b149f2f823dc4f27dbc29eb530ecd79786962fd00ef8dd2936941d7d55178b71161145135672bb2b6fa8bd113db1613c786a362c501e6ed103f406
7
- data.tar.gz: 72e1bd40dd55541460679cf6af7a767f22662246dd615c8f6e1a487ce8da20860f2de05690dcf48399ebb587842232bf3cf1ddbe4b49232e7c316ceb61856a6b
6
+ metadata.gz: 73b23c3605d3089d851f7b11c617830d80d78c53fa316accbbbd0b5d201be3327073afe17bce9574df39f897559852fff954f1aba916320af58f03e9239ce224
7
+ data.tar.gz: eb73ffb67a91ed15f64d736962a9ac1e0ea8bc2c80b38f2d28136a90b3e14acb4d348de3b300d6592af18da562b93435b0a04d60a374fef63e5753147b6c6176
@@ -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) }
@@ -2,17 +2,18 @@
2
2
 
3
3
  module WCC::Data::Nucleus
4
4
  class Campus < WCC::Data::EnumeratedType
5
- attributes :id, :name, :key
5
+ attributes :id, :name, :key, :code
6
6
  attributes :street, :city, :state, :zip, :geo
7
7
 
8
8
  def matches?(value)
9
- [id, key].include?(value)
9
+ [id, key, code].include?(value)
10
10
  end
11
11
 
12
12
  def self.db
13
13
  [
14
14
  {
15
15
  id: 1,
16
+ code: 'DAL',
16
17
  name: 'Dallas',
17
18
  key: :dallas,
18
19
  street: '7540 LBJ Freeway',
@@ -23,16 +24,18 @@ module WCC::Data::Nucleus
23
24
  },
24
25
  {
25
26
  id: 2,
27
+ code: 'FTW',
26
28
  name: 'Fort Worth',
27
29
  key: :ft_worth,
28
- street: '3345 Winthrop Avenue',
30
+ street: '8000 Western Hills Blvd',
29
31
  city: 'Fort Worth',
30
32
  state: 'TX',
31
- zip: '76116',
32
- geo: [32.7280064, -97.4146727]
33
+ zip: '76108',
34
+ geo: [32.739972, -97.455414]
33
35
  },
34
36
  {
35
37
  id: 3,
38
+ code: 'PLA',
36
39
  name: 'Plano',
37
40
  key: :plano,
38
41
  street: '6400 K Avenue',
@@ -43,6 +46,7 @@ module WCC::Data::Nucleus
43
46
  },
44
47
  {
45
48
  id: 4,
49
+ code: 'FRS',
46
50
  name: 'Frisco',
47
51
  key: :frisco,
48
52
  street: '6401 Parkwood Blvd',
@@ -1,5 +1,5 @@
1
1
  module WCC
2
2
  module Data
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.5'.freeze
4
4
  end
5
5
  end
data/wcc-data.gemspec CHANGED
@@ -13,10 +13,9 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.files = Dir['lib/**/*'] + %w[LICENSE.txt README.md wcc-data.gemspec]
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
20
19
 
21
20
  spec.required_ruby_version = '~> 2.2'
22
21
 
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.3.0
4
+ version: 0.3.5
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: 2019-02-20 00:00:00.000000000 Z
11
+ date: 2021-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -97,20 +97,12 @@ dependencies:
97
97
  description: Watermark's library for interapp communication via APIs
98
98
  email:
99
99
  - dev@watermark.org
100
- executables:
101
- - rspec
100
+ executables: []
102
101
  extensions: []
103
102
  extra_rdoc_files: []
104
103
  files:
105
- - ".env.example"
106
- - ".gitignore"
107
- - ".rspec"
108
- - Gemfile
109
104
  - LICENSE.txt
110
105
  - README.md
111
- - Rakefile
112
- - bin/rspec
113
- - circle.yml
114
106
  - lib/wcc/data.rb
115
107
  - lib/wcc/data/config.rb
116
108
  - lib/wcc/data/enumerated_type.rb
@@ -136,28 +128,12 @@ files:
136
128
  - lib/wcc/data/rest_endpoint.rb
137
129
  - lib/wcc/data/service.rb
138
130
  - lib/wcc/data/version.rb
139
- - spec/spec_helper.rb
140
- - spec/support/inheritable_class_attribute_examples.rb
141
- - spec/wcc/data/config_spec.rb
142
- - spec/wcc/data/enumerated_type_spec.rb
143
- - spec/wcc/data/faraday_client_app_token_auth_spec.rb
144
- - spec/wcc/data/mapper/attributes_spec.rb
145
- - spec/wcc/data/mapper/json_response_spec.rb
146
- - spec/wcc/data/mapper/rest_configuration_spec.rb
147
- - spec/wcc/data/mapper/rest_query_spec.rb
148
- - spec/wcc/data/model_spec.rb
149
- - spec/wcc/data/nucleus/campus_spec.rb
150
- - spec/wcc/data/rack_client_app_token_auth_spec.rb
151
- - spec/wcc/data/response_spec.rb
152
- - spec/wcc/data/rest_endpoint_spec.rb
153
- - spec/wcc/data/service_spec.rb
154
- - spec/wcc/data_spec.rb
155
131
  - wcc-data.gemspec
156
132
  homepage: ''
157
133
  licenses:
158
134
  - MIT
159
135
  metadata: {}
160
- post_install_message:
136
+ post_install_message:
161
137
  rdoc_options: []
162
138
  require_paths:
163
139
  - lib
@@ -172,25 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
148
  - !ruby/object:Gem::Version
173
149
  version: '0'
174
150
  requirements: []
175
- rubyforge_project:
151
+ rubyforge_project:
176
152
  rubygems_version: 2.6.11
177
- signing_key:
153
+ signing_key:
178
154
  specification_version: 4
179
155
  summary: Watermark's library for interapp communication via APIs
180
- test_files:
181
- - spec/spec_helper.rb
182
- - spec/support/inheritable_class_attribute_examples.rb
183
- - spec/wcc/data/config_spec.rb
184
- - spec/wcc/data/enumerated_type_spec.rb
185
- - spec/wcc/data/faraday_client_app_token_auth_spec.rb
186
- - spec/wcc/data/mapper/attributes_spec.rb
187
- - spec/wcc/data/mapper/json_response_spec.rb
188
- - spec/wcc/data/mapper/rest_configuration_spec.rb
189
- - spec/wcc/data/mapper/rest_query_spec.rb
190
- - spec/wcc/data/model_spec.rb
191
- - spec/wcc/data/nucleus/campus_spec.rb
192
- - spec/wcc/data/rack_client_app_token_auth_spec.rb
193
- - spec/wcc/data/response_spec.rb
194
- - spec/wcc/data/rest_endpoint_spec.rb
195
- - spec/wcc/data/service_spec.rb
196
- - spec/wcc/data_spec.rb
156
+ test_files: []
data/.env.example DELETED
@@ -1,3 +0,0 @@
1
- NUCLEUS_CLIENT_ID=client-id-3
2
- NUCLEUS_CLIENT_SECRET=client-secret-3
3
- NUCLEUS_URL=http://login.wcc/
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .env*.local
6
- .yardoc
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in wcc-data.gemspec
4
- gemspec
5
-
6
- gem 'rack', '~>1.6.5'
data/Rakefile DELETED
@@ -1,36 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'dotenv/tasks'
3
-
4
- PROJECT_PATH = File.dirname(__FILE__)
5
- LIB_PATH = File.join(PROJECT_PATH, "lib")
6
-
7
- task :default => :test
8
-
9
- desc 'run test examples'
10
- task :test do
11
- exec 'rspec .'
12
- end
13
-
14
- task :environment => :dotenv do
15
- $LOAD_PATH.unshift(LIB_PATH)
16
- require 'wcc/data'
17
- end
18
-
19
- task :development => [:environment] do
20
- WCC::Data.setup do |config|
21
- conn = config.applications[:nucleus].connection
22
- conn.use Faraday::Response::Logger
23
- conn.basic_auth(ENV['NUCLEUS_CLIENT_ID'], ENV['NUCLEUS_CLIENT_SECRET'])
24
- end
25
- end
26
-
27
- desc 'launch IRB shell with base environment loaded'
28
- task :irb => :environment do
29
- require 'irb'
30
- ARGV.clear
31
- IRB.start
32
- end
33
-
34
- desc 'launch IRB shell with development environment loaded'
35
- task :console => [:development, :irb]
36
-
data/bin/rspec DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- #
4
- # This file was generated by Bundler.
5
- #
6
- # The application 'rspec' is installed as part of a gem, and
7
- # this file is here to facilitate running it.
8
- #
9
-
10
- require "pathname"
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
- Pathname.new(__FILE__).realpath)
13
-
14
- require "rubygems"
15
- require "bundler/setup"
16
-
17
- load Gem.bin_path("rspec-core", "rspec")
data/circle.yml DELETED
@@ -1,6 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.2.2
4
- dependencies:
5
- pre:
6
- - cp .env.example .env
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- SPEC_DIR = File.dirname(__FILE__)
2
- FIXTURES_DIR = File.join(SPEC_DIR, "fixtures")
3
-
4
- $LOAD_PATH.unshift File.join(SPEC_DIR, "..", "lib")
5
- $LOAD_PATH.unshift SPEC_DIR
6
-
7
- require 'dotenv'
8
- Dotenv.load
9
-
10
- require 'wcc/data'
11
- require 'sidekiq'
12
-
13
- Dir[File.join(SPEC_DIR, "support", "*.rb")].each do |support_file|
14
- require "support/#{File.basename(support_file, ".rb")}"
15
- end
16
-
17
- RSpec.configure do |config|
18
- config.run_all_when_everything_filtered = true
19
- config.filter_run :focus
20
-
21
- config.order = 'random'
22
- end
@@ -1,16 +0,0 @@
1
- shared_examples_for :inheritable_class_attributes do |name|
2
- let(:subclass) { Class.new(subject) }
3
-
4
- it "inherited value is the same as parent class" do
5
- subject.send(:instance_variable_set, :"@#{name}", foo: :bar)
6
- expect(subject.send(name)).to eq(foo: :bar)
7
- expect(subclass.send(name)).to eq(foo: :bar)
8
- end
9
-
10
- it "inherited reference is unique from the parent class" do
11
- subject.send(:instance_variable_set, :"@#{name}", foo: :bar)
12
- subclass.send(name)[:bar] = :baz
13
- expect(subject.send(name)).to eq(foo: :bar)
14
- end
15
- end
16
-
@@ -1,113 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe WCC::Data::Config::Application do
4
- let(:unit) { WCC::Data::Config::Application }
5
- subject { unit.new(:name) }
6
-
7
- describe "#initialize" do
8
- it "takes a single name symbol and stores in @name" do
9
- obj = unit.new(:name)
10
- expect(obj.name).to eq(:name)
11
- end
12
-
13
- it "takes a connection option and stores it in @connection" do
14
- obj = unit.new(:name, connection: "foo")
15
- expect(obj.connection).to eq("foo")
16
- end
17
-
18
- it "sets to a blank Faraday::Connection" do
19
- obj = unit.new(:name)
20
- expect(obj.connection).to be_a(Faraday::Connection)
21
- end
22
- end
23
-
24
- describe "#uri=" do
25
- it "converts a string to a URI and stores in @uri" do
26
- subject.uri = "http://test"
27
- expect(subject.uri).to be_a(URI)
28
- expect(subject.uri.scheme).to eq("http")
29
- end
30
-
31
- it "uses the URI object if set with a URI" do
32
- subject.uri = test_value = URI("http://test")
33
- expect(subject.uri).to eq(test_value)
34
- end
35
- end
36
-
37
- describe "#service" do
38
- before(:each) do
39
- subject.uri = "http://test.com/"
40
- end
41
-
42
- it "returns a service object based on the URI" do
43
- obj = subject.service
44
- expect(obj).to be_a(WCC::Data::Service)
45
- expect(obj.uri).to eq(subject.uri)
46
- end
47
-
48
- it "passes the application connection through to the service" do
49
- obj = subject.service
50
- expect(obj.connection).to eq(subject.connection)
51
- end
52
- end
53
-
54
- describe "@connection" do
55
- it "gets and sets" do
56
- subject.connection = "foo"
57
- expect(subject.connection).to eq("foo")
58
- end
59
- end
60
- end
61
-
62
- describe WCC::Data::Config do
63
- let(:unit) { WCC::Data::Config }
64
- subject { unit.new }
65
-
66
-
67
- describe "#applications" do
68
- it "returns a hash" do
69
- expect(subject.applications).to be_a(Hash)
70
- end
71
-
72
- it "defaults empty keys to an application" do
73
- expect(subject.applications[:foo]).to be_a(WCC::Data::Config::Application)
74
- end
75
-
76
- it "contains a default entry for :nucleus" do
77
- expect(subject.applications[:nucleus].uri).to eq(
78
- URI(ENV['NUCLEUS_URL'])
79
- )
80
- end
81
-
82
- context "with APP_CLIENT_ID and APP_CLIENT_SECRET ENV vars set" do
83
- after do
84
- ENV['APP_CLIENT_ID'] = ENV['APP_CLIENT_SECRET'] = nil
85
- end
86
-
87
- it "sets the connection's basic auth for nucleus" do
88
- ENV['APP_CLIENT_ID'] = "test"
89
- ENV['APP_CLIENT_SECRET'] = "value"
90
-
91
- header = subject.applications[:nucleus].connection.headers["Authorization"]
92
-
93
- expect(header)
94
- .to eq(Faraday::Request::BasicAuthentication.header("test", "value"))
95
- end
96
- end
97
-
98
- context "with APP_CLIENT_ID and APP_CLIENT_SECRET not both set" do
99
- it "does not set the basic auth for nucleus" do
100
- header = subject.applications[:nucleus].connection.headers["Authorization"]
101
-
102
- expect(header).to be_nil
103
- end
104
- end
105
- end
106
-
107
- describe "#apps alias" do
108
- it "aliases to #applications" do
109
- expect(subject.apps).to eq(subject.applications)
110
- end
111
- end
112
-
113
- end