neo4j-ruby-driver 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: b0527e52f881e9d0a1d2a82bb6d44adada7187cf5ed0639897c95c6eeb414710
4
- data.tar.gz: d1816823ed6760dfaafea61ecc2d30945535c322156059ac807dd15545a38088
3
+ metadata.gz: f3e3e772ba2164fefe876f905912cf2a42472b1db5c762b8b7f6d0abc2677c83
4
+ data.tar.gz: 9a57a05095babfe6ff9b8ff3438893599969f5fd15745e0167f309c73387862c
5
5
  SHA512:
6
- metadata.gz: a1484192cda413f3e35adaf9636f9c7db560eb3c34bb192903922b2c82bd16dd882bfb64465b5fd9f1f5f23c5c9bf55484c811777b816ed5fe0fd4a85459fb3b
7
- data.tar.gz: e4311e81ab4bab518cc93afc71d0fccb04a51b12759eebe377c8690fd9557d8be4d0aa0a2c8ef97dcd5b939bbd06310655bce0042a750bac76bf02fd8c35c6f9
6
+ metadata.gz: f41c8ceddda78db2619babd2e730e2fcb6c36726f4764acfe3086647afd732649e8d88bc36850690c3e8dca1d140b581a5b8f66b1967ea368fa091274c915c71
7
+ data.tar.gz: 154821e8c904705848ed9bb3475bce53fa4141ca1d9a5b7fc16333be3fd129a1f6fb5f68b39c447d71d1915e5e19735b9fc9367a678fc5c333313ee7c45f97d2
@@ -5,6 +5,7 @@ module Neo4j
5
5
  class AuthTokens
6
6
  class << self
7
7
  def basic(username, password)
8
+ Internal::Validator.require_non_nil_credentials!(username, password)
8
9
  Bolt::Auth.basic(username, password, nil)
9
10
  end
10
11
 
@@ -11,17 +11,16 @@ module Neo4j
11
11
  nil
12
12
  # Permission denied
13
13
  when Bolt::Error::BOLT_PERMISSION_DENIED # 7
14
- failure Exceptions::AuthenticationException.new(error_code, 'Permission denied')
14
+ throw Exceptions::AuthenticationException.new(error_code, 'Permission denied')
15
15
  # Connection refused
16
16
  when Bolt::Error::BOLT_CONNECTION_REFUSED
17
- failure Exceptions::ServiceUnavailableException.new(error_code, 'unable to acquire connection')
17
+ throw Exceptions::ServiceUnavailableException.new(error_code, 'unable to acquire connection')
18
+ # Error set in connection
19
+ when Bolt::Error::BOLT_CONNECTION_HAS_MORE_INFO, Bolt::Error::BOLT_STATUS_SET
20
+ status = Bolt::Connection.status(bolt_connection)
21
+ unqualified_error(error_code, status, error_text)
18
22
  else
19
- error_ctx = status && Bolt::Status.get_error_context(status)
20
- failure Exceptions::Neo4jException.new(
21
- error_code,
22
- "#{error_text || 'Unknown Bolt failure'} (code: #{error_code.to_s(16)}, " \
23
- "text: #{Bolt::Error.get_string(error_code)}, context: #{error_ctx})"
24
- )
23
+ unqualified_error(error_code, status, error_text)
25
24
  end
26
25
  end
27
26
 
@@ -40,10 +39,19 @@ module Neo4j
40
39
 
41
40
  private
42
41
 
43
- def failure(error)
42
+ def throw(error)
44
43
  on_failure(error)
45
44
  raise error
46
45
  end
46
+
47
+ def unqualified_error(error_code, status, error_text)
48
+ error_ctx = status && Bolt::Status.get_error_context(status)
49
+ throw Exceptions::Neo4jException.new(
50
+ error_code,
51
+ "#{error_text || 'Unknown Bolt failure'} (code: #{error_code.to_s(16)}, " \
52
+ "text: #{Bolt::Error.get_string(error_code)}, context: #{error_ctx})"
53
+ )
54
+ end
47
55
  end
48
56
  end
49
57
  end
@@ -5,6 +5,8 @@ module Neo4j
5
5
  module Internal
6
6
  module Handlers
7
7
  class PullAllResponseHandler < ResponseHandler
8
+ include ErrorHandling
9
+
8
10
  delegate :bolt_connection, to: :connection
9
11
  delegate :statement_keys, to: :run_handler
10
12
  attr_reader :connection
@@ -90,7 +92,7 @@ module Neo4j
90
92
  nil
91
93
  end
92
94
  rescue StandardError => e
93
- @finished = true
95
+ on_failure(e)
94
96
  raise e
95
97
  end
96
98
  end
@@ -6,7 +6,7 @@ module Neo4j
6
6
  attr_reader :text, :parameters
7
7
 
8
8
  def initialize(text, parameters = nil)
9
- Internal::StatementValidator.validate!(parameters)
9
+ Internal::Validator.require_hash_parameters!(parameters)
10
10
  @text = text
11
11
  @parameters = parameters || {}
12
12
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Internal
6
+ module Validator
7
+ def self.require_hash_parameters!(parameters)
8
+ require_hash!(parameters) do
9
+ "The parameters should be provided as Map type. Unsupported parameters type: #{parameters.class.name}"
10
+ end
11
+ end
12
+
13
+ def self.require_hash!(obj)
14
+ raise(ArgumentError, yield) unless obj.nil? || obj.is_a?(Hash)
15
+ end
16
+
17
+ def self.require_non_nil!(obj, message)
18
+ raise ArgumentError, message if obj.nil?
19
+ end
20
+
21
+ def self.require_non_nil_credentials!(username, password)
22
+ require_non_nil! username, "Username can't be nil"
23
+ require_non_nil! password, "Password can't be nil"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neo4j
4
4
  module Driver
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,184 +1,185 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-ruby-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinrich Klobuczek
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-18 00:00:00.000000000 Z
11
+ date: 2019-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: activesupport
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - ">="
17
18
  - !ruby/object:Gem::Version
18
19
  version: '0'
19
- name: activesupport
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: 2.1.10
33
- name: zeitwerk
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.1.10
41
41
  - !ruby/object:Gem::Dependency
42
+ name: ffi
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
- name: ffi
48
- prerelease: false
49
48
  type: :runtime
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
+ name: recursive-open-struct
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - ">="
59
60
  - !ruby/object:Gem::Version
60
61
  version: '0'
61
- name: recursive-open-struct
62
- prerelease: false
63
62
  type: :runtime
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
+ name: ffaker
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - ">="
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
- name: ffaker
76
- prerelease: false
77
76
  type: :development
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
+ name: neo4j-rake_tasks
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - ">="
87
88
  - !ruby/object:Gem::Version
88
89
  version: 0.3.0
89
- name: neo4j-rake_tasks
90
- prerelease: false
91
90
  type: :development
91
+ prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.3.0
97
97
  - !ruby/object:Gem::Dependency
98
+ name: parallel
98
99
  requirement: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - ">="
101
102
  - !ruby/object:Gem::Version
102
103
  version: '0'
103
- name: parallel
104
- prerelease: false
105
104
  type: :development
105
+ prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
+ name: rake
112
113
  requirement: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - "<"
115
116
  - !ruby/object:Gem::Version
116
117
  version: '13'
117
- name: rake
118
- prerelease: false
119
118
  type: :development
119
+ prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "<"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '13'
125
125
  - !ruby/object:Gem::Dependency
126
+ name: rspec-its
126
127
  requirement: !ruby/object:Gem::Requirement
127
128
  requirements:
128
129
  - - ">="
129
130
  - !ruby/object:Gem::Version
130
131
  version: '0'
131
- name: rspec-its
132
- prerelease: false
133
132
  type: :development
133
+ prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
+ name: hoe
140
141
  requirement: !ruby/object:Gem::Requirement
141
142
  requirements:
142
143
  - - ">="
143
144
  - !ruby/object:Gem::Version
144
145
  version: '0'
145
- name: hoe
146
- prerelease: false
147
146
  type: :development
147
+ prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
+ name: hoe-bundler
154
155
  requirement: !ruby/object:Gem::Requirement
155
156
  requirements:
156
157
  - - ">="
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
- name: hoe-bundler
160
- prerelease: false
161
160
  type: :development
161
+ prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
+ name: hoe-gemspec
168
169
  requirement: !ruby/object:Gem::Requirement
169
170
  requirements:
170
171
  - - ">="
171
172
  - !ruby/object:Gem::Version
172
173
  version: '0'
173
- name: hoe-gemspec
174
- prerelease: false
175
174
  type: :development
175
+ prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
+ name: rdoc
182
183
  requirement: !ruby/object:Gem::Requirement
183
184
  requirements:
184
185
  - - ">="
@@ -187,9 +188,8 @@ dependencies:
187
188
  - - "<"
188
189
  - !ruby/object:Gem::Version
189
190
  version: '7'
190
- name: rdoc
191
- prerelease: false
192
191
  type: :development
192
+ prerelease: false
193
193
  version_requirements: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - ">="
@@ -297,7 +297,7 @@ files:
297
297
  - lib/neo4j/driver/exceptions/untrusted_server_exception.rb
298
298
  - lib/neo4j/driver/internal/duration_normalizer.rb
299
299
  - lib/neo4j/driver/internal/ruby_signature.rb
300
- - lib/neo4j/driver/internal/statement_validator.rb
300
+ - lib/neo4j/driver/internal/validator.rb
301
301
  - lib/neo4j/driver/types/bytes.rb
302
302
  - lib/neo4j/driver/types/local_date_time.rb
303
303
  - lib/neo4j/driver/types/local_time.rb
@@ -310,7 +310,7 @@ homepage: https://github.com/neo4jrb/neo4j-ruby-driver
310
310
  licenses:
311
311
  - MIT
312
312
  metadata: {}
313
- post_install_message:
313
+ post_install_message:
314
314
  rdoc_options:
315
315
  - "--main"
316
316
  - README.md
@@ -328,9 +328,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
328
  - !ruby/object:Gem::Version
329
329
  version: '0'
330
330
  requirements: []
331
- rubyforge_project:
332
- rubygems_version: 2.7.9
333
- signing_key:
331
+ rubygems_version: 3.0.6
332
+ signing_key:
334
333
  specification_version: 4
335
334
  summary: ''
336
335
  test_files: []
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Neo4j
4
- module Driver
5
- module Internal
6
- module StatementValidator
7
- def self.validate!(parameters)
8
- unless parameters.nil? || parameters.is_a?(Hash)
9
- raise ArgumentError,
10
- "The parameters should be provided as Map type. Unsupported parameters type: #{parameters.class.name}"
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end