boltless 2.1.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: f8b7c4416097390006b201dcec4ce9beaa8190659d079da12af5e01689670aff
4
- data.tar.gz: 434205668e628cb4b0d12a1451a83dac804cea38c1a045f3982f8157e9e25873
3
+ metadata.gz: c055f7c7d799ed3730576b41ab6f4e06b934b6474cc500dd129fa4d6b3e2aa03
4
+ data.tar.gz: 3af83a59d287e99c4003b623085381568848c41f78647efde5213c77c4f1e96f
5
5
  SHA512:
6
- metadata.gz: d20881d61af51e69287d45b36358c8bd35f2709e16b43439b598c542fe92a09f33a182260a2cc19360ddf3586f6c918e79957d1bb3b20b3eb5dafedfdd12273a
7
- data.tar.gz: 163eb7a5a639a046a2801ecc002772c0eac9f0b6fe9113f9c35c0271cf41e3aee75137fd17d3c6278957caa67a29e1919e0fd7fcdfac6feb5a4939b65ddf1b59
6
+ metadata.gz: 77621fe5e243f0101f36b83580ee53dc84798494baa935e2fa7a070d206600ce5950e5e9bcd3b3c5ae35052fdcbc7531b853bcd593a6160193c12fdbd599b70e
7
+ data.tar.gz: 4df2493fd8f6a89133fd25d5a27c06c4bfcadb44d82a2f5b818a3f97747125279cc51c5abfddfcf46245315aec4110855f93de331062ac3cb47f02b4e0087f11
data/Envfile CHANGED
@@ -1,3 +1,4 @@
1
1
  LANG=en_US.UTF-8
2
2
  LANGUAGE=en_US.UTF-8
3
3
  LC_ALL=en_US.UTF-8
4
+ RUBOCOP_CACHE_ROOT=/app/tmp
@@ -73,7 +73,7 @@ module Boltless
73
73
  # transmitting and response completion)
74
74
  config_accessor(:request_timeout) { 10.seconds }
75
75
 
76
- # We allow the neo4j server to bootup for the configured time. This allows
76
+ # We allow the neo4j server to boot-up for the configured time. This allows
77
77
  # parallel starts of the user application and the neo4j server, without
78
78
  # glitching.
79
79
  config_accessor(:wait_for_upstream_server) { 30.seconds }
@@ -3,9 +3,6 @@
3
3
  module Boltless
4
4
  module Extensions
5
5
  # A top-level gem-module extension to add easy-to-use connection pool.
6
- #
7
- # rubocop:disable Metrics/BlockLength -- because this is how an
8
- # +ActiveSupport::Concern+ looks like
9
6
  module ConnectionPool
10
7
  extend ActiveSupport::Concern
11
8
 
@@ -22,7 +19,6 @@ module Boltless
22
19
  # @raise [HTTP::Error] in case the upstream server did not come up
23
20
  #
24
21
  # rubocop:disable Metrics/MethodLength -- because of the retry logic
25
- # rubocop:disable Metrics/AbcSize -- ditto
26
22
  def wait_for_server!(connection)
27
23
  # Check if the server already accepted connections
28
24
  return connection if @upstream_is_ready
@@ -67,7 +63,6 @@ module Boltless
67
63
  retry
68
64
  end
69
65
  # rubocop:enable Metrics/MethodLength
70
- # rubocop:enable Metrics/AbcSize
71
66
 
72
67
  # A memoized connection pool for our HTTP API clients.
73
68
  #
@@ -76,7 +71,6 @@ module Boltless
76
71
  #
77
72
  # rubocop:disable Metrics/MethodLength -- because of the connection
78
73
  # configuration
79
- # rubocop:disable Metrics/AbcSize -- ditto
80
74
  def connection_pool
81
75
  @connection_pool ||= begin
82
76
  conf = Boltless.configuration
@@ -102,14 +96,13 @@ module Boltless
102
96
  )
103
97
  .encoding('UTF-8')
104
98
  .persistent(conf.base_url)
105
- .yield_self do |connection|
99
+ .then do |connection|
106
100
  conf.http_client_configure.call(connection)
107
101
  end
108
102
  end
109
103
  end
110
104
  end
111
105
  # rubocop:enable Metrics/MethodLength
112
- # rubocop:enable Metrics/AbcSize
113
106
  end
114
107
 
115
108
  included do
@@ -121,6 +114,5 @@ module Boltless
121
114
  end
122
115
  end
123
116
  end
124
- # rubocop:enable Metrics/BlockLength
125
117
  end
126
118
  end
@@ -3,9 +3,6 @@
3
3
  module Boltless
4
4
  module Extensions
5
5
  # A top-level gem-module extension for neo4j operations.
6
- #
7
- # rubocop:disable Metrics/BlockLength -- because this is how an
8
- # +ActiveSupport::Concern+ looks like
9
6
  module Operations
10
7
  extend ActiveSupport::Concern
11
8
 
@@ -15,12 +12,6 @@ module Boltless
15
12
  # database is completely empty and "unconfigured". (dist clean)
16
13
  #
17
14
  # @param database [String, Symbol] the neo4j database to use
18
- #
19
- # rubocop:disable Metrics/MethodLength -- because of multiple
20
- # transactions
21
- # rubocop:disable Metrics/AbcSize -- because of the extra transaction
22
- # handlings (we cannot do multiple structural changes in
23
- # a single transaction)
24
15
  def clear_database!(database: Boltless.configuration.default_db)
25
16
  logger.warn('Clear neo4j database ..')
26
17
 
@@ -52,8 +43,6 @@ module Boltless
52
43
  " > Relationships deleted: #{stats[:relationship_deleted]}"
53
44
  )
54
45
  end
55
- # rubocop:enable Metrics/MethodLength
56
- # rubocop:enable Metrics/AbcSize
57
46
 
58
47
  # Check whenever the given name is already taken on the neo4j
59
48
  # database for a component (index or constraint).
@@ -170,6 +159,5 @@ module Boltless
170
159
  end
171
160
  end
172
161
  end
173
- # rubocop:enable Metrics/BlockLength
174
162
  end
175
163
  end
@@ -4,10 +4,6 @@ module Boltless
4
4
  module Extensions
5
5
  # A top-level gem-module extension to add easy-to-use methods to use the
6
6
  # Cypher transactional API.
7
- #
8
- # rubocop:disable Metrics/BlockLength -- because this is how an
9
- # +ActiveSupport::Concern+ looks like
10
- # rubocop:disable Metrics/ModuleLength -- ditto
11
7
  module Transactions
12
8
  extend ActiveSupport::Concern
13
9
 
@@ -148,9 +144,6 @@ module Boltless
148
144
  # or +nil+ on errors
149
145
  #
150
146
  # @raise [Mixed] when an exception occurs inside the user given block
151
- #
152
- # rubocop:disable Metrics/MethodLength -- because of the extra error
153
- # handling
154
147
  def one_shot(access_mode = :write,
155
148
  database: Boltless.configuration.default_db,
156
149
  raw_results: false)
@@ -175,7 +168,6 @@ module Boltless
175
168
  end
176
169
  end
177
170
  end
178
- # rubocop:enable Metrics/MethodLength
179
171
 
180
172
  # Start an new transaction and run Cypher statements inside it. When
181
173
  # anything within the user given block raises, we automatically
@@ -195,8 +187,6 @@ module Boltless
195
187
  # found by neo4j
196
188
  # @raise [Mixed] when an exception occurs inside the user given
197
189
  # block, we re-raise it
198
- #
199
- # rubocop:disable Metrics/MethodLength -- because this is the workflow
200
190
  def transaction!(access_mode = :write,
201
191
  database: Boltless.configuration.default_db,
202
192
  raw_results: false)
@@ -233,7 +223,6 @@ module Boltless
233
223
  tx.cleanup
234
224
  end
235
225
  end
236
- # rubocop:enable Metrics/MethodLength
237
226
 
238
227
  # Start an new transaction and run Cypher statements inside it. When
239
228
  # anything within the user given block raises, we automatically
@@ -250,8 +239,6 @@ module Boltless
250
239
  #
251
240
  # @raise [Mixed] when an exception occurs inside the user given
252
241
  # block, we re-raise it
253
- #
254
- # rubocop:disable Metrics/MethodLength -- because this is the workflow
255
242
  def transaction(access_mode = :write,
256
243
  database: Boltless.configuration.default_db,
257
244
  raw_results: false)
@@ -280,7 +267,7 @@ module Boltless
280
267
 
281
268
  # Try to commit after the user given block, when the transaction is
282
269
  # still open, and return the results of the user given block if the
283
- # transaction is successfully commited
270
+ # transaction is successfully committed
284
271
  tx_committed = tx.state.open? ? tx.commit : true
285
272
  next res if tx_committed
286
273
 
@@ -292,10 +279,7 @@ module Boltless
292
279
  tx.cleanup
293
280
  end
294
281
  end
295
- # rubocop:enable Metrics/MethodLength
296
282
  end
297
283
  end
298
- # rubocop:enable Metrics/BlockLength
299
- # rubocop:enable Metrics/ModuleLength
300
284
  end
301
285
  end
@@ -2,10 +2,7 @@
2
2
 
3
3
  module Boltless
4
4
  module Extensions
5
- # A top-level gem-module extension add helpers and utilites.
6
- #
7
- # rubocop:disable Metrics/BlockLength -- because this is how an
8
- # +ActiveSupport::Concern+ looks like
5
+ # A top-level gem-module extension add helpers and utilities.
9
6
  module Utilities
10
7
  extend ActiveSupport::Concern
11
8
 
@@ -38,10 +35,6 @@ module Boltless
38
35
  # @yield the given block result will be used as Cypher string
39
36
  # template
40
37
  # @return [String] the built Cypher query
41
- #
42
- # rubocop:disable Metrics/MethodLength -- because of the various
43
- # replacement strategies
44
- # rubocop:disable Metrics/AbcSize -- ditto
45
38
  def build_cypher(**replacements)
46
39
  # Process the given replacements in order to prevent Cypher
47
40
  # injections from user given values
@@ -57,13 +50,11 @@ module Boltless
57
50
  # Then evaluate the given block to get the Cypher template
58
51
  # which should be interpolated with the replacements
59
52
  format(yield.to_s, replacements).lines.map do |line|
60
- line.split('//').first.rstrip.yield_self do |processed|
53
+ line.split('//').first.rstrip.then do |processed|
61
54
  processed.empty? ? nil : processed
62
55
  end
63
56
  end.compact.join("\n")
64
57
  end
65
- # rubocop:enable Metrics/MethodLength
66
- # rubocop:enable Metrics/AbcSize
67
58
 
68
59
  # Prepare the given input(s) as node label for injection-free Cypher.
69
60
  #
@@ -80,7 +71,7 @@ module Boltless
80
71
  end.sort.uniq.join(':')
81
72
  end
82
73
 
83
- # Prepare the given input as relationship tyep for
74
+ # Prepare the given input as relationship type for
84
75
  # injection-free Cypher.
85
76
  #
86
77
  # @param inputs [Array<#to_s>] the input object(s) to prepare as type
@@ -156,9 +147,6 @@ module Boltless
156
147
  #
157
148
  # @param cypher [String] the Cypher query to check
158
149
  # @return [Symbol] the ANSI color name
159
- #
160
- # rubocop:disable Metrics/CyclomaticComplexity -- because of the
161
- # various conditions
162
150
  def cypher_logging_color(cypher)
163
151
  cypher = cypher.to_s.downcase.lines.map(&:strip)
164
152
 
@@ -179,9 +167,7 @@ module Boltless
179
167
  # Everything else, like matches
180
168
  :light_blue
181
169
  end
182
- # rubocop:enable Metrics/CyclomaticComplexity
183
170
  end
184
171
  end
185
- # rubocop:enable Metrics/BlockLength
186
172
  end
187
173
  end
@@ -4,9 +4,6 @@ module Boltless
4
4
  # A neo4j HTTP API request abstraction class, which consumes a single HTTP
5
5
  # persistent connection for its whole runtime. This connection is strictly
6
6
  # owned by a single request object. It is not safe to share it.
7
- #
8
- # rubocop:disable Metrics/ClassLength -- because of the isolated request
9
- # abstraction
10
7
  class Request
11
8
  class << self
12
9
  # Convert a multiple Cypher queries and +Hash+ arguments into multiple
@@ -72,7 +69,7 @@ module Boltless
72
69
 
73
70
  # Run one/multiple Cypher statements inside a one-shot transaction.
74
71
  # A new transaction is opened, the statements are run and the transaction
75
- # is commited in a single HTTP request for efficiency.
72
+ # is committed in a single HTTP request for efficiency.
76
73
  #
77
74
  # @param statements [Array<Hash>] the Cypher statements to run
78
75
  # @return [Array<Hash{Symbol => Mixed}>] the raw neo4j results
@@ -101,10 +98,6 @@ module Boltless
101
98
  # @return [Integer] the neo4j transaction identifier
102
99
  # @raise [Errors::TransactionBeginError] when we fail to start a
103
100
  # new transaction
104
- #
105
- # rubocop:disable Metrics/MethodLength -- because of the error handlings
106
- # and transaction identifier parsing
107
- # rubocop:disable Metrics/AbcSize -- ditto
108
101
  def begin_transaction
109
102
  log_query(:begin, Request.statement_payload('BEGIN')) do
110
103
  handle_transport_errors do
@@ -131,8 +124,6 @@ module Boltless
131
124
  end
132
125
  end
133
126
  end
134
- # rubocop:enable Metrics/MethodLength
135
- # rubocop:enable Metrics/AbcSize
136
127
 
137
128
  # Run one/multiple Cypher statements inside an open transaction.
138
129
  #
@@ -236,7 +227,6 @@ module Boltless
236
227
  #
237
228
  # rubocop:disable Metrics/MethodLength -- because of the result handling
238
229
  # (error, raw result, restructured result)
239
- # rubocop:disable Metrics/AbcSize -- ditto
240
230
  def handle_response_body(res, tx_id: nil)
241
231
  # Parse the response body as a whole, which is returned by
242
232
  # the configured raw response handler
@@ -271,7 +261,6 @@ module Boltless
271
261
  raise Errors::InvalidJsonError.new(e.message, response: res)
272
262
  end
273
263
  # rubocop:enable Metrics/MethodLength
274
- # rubocop:enable Metrics/AbcSize
275
264
 
276
265
  # Serialize the given object to a JSON string.
277
266
  #
@@ -287,7 +276,7 @@ module Boltless
287
276
  # @yield the given block
288
277
  # @return [Mixed] the result of the given block
289
278
  #
290
- # @raise [Errors::RequestError] when a low-level error occured
279
+ # @raise [Errors::RequestError] when a low-level error occurred
291
280
  def handle_transport_errors
292
281
  yield
293
282
  rescue HTTP::Error => e
@@ -316,7 +305,7 @@ module Boltless
316
305
  # Add a new request to the counter
317
306
  @requests_done += 1
318
307
 
319
- # When the +query_debug_log_enabled+ config flag is set, we prodce a
308
+ # When the +query_debug_log_enabled+ config flag is set, we produce a
320
309
  # logging output before the actual request is sent, in order to help
321
310
  # while debugging slow/never-ending Cypher statements
322
311
  if enabled == :debug
@@ -356,10 +345,6 @@ module Boltless
356
345
  # @param duration [Numeric, nil] the duration (ms) of the query
357
346
  # @param statements [Array<Hash>] the Cypher statements to run
358
347
  # @return [String] the assembled logging string
359
- #
360
- # rubocop:disable Metrics/MethodLength -- because of the complex logging
361
- # string assembling/formatting
362
- # rubocop:disable Metrics/AbcSize -- ditto
363
348
  def generate_log_str(tx_id, duration, *statements)
364
349
  dur = "(#{duration}ms)".colorize(color: :magenta, mode: :bold) \
365
350
  if duration
@@ -382,8 +367,5 @@ module Boltless
382
367
  "#{prefix} #{cypher}"
383
368
  end.join("\n")
384
369
  end
385
- # rubocop:enable Metrics/MethodLength
386
- # rubocop:enable Metrics/AbcSize
387
370
  end
388
- # rubocop:enable Metrics/ClassLength
389
371
  end
@@ -64,10 +64,6 @@ module Boltless
64
64
  # Pretty print the result structure in a meaningful way.
65
65
  #
66
66
  # @param pp [PP] a pretty printer instance to use
67
- #
68
- # rubocop:disable Metrics/MethodLength -- because of the pretty printing
69
- # logic
70
- # rubocop:disable Metrics/AbcSize -- ditto
71
67
  def pretty_print(pp)
72
68
  pp.object_group(self) do
73
69
  pp.breakable
@@ -91,8 +87,6 @@ module Boltless
91
87
  pp.pp(stats)
92
88
  end
93
89
  end
94
- # rubocop:enable Metrics/MethodLength
95
- # rubocop:enable Metrics/AbcSize
96
90
  alias_method :inspect, :pretty_inspect
97
91
  end
98
92
  end
@@ -17,7 +17,7 @@ module Boltless
17
17
  # @return [Mixed] the value for the given key
18
18
  def [](key)
19
19
  # When the requested key was not found, we return +nil+, no need to
20
- # perfom the actual lookup
20
+ # perform the actual lookup
21
21
  return unless (idx = columns.index(key.to_sym))
22
22
 
23
23
  # Otherwise return the value from the slot
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Boltless
4
4
  # A shallow interface object to collect multiple Cypher statements. We have
5
- # an explicit different interface (+#add+ instead ot +#run+) from a regular
5
+ # an explicit different interface (+#add+ instead or +#run+) from a regular
6
6
  # transaction to clarify that we just collect statements without running them
7
7
  # directly. As a result no subsequent statement can access the results of a
8
8
  # previous statement within this collection.
@@ -15,7 +15,7 @@ module Boltless
15
15
  # We allow to read our collected details
16
16
  attr_reader :statements
17
17
 
18
- # We allow to access helpful utilities straigth from here
18
+ # We allow to access helpful utilities straight from here
19
19
  delegate :build_cypher, :prepare_label, :prepare_type, :prepare_string,
20
20
  :to_options, :resolve_cypher,
21
21
  to: Boltless
@@ -4,7 +4,7 @@ module Boltless
4
4
  # A single neo4j transaction representation.
5
5
  #
6
6
  # When passing Cypher statements you can tweak some HTTP API result options
7
- # while passing the following keys to the Cypher parameters (they wont be
7
+ # while passing the following keys to the Cypher parameters (they won't be
8
8
  # sent to neo4j):
9
9
  #
10
10
  # * +with_stats: true|false+: whenever to include statement
@@ -21,7 +21,7 @@ module Boltless
21
21
  # We allow to read some internal configurations
22
22
  attr_reader :access_mode, :id, :raw_state
23
23
 
24
- # We allow to access helpful utilities straigth from here
24
+ # We allow to access helpful utilities straight from here
25
25
  delegate :build_cypher, :prepare_label, :prepare_type, :prepare_string,
26
26
  :to_options, :resolve_cypher,
27
27
  to: Boltless
@@ -219,7 +219,7 @@ module Boltless
219
219
  yield
220
220
  rescue Errors::RequestError, Errors::ResponseError,
221
221
  Errors::TransactionInBadStateError => e
222
- # When an error occured, the transaction is automatically rolled back by
222
+ # When an error occurred, the transaction is automatically rolled back by
223
223
  # neo4j, so we cannot handle any further interaction
224
224
  cleanup
225
225
  @raw_state = :closed
@@ -3,7 +3,7 @@
3
3
  # The gem version details.
4
4
  module Boltless
5
5
  # The version of the +boltless+ gem
6
- VERSION = '2.1.0'
6
+ VERSION = '2.2.0'
7
7
 
8
8
  class << self
9
9
  # Returns the version of gem as a string.
@@ -41,7 +41,7 @@ RSpec.describe Boltless::Extensions::ConnectionPool do
41
41
  expect(action.size).to be(1)
42
42
  end
43
43
 
44
- it 'returns a configured HTTP client (connection aquire timeout)' do
44
+ it 'returns a configured HTTP client (connection acquire timeout)' do
45
45
  Boltless.configuration.connection_pool_timeout = 1
46
46
  reload.call
47
47
  expect(action.instance_variable_get(:@timeout)).to be(1)
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- # rubocop:disable RSpec/NestedGroups -- because nesting makes sense here
6
5
  RSpec.describe Boltless::Request do
7
6
  let(:new_instance) { ->(**args) { described_class.new(connection, **args) } }
8
7
  let(:instance) { new_instance.call }
@@ -447,12 +446,12 @@ RSpec.describe Boltless::Request do
447
446
 
448
447
  context 'with an unsuccessful status code' do
449
448
  let(:http_status_code) { 500 }
450
- let(:body) { 'Unknown error happend' }
449
+ let(:body) { 'Unknown error happened' }
451
450
 
452
451
  it 'raises a Boltless::Errors::TransactionRollbackError' do
453
452
  expect { action.call }.to \
454
453
  raise_error(Boltless::Errors::TransactionRollbackError,
455
- /Unknown error happend/)
454
+ /Unknown error happened/)
456
455
  end
457
456
  end
458
457
 
@@ -971,4 +970,3 @@ RSpec.describe Boltless::Request do
971
970
  end
972
971
  end
973
972
  end
974
- # rubocop:enable RSpec/NestedGroups
@@ -112,7 +112,7 @@ RSpec.describe Boltless::Transaction do
112
112
  describe '#access_mode' do
113
113
  let(:action) { instance.access_mode }
114
114
 
115
- context 'when not explictly configured' do
115
+ context 'when not explicitly configured' do
116
116
  it 'returns write' do
117
117
  expect(action).to be(:write)
118
118
  end
@@ -25,7 +25,7 @@ def file_fixture(path)
25
25
  "../fixtures/files/#{path}")))
26
26
  end
27
27
 
28
- # Return a neo4j raw result from a file fixture. It looks excatly like produced
28
+ # Return a neo4j raw result from a file fixture. It looks exactly like produced
29
29
  # by +Boltless::Request#handle_response_body+.
30
30
  #
31
31
  # @param suffixes [Array<String, Symbol>] additional file suffixes, check the
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boltless
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer