boltless 1.0.0 → 1.1.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: 1d776e0f6ae5034f522faf66e8900c225d0799bc9b73257b681e9afd7b912f02
4
- data.tar.gz: 3ed2ba355d515b9dfd620616772e083c097d02b401a847f43939c87024119fef
3
+ metadata.gz: 90c7aeff2f28dedaef95fce6b671e669e1f0cb91f0de16071a72670396f8eecd
4
+ data.tar.gz: bcd593ed5d27c734fdd5efabb324a2cc60890efc0230fd085c38f4b276a1782b
5
5
  SHA512:
6
- metadata.gz: 34e8e551fd39dd5069e3b58934ec7834eb9629defc3ca2accb185449cbb956c297bbd36f7a340cca836182d0b67c09b64719112ffc4d7179bd0eac158534da9d
7
- data.tar.gz: cc5f3dabddbf7845f0a43126c3b3919d92a6873718f1895cd95d8b05c7ac2a29c787b18e7dae3b1074677ab3ef5c9295ec03fc57d8b0b76a50f66c2d900513d1
6
+ metadata.gz: 3cf67a5be73475d94c5860a44e7c73fb0efccba46f452f559a5db9bfca56805d5a21ce518c5355970b47a267556c206369b6222cfc0c792eac46ba51a199ad6d
7
+ data.tar.gz: b616566ff140b20482d084516deae237e4c54302fe9480c06d4aa9a4da5978fdf4c2660c26bf20d99d782c76193f9e133dd3b1a27a7674761b52eb348ee39b08
data/docker-compose.yml CHANGED
@@ -17,3 +17,4 @@ services:
17
17
  - .:/app:${DOCKER_MOUNT_MODE:-rw}
18
18
  environment:
19
19
  MDNS_HOSTNAME: neo4j.boltless.local
20
+ NEO4J_dbms_logs_http_enabled: 'true'
@@ -65,5 +65,18 @@ module Boltless
65
65
  connection
66
66
  end
67
67
  end
68
+
69
+ # We allow to check/modify the raw neo4j response body string before it
70
+ # gets JSON parsed and handled. This may be handy for some low-level
71
+ # analyses on the raw responses. The first argument of the user defined
72
+ # block will be the raw response body string and the second it the full
73
+ # HTTP response object (+HTTP::Response+). The user defined block MUST
74
+ # return a JSON parsable string (eg. the original input) in order to
75
+ # continue regular processing.
76
+ config_accessor(:raw_response_handler) do
77
+ proc do |body, _response|
78
+ body
79
+ end
80
+ end
68
81
  end
69
82
  end
@@ -238,8 +238,11 @@ module Boltless
238
238
  # handling (error, raw result, restructured result)
239
239
  # rubocop:disable Metrics/AbcSize dito
240
240
  def handle_response_body(res, tx_id: nil)
241
- # Parse the response body as a whole
242
- body = FastJsonparser.parse(res.to_s)
241
+ # Parse the response body as a whole, which is returned by
242
+ # the configured raw response handler
243
+ body = FastJsonparser.parse(
244
+ Boltless.configuration.raw_response_handler.call(res.to_s, res)
245
+ )
243
246
 
244
247
  # When we hit some response errors, we handle them and
245
248
  # re-raise in a wrapped exception
@@ -3,7 +3,7 @@
3
3
  # The gem version details.
4
4
  module Boltless
5
5
  # The version of the +boltless+ gem
6
- VERSION = '1.0.0'
6
+ VERSION = '1.1.0'
7
7
 
8
8
  class << self
9
9
  # Returns the version of gem as a string.
@@ -472,6 +472,7 @@ RSpec.describe Boltless::Request do
472
472
 
473
473
  describe '#handle_response_body' do
474
474
  let(:action) { instance.handle_response_body(response, tx_id: tx_id) }
475
+ let(:safe_action) { suppress(StandardError) { action } }
475
476
 
476
477
  context 'with invalid JSON response' do
477
478
  let(:body) { '<html>Service unavailable</html>' }
@@ -598,6 +599,35 @@ RSpec.describe Boltless::Request do
598
599
  all(be_a(Boltless::Errors::ResponseError))
599
600
  end
600
601
  end
602
+
603
+ context 'with a custom raw response handler' do
604
+ let(:body) { { test: true }.to_json }
605
+ let(:handler) { proc { 'test!' } }
606
+
607
+ before { Boltless.configuration.raw_response_handler = handler }
608
+
609
+ it 'uses the raw response handler return value for parsing' do
610
+ expect(FastJsonparser).to \
611
+ receive(:parse).with('test!').once.and_call_original
612
+ safe_action
613
+ end
614
+
615
+ it 'passes over the raw response body' do
616
+ Boltless.configuration.raw_response_handler = proc do |body, _res|
617
+ expect(body).to be_eql('{"test":true}')
618
+ body
619
+ end
620
+ action
621
+ end
622
+
623
+ it 'passes over the raw response' do
624
+ Boltless.configuration.raw_response_handler = proc do |body, res|
625
+ expect(res).to be_a(HTTP::Response)
626
+ body
627
+ end
628
+ action
629
+ end
630
+ end
601
631
  end
602
632
 
603
633
  describe '#serialize_body' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boltless
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport