http_debug_output-parser 1.0.0 → 1.0.2

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: 21c17e896d8a98fc500c71b6b7a5fcf42328281013e1da0400b76d4b6e5e9e9f
4
- data.tar.gz: 6ac253909248d0795892fe4c545628697b3b9338153a76f54db37893910c9625
3
+ metadata.gz: 5ca64ebb1c13e162e889a0d93e2b04bc3f2b363244599b9b35abf7d7130d1661
4
+ data.tar.gz: f4fe194df36fe913ef28e691fa62ff336e84bcdd85e0887e8ceed26ac3637290
5
5
  SHA512:
6
- metadata.gz: 12987812dcd7db3dd44b05cdd22f3820c5094ed631429797132d94e6f8bc146c3391a42564c3d8ec1f67523f9f58556c7c9c464dc8f77d525e1b0e76cad54a90
7
- data.tar.gz: 273c6a10ed566070edba9f2e9dd3fcbcceaa38fbc718f974cd2f9aca733bc3ba3e990cfcf08bffea3712dc2ac7b160eb0d7a83b59bc47aab64c8752546a53c93
6
+ metadata.gz: e6eebe21ee196d94f96893ed8448f838688f601a260fcbd7aef1142400659829403e7b10d85487c564b04804b433a99bd83f4ee9f75576472d357bb05b58694e
7
+ data.tar.gz: b48684cc04a33dd6c31c9aefe0bb4c03e91432e930f88e06ab13410cd84cd852f412b90c5c84750f1500de8a7656f2e748fd639dfa41f702e5359135e706ce07
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
- TargetRubyVersion: 3.2
3
+ TargetRubyVersion: 3.1
4
4
  Exclude:
5
5
  - 'rails_simple_event_sourcing.gemspec'
6
6
  - 'vendor/bundle/**/*'
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "A gem that parses debug output from Ruby's Net::HTTP."
13
13
  spec.homepage = 'https://github.com/dbackowski/http_debug_output-parser'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 3.2.0'
15
+ spec.required_ruby_version = '>= 3.1.0'
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module HttpDebugOutput
4
4
  class Parser
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  end
@@ -19,7 +19,7 @@ module HttpDebugOutput
19
19
  private
20
20
 
21
21
  def parse_request # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
22
- request_lines = @debug_output[find_range_for_start_and_end_strings('<- ', '-> ')]
22
+ request_lines = @debug_output[find_range_for_start_and_end_strings('<- ', '-> ', last_occurence_of_end: false)]
23
23
  .map { |line| clean_line(line.gsub('<- ', '')) }
24
24
  method, path, protocol = request_lines.first.split
25
25
  headers = request_lines[1..].take_while { |line| line != '' }
@@ -40,7 +40,8 @@ module HttpDebugOutput
40
40
  .filter { |line| line != '' }
41
41
  protocol, status, *message = response_lines.first.split
42
42
  headers = response_lines[1..].take_while { |line| !line.start_with?('reading') }
43
- payload = response_lines[headers.count + 2..].join
43
+ payload_end_index = response_lines.rindex { |line| line.start_with?('read ') } || response_lines.count
44
+ payload = response_lines[headers.count + 2..payload_end_index - 1].join
44
45
 
45
46
  {
46
47
  protocol:,
@@ -51,9 +52,10 @@ module HttpDebugOutput
51
52
  }
52
53
  end
53
54
 
54
- def find_range_for_start_and_end_strings(start_index_string, end_index_string)
55
+ def find_range_for_start_and_end_strings(start_index_string, end_index_string, last_occurence_of_end: true)
55
56
  start_index = @debug_output.find_index { |line| line.start_with?(start_index_string) }
56
- end_index = @debug_output.find_index { |line| line.start_with?(end_index_string) }
57
+ end_index_method = last_occurence_of_end ? :rindex : :find_index
58
+ end_index = @debug_output.public_send(end_index_method) { |line| line.start_with?(end_index_string) }
57
59
  start_index..end_index - 1
58
60
  end
59
61
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_debug_output-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Baćkowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-19 00:00:00.000000000 Z
11
+ date: 2025-02-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A gem that parses debug output from Ruby's Net::HTTP.
14
14
  email:
@@ -40,7 +40,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 3.2.0
43
+ version: 3.1.0
44
44
  required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="