http_debug_output-parser 1.0.1 → 1.0.2

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: 8fe87f1133da431bf14f6219f5eaf0ec01d0b1fb62a8a0acd934510f2880a916
4
- data.tar.gz: ce15ef6696ae63a04676c498e206a09d03552371c3c6e1068bc812d331a857cd
3
+ metadata.gz: 5ca64ebb1c13e162e889a0d93e2b04bc3f2b363244599b9b35abf7d7130d1661
4
+ data.tar.gz: f4fe194df36fe913ef28e691fa62ff336e84bcdd85e0887e8ceed26ac3637290
5
5
  SHA512:
6
- metadata.gz: 84b0871b3cec1b31a36733e232ca56a1519853de1f06925fc2f623f5c8db8798ce0121f913adddab3fef98ee83e1a0d1982c3c40e0560ad689f98d6f9ff2320a
7
- data.tar.gz: ee8ac3b1967665aedec1b6d5a1855eaed088132503a85806969fa291f4164c6bae8a86b6b018fd96e8213c995779c0d689fbaa61d3786e8e8df2fcba524491aa
6
+ metadata.gz: e6eebe21ee196d94f96893ed8448f838688f601a260fcbd7aef1142400659829403e7b10d85487c564b04804b433a99bd83f4ee9f75576472d357bb05b58694e
7
+ data.tar.gz: b48684cc04a33dd6c31c9aefe0bb4c03e91432e930f88e06ab13410cd84cd852f412b90c5c84750f1500de8a7656f2e748fd639dfa41f702e5359135e706ce07
@@ -2,6 +2,6 @@
2
2
 
3
3
  module HttpDebugOutput
4
4
  class Parser
5
- VERSION = '1.0.1'
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.1
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-20 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: