orientdb_client 0.0.4 → 0.0.5

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: 1f790f7d0f994bd626bff6f95c180024a2fbcd7c
4
- data.tar.gz: 46f3386fef71ef7736be02b7b92e59254f1d62b2
3
+ metadata.gz: c3b7e8eed23a652cb9e3b2011164a7327ef5c554
4
+ data.tar.gz: 9f567cb1117ad35b8ffbf656f3e1767e0f7dedbb
5
5
  SHA512:
6
- metadata.gz: 7765f03411f6491a02751d05bf2bb0d3c5fa7c744a4c7290775e0fc376c709103d9c2bc4c4cc01a04cd45e766394d02cf3171ebcdff62d44f21ef82c09afa0fd
7
- data.tar.gz: 9e42dc627c9e01792cbce92a16e9259efaac17f4ccae3d82220d48783eecf66b593f9bb0ed2f02e869f09fbbae244d7a3995d9c42c43f1af0d0fdfda404fe26c
6
+ metadata.gz: fc6cd1274f0452ea61b90bee9ddfcf4c8a6aa65f80ca408820074310e658ba0b3e51d3b5a861829c24aaf150c1bc442868ee5eb031129436af90cc32da56ed1e
7
+ data.tar.gz: 9923fe4d47c09552ae309c82cf0bc90bdcb501d0cbd41dfe7ce1ad51fd0966e64434ef4a52053e2346b0e1408bf1a84a873d963dcd12b7e73833013a21842fdf
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Master
4
4
 
5
+ ## 0.0.5
6
+
7
+ * Differentiate between Typhoeus adapter timeouts and connection failures.
8
+ * Prevent Curb errors from bubbling up to gem user; convert some of them to native
9
+ OrientdbClient errors.
10
+
11
+ ## 0.0.4
12
+
5
13
  * Added support for timeouts.
6
14
 
7
15
  ## 0.0.3
@@ -37,4 +37,10 @@ module OrientdbClient
37
37
  class NotFoundError < OrientdbError; end
38
38
 
39
39
  class NegativeArraySizeException < OrientdbError; end
40
+
41
+ # Some adapters, e.g. Curb, have many different errors they may raise, and we don't
42
+ # want to have to worry about rescuing each individual one (e.g. FTPError), so if
43
+ # we get an exception from an adapter for which we don't have a clear mapping to a native
44
+ # OrientdbClient error, just wrap it in HttpAdapterError.
45
+ class HttpAdapterError < OrientdbError; end
40
46
  end
@@ -10,6 +10,12 @@ module OrientdbClient
10
10
  req
11
11
  rescue Curl::Err::TimeoutError
12
12
  timed_out!(method, url)
13
+ rescue Curl::Err::ConnectionFailedError, Curl::Err::HostResolutionError
14
+ raise ConnectionError
15
+ rescue Curl::Err::MalformedURLError
16
+ raise ClientError
17
+ rescue Curl::Err::CurlError
18
+ raise HttpAdapterError
13
19
  end
14
20
 
15
21
  private
@@ -7,7 +7,9 @@ module OrientdbClient
7
7
  def request(method, url, options = {})
8
8
  req = prepare_request(method, url, options)
9
9
  response = run_request(req)
10
- if response.timed_out?
10
+ if response.return_message == "Couldn't connect to server".freeze
11
+ raise ConnectionError
12
+ elsif response.timed_out?
11
13
  timed_out!(method, url)
12
14
  else
13
15
  return response
@@ -1,3 +1,3 @@
1
1
  module OrientdbClient
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -5,4 +5,29 @@ RSpec.describe OrientdbClient::HttpAdapters::CurbAdapter do
5
5
  it_behaves_like 'http adapter' do
6
6
  let(:adapter_klass) { OrientdbClient::HttpAdapters::CurbAdapter }
7
7
  end
8
+
9
+ describe '#request' do
10
+ let(:adapter) { OrientdbClient::HttpAdapters::CurbAdapter.new }
11
+ subject { adapter.request(:get, 'http://localhost/foo') }
12
+
13
+ it 'converts Curl::Err::ConnectionFailedError into a ConnectionError' do
14
+ allow(adapter).to receive(:run_request) { raise Curl::Err::ConnectionFailedError }
15
+ expect { subject }.to raise_exception(OrientdbClient::ConnectionError)
16
+ end
17
+
18
+ it 'converts Curl::Err::HostResolutionError into a ConnectionError' do
19
+ allow(adapter).to receive(:run_request) { raise Curl::Err::HostResolutionError }
20
+ expect { subject }.to raise_exception(OrientdbClient::ConnectionError)
21
+ end
22
+
23
+ it 'converts Curl::Err::MalformedURLError into a ClientError' do
24
+ allow(adapter).to receive(:run_request) { raise Curl::Err::MalformedURLError }
25
+ expect { subject }.to raise_exception(OrientdbClient::ClientError)
26
+ end
27
+
28
+ it 'converts other Curl errors into HttpAdapaterError' do
29
+ allow(adapter).to receive(:run_request) { raise Curl::Err::HTTPFailedError }
30
+ expect { subject }.to raise_exception(OrientdbClient::HttpAdapterError)
31
+ end
32
+ end
8
33
  end
@@ -5,4 +5,13 @@ RSpec.describe OrientdbClient::HttpAdapters::TyphoeusAdapter do
5
5
  it_behaves_like 'http adapter' do
6
6
  let(:adapter_klass) { OrientdbClient::HttpAdapters::TyphoeusAdapter }
7
7
  end
8
+
9
+ describe '#request' do
10
+ let(:adapter) { OrientdbClient::HttpAdapters::TyphoeusAdapter.new }
11
+ subject { adapter.request(:get, 'http://localhost/noodbhere') }
12
+
13
+ it 'raises a connection failure if it cannot connect' do
14
+ expect { subject }.to raise_exception(OrientdbClient::ConnectionError)
15
+ end
16
+ end
8
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orientdb_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Rodgers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-05 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus