cortex-client 0.3.0 → 0.3.1

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: 77658369ff63cdc4448149946ae675efb937dc9d
4
- data.tar.gz: 8326bee51ecb3d16f66eee959b1186a3fb9ec3da
3
+ metadata.gz: 633197e1ba4fa196d04c8cacd0d441e1b036c234
4
+ data.tar.gz: 3883112e28bc8cda1855912d35c52747455b422d
5
5
  SHA512:
6
- metadata.gz: 4a64a29148d0b1561e594664343792624e86edff7d5dafc62a808c8c2fe3785ab3898c71d49d55d827624f1303090af9e643ea81b578c6ddf8f6e75034c87ab6
7
- data.tar.gz: 63d4568bd71a1f538b35dcabc25241fa9bf9e72939a2286a47564a2b49ab20241fab381e47074b06d50aebb438ab2e353f9739e376af71233243ec3bf2ff05a9
6
+ metadata.gz: 882b7046c0350ec1bdf8921566f0cb365b38b7763081c59070a2ca51d21351f72486917bf0455caa62c6ba052bbb8a76af9e09ecec20467ead8e4aab0266212a
7
+ data.tar.gz: 0e8ee1f16cabdb0e29c158bc6fee2b51486f23b8baec78c964a63db356fcd9ab8309d1aaf97255cd6ce931dfbe0dea2903930a32c02e5ac6ddb458f0dfc28bb2
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.version = Cortex::VERSION
7
7
  s.summary = 'Cortex API Client'
8
8
  s.homepage = 'https://github.com/cb-talent-development/cortex-client'
9
- s.authors = ['Bennett Goble']
9
+ s.authors = ['Bennett Goble', 'Colin Ewen']
10
10
  s.license = 'MIT'
11
11
 
12
12
  s.files = `git ls-files`.split($/).reject { |f| f == '.gitignore' }
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'faraday', '~> 0.9'
21
21
  s.add_dependency 'faraday_middleware', '~> 0.9.0'
22
22
  s.add_dependency 'oauth2', '~>0.9'
23
+ s.add_dependency 'cortex-exceptions', '~> 0.0.4'
23
24
  end
@@ -1,2 +1,3 @@
1
1
  require 'cortex/client'
2
2
  require 'cortex/version'
3
+ require 'cortex/client_exceptions'
@@ -5,6 +5,7 @@ require 'cortex/posts'
5
5
  require 'cortex/users'
6
6
  require 'cortex/result'
7
7
  require 'oauth2'
8
+ require 'cortex/exceptions'
8
9
 
9
10
  module Cortex
10
11
  class Client
@@ -30,8 +31,12 @@ module Cortex
30
31
  end
31
32
 
32
33
  def get_cc_token
33
- client = OAuth2::Client.new(@key, @secret, site: @base_url)
34
- client.client_credentials.get_token
34
+ begin
35
+ client = OAuth2::Client.new(@key, @secret, site: @base_url)
36
+ client.client_credentials.get_token
37
+ rescue Faraday::ConnectionFailed
38
+ raise Cortex::Exceptions::ConnectionFailed.new(base_url: @base_url)
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -0,0 +1,13 @@
1
+ module Cortex
2
+ module ClientExceptions
3
+ class ErrorFromResult < StandardError
4
+ attr_accessor :status, :contents, :errors
5
+ def initialize(arg)
6
+ throw ArgumentError.new(msg: "Expected: Cortex::Result, Received: #{arg.class}") unless arg.is_a?(Cortex::Result)
7
+ @status = arg.status
8
+ @errors = arg.errors
9
+ @contents = arg.contents
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,6 @@
1
1
  require 'faraday'
2
2
  require 'faraday_middleware'
3
+ require 'cortex/faraday_middleware'
3
4
 
4
5
  module Cortex
5
6
  module Connection
@@ -16,6 +17,7 @@ module Cortex
16
17
  end
17
18
 
18
19
  Faraday.new options do |conn|
20
+ conn.use Cortex::FaradayMiddleware
19
21
  conn.request :oauth2, access_token.is_a?(OAuth2::AccessToken) ? access_token.token : access_token
20
22
  conn.request :json
21
23
  conn.response :json, :content_type => /\bjson$/
@@ -0,0 +1,14 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module Cortex
5
+ class FaradayMiddleware < Faraday::Middleware
6
+ def call(env)
7
+ begin
8
+ @app.call(env)
9
+ rescue Faraday::ConnectionFailed
10
+ raise Cortex::Exceptions::ConnectionFailed.new(base_url: env[:url])
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Cortex
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cortex-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bennett Goble
8
+ - Colin Ewen
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-08-21 00:00:00.000000000 Z
12
+ date: 2015-02-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
@@ -94,6 +95,20 @@ dependencies:
94
95
  - - "~>"
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0.9'
98
+ - !ruby/object:Gem::Dependency
99
+ name: cortex-exceptions
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 0.0.4
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 0.0.4
97
112
  description:
98
113
  email:
99
114
  executables: []
@@ -102,14 +117,15 @@ extra_rdoc_files: []
102
117
  files:
103
118
  - ".travis.yml"
104
119
  - Gemfile
105
- - Gemfile.lock
106
120
  - LICENSE
107
121
  - README.md
108
122
  - Rakefile
109
123
  - cortex-client.gemspec
110
124
  - lib/cortex-client.rb
111
125
  - lib/cortex/client.rb
126
+ - lib/cortex/client_exceptions.rb
112
127
  - lib/cortex/connection.rb
128
+ - lib/cortex/faraday_middleware.rb
113
129
  - lib/cortex/posts.rb
114
130
  - lib/cortex/request.rb
115
131
  - lib/cortex/resource.rb
@@ -142,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
158
  version: '0'
143
159
  requirements: []
144
160
  rubyforge_project:
145
- rubygems_version: 2.2.2
161
+ rubygems_version: 2.4.5
146
162
  signing_key:
147
163
  specification_version: 4
148
164
  summary: Cortex API Client
@@ -1,52 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cortex-client (0.3.0)
5
- faraday (~> 0.9)
6
- faraday_middleware (~> 0.9.0)
7
- oauth2 (~> 0.9)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- diff-lcs (1.2.5)
13
- faraday (0.9.0)
14
- multipart-post (>= 1.2, < 3)
15
- faraday_middleware (0.9.1)
16
- faraday (>= 0.7.4, < 0.10)
17
- jwt (1.0.0)
18
- metaclass (0.0.4)
19
- mocha (1.1.0)
20
- metaclass (~> 0.0.1)
21
- multi_json (1.10.1)
22
- multi_xml (0.5.5)
23
- multipart-post (2.0.0)
24
- oauth2 (0.9.4)
25
- faraday (>= 0.8, < 0.10)
26
- jwt (~> 1.0)
27
- multi_json (~> 1.3)
28
- multi_xml (~> 0.5)
29
- rack (~> 1.2)
30
- rack (1.5.2)
31
- rake (10.3.2)
32
- rspec (3.0.0)
33
- rspec-core (~> 3.0.0)
34
- rspec-expectations (~> 3.0.0)
35
- rspec-mocks (~> 3.0.0)
36
- rspec-core (3.0.3)
37
- rspec-support (~> 3.0.0)
38
- rspec-expectations (3.0.3)
39
- diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.0.0)
41
- rspec-mocks (3.0.3)
42
- rspec-support (~> 3.0.0)
43
- rspec-support (3.0.3)
44
-
45
- PLATFORMS
46
- ruby
47
-
48
- DEPENDENCIES
49
- cortex-client!
50
- mocha
51
- rake (~> 10.3.2)
52
- rspec (~> 3.0)