protocol-http 0.52.0 → 0.53.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: 9e1927ee19fba11fbeb421268490fabcde86d7ef9ca5d472320b9aaad6763892
4
- data.tar.gz: fe4c304a05ce7c3637ad460e976dbbf114c22dfb49fe425f9a2dbde1cf280d35
3
+ metadata.gz: 49ea23b4e99ab120bfd68806628631db474b789d7ca841a28877ba176239816f
4
+ data.tar.gz: 2dbe6a91006f94a303babb3b156a55eb82ac60025f111d7f003896e744009394
5
5
  SHA512:
6
- metadata.gz: 97d19c21e2d67d5870077b7ae2856438a1e4314934f01bc93148f63be4db4d55ffee18f45f66ed7b0665678dd8b0deb4718cda92fd9334f198bb2fa335bb297f
7
- data.tar.gz: 674bd9d94d4efacde5d42d8c02dd8876f7f8f96290a26051343103c11f6e68ae54678746bf6d034071c0bba3a5dd7263affecc8c3e86be9ec1766faefc93e50a
6
+ metadata.gz: 0d05dca30d34d5a66483cf09b3b3927af1bd6cf4679cd2421fa0737ab7f6cd56b61fd681d90c7b3252c6bc79d6843b8460c3c74c595b31ff636fb46920088165
7
+ data.tar.gz: 75cb7b599a2ba9d49f859b16f00f94bc2e59118813779e9a4a7e5804ea94d6cc66cc361fc4ef0d7ce957e26bbf7a6a53e1f7b02ec92e438260bfa5a1a33e1299
checksums.yaml.gz.sig CHANGED
Binary file
@@ -153,8 +153,10 @@ module Protocol
153
153
  #
154
154
  # @returns [String] a string representation of the buffered body.
155
155
  def inspect
156
- if @chunks
157
- "\#<#{self.class} #{@chunks.size} chunks, #{self.length} bytes>"
156
+ if @chunks and @chunks.size > 0
157
+ "#<#{self.class} #{@index}/#{@chunks.size} chunks, #{self.length} bytes>"
158
+ else
159
+ "#<#{self.class} empty>"
158
160
  end
159
161
  end
160
162
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "wrapper"
7
7
 
@@ -53,6 +53,23 @@ module Protocol
53
53
 
54
54
  super
55
55
  end
56
+
57
+ # Convert the body to a hash suitable for serialization.
58
+ #
59
+ # @returns [Hash] The body as a hash.
60
+ def as_json(...)
61
+ super.merge(
62
+ callback: @callback&.to_s
63
+ )
64
+ end
65
+
66
+ # Inspect the completable body.
67
+ #
68
+ # @returns [String] a string representation of the completable body.
69
+ def inspect
70
+ callback_status = @callback ? "callback pending" : "callback completed"
71
+ return "#{super} | #<#{self.class} #{callback_status}>"
72
+ end
56
73
  end
57
74
  end
58
75
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "wrapper"
7
7
 
@@ -75,11 +75,22 @@ module Protocol
75
75
  end
76
76
  end
77
77
 
78
+ # Convert the body to a hash suitable for serialization.
79
+ #
80
+ # @returns [Hash] The body as a hash.
81
+ def as_json(...)
82
+ super.merge(
83
+ input_length: @input_length,
84
+ output_length: @output_length,
85
+ compression_ratio: (ratio * 100).round(2)
86
+ )
87
+ end
88
+
78
89
  # Inspect the body, including the compression ratio.
79
90
  #
80
91
  # @returns [String] a string representation of the body.
81
92
  def inspect
82
- "#{super} | \#<#{self.class} #{(ratio*100).round(2)}%>"
93
+ "#{super} | #<#{self.class} #{(ratio*100).round(2)}%>"
83
94
  end
84
95
  end
85
96
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "wrapper"
7
7
 
@@ -64,6 +64,16 @@ module Protocol
64
64
  return nil
65
65
  end
66
66
  end
67
+
68
+ # Convert the body to a hash suitable for serialization.
69
+ #
70
+ # @returns [Hash] The body as a hash.
71
+ def as_json(...)
72
+ super.merge(
73
+ digest_class: @digest.class.name,
74
+ callback: @callback&.to_s
75
+ )
76
+ end
67
77
  end
68
78
  end
69
79
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "readable"
7
7
 
@@ -135,7 +135,11 @@ module Protocol
135
135
  #
136
136
  # @returns [String] a string representation of the file body.
137
137
  def inspect
138
- "\#<#{self.class} file=#{@file.inspect} offset=#{@offset} remaining=#{@remaining}>"
138
+ if @offset > 0
139
+ "#<#{self.class} #{@file.inspect} +#{@offset}, #{@remaining} bytes remaining>"
140
+ else
141
+ "#<#{self.class} #{@file.inspect}, #{@remaining} bytes remaining>"
142
+ end
139
143
  end
140
144
  end
141
145
  end
@@ -53,6 +53,13 @@ module Protocol
53
53
  def length
54
54
  @length
55
55
  end
56
+
57
+ # Inspect the head body.
58
+ #
59
+ # @returns [String] a string representation of the head body.
60
+ def inspect
61
+ "#<#{self.class} #{@length} bytes (empty)>"
62
+ end
56
63
  end
57
64
  end
58
65
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require "zlib"
7
7
 
@@ -82,11 +82,21 @@ module Protocol
82
82
  true
83
83
  end
84
84
 
85
+ # Convert the body to a hash suitable for serialization.
86
+ #
87
+ # @returns [Hash] The body as a hash.
88
+ def as_json(...)
89
+ super.merge(
90
+ index: @index,
91
+ chunks: @chunks.size
92
+ )
93
+ end
94
+
85
95
  # Inspect the rewindable body.
86
96
  #
87
97
  # @returns [String] a string representation of the body.
88
98
  def inspect
89
- "\#<#{self.class} #{@index}/#{@chunks.size} chunks read>"
99
+ "#{super} | #<#{self.class} #{@index}/#{@chunks.size} chunks read>"
90
100
  end
91
101
  end
92
102
  end
@@ -386,6 +386,21 @@ module Protocol
386
386
  @closed
387
387
  end
388
388
 
389
+ # Inspect the stream.
390
+ #
391
+ # @returns [String] a string representation of the stream.
392
+ def inspect
393
+ buffer_info = @buffer ? "#{@buffer.bytesize} bytes buffered" : "no buffer"
394
+
395
+ status = []
396
+ status << "closed" if @closed
397
+ status << "read-closed" if @closed_read
398
+
399
+ status_info = status.empty? ? "open" : status.join(", ")
400
+
401
+ return "#<#{self.class} #{buffer_info}, #{status_info}>"
402
+ end
403
+
389
404
  # @returns [Boolean] Whether there are any output chunks remaining.
390
405
  def empty?
391
406
  @output.empty?
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "readable"
7
7
  require_relative "writable"
@@ -147,7 +147,23 @@ module Protocol
147
147
  #
148
148
  # @parameter error [Exception | Nil] The error that caused this stream to be closed, if any.
149
149
  def close_output(error = nil)
150
- @output&.close(error)
150
+ if output = @output
151
+ @output = nil
152
+ output.close(error)
153
+ end
154
+ end
155
+
156
+ # Inspect the streaming body.
157
+ #
158
+ # @returns [String] a string representation of the streaming body.
159
+ def inspect
160
+ if @block
161
+ "#<#{self.class} block available, not consumed>"
162
+ elsif @output
163
+ "#<#{self.class} block consumed, output active>"
164
+ else
165
+ "#<#{self.class} block consumed, output closed>"
166
+ end
151
167
  end
152
168
  end
153
169
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "readable"
7
7
 
@@ -166,9 +166,9 @@ module Protocol
166
166
  # @returns [String] A string representation of the body.
167
167
  def inspect
168
168
  if @error
169
- "\#<#{self.class} #{@count} chunks written, #{status}, error=#{@error}>"
169
+ "#<#{self.class} #{@count} chunks written, #{status}, error=#{@error}>"
170
170
  else
171
- "\#<#{self.class} #{@count} chunks written, #{status}>"
171
+ "#<#{self.class} #{@count} chunks written, #{status}>"
172
172
  end
173
173
  end
174
174
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "body/buffered"
7
7
  require_relative "body/reader"
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.52.0"
8
+ VERSION = "0.53.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -32,6 +32,11 @@ Please see the [project documentation](https://socketry.github.io/protocol-http/
32
32
 
33
33
  Please see the [project releases](https://socketry.github.io/protocol-http/releases/index) for all releases.
34
34
 
35
+ ### v0.53.0
36
+
37
+ - Improve consistency of Body `#inspect`.
38
+ - Improve `as_json` support for Body wrappers.
39
+
35
40
  ### v0.52.0
36
41
 
37
42
  - Add `Protocol::HTTP::Headers#to_a` method that returns the fields array, providing compatibility with standard Ruby array conversion pattern.
data/releases.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Releases
2
2
 
3
+ ## v0.53.0
4
+
5
+ - Improve consistency of Body `#inspect`.
6
+ - Improve `as_json` support for Body wrappers.
7
+
3
8
  ## v0.52.0
4
9
 
5
10
  - Add `Protocol::HTTP::Headers#to_a` method that returns the fields array, providing compatibility with standard Ruby array conversion pattern.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.52.0
4
+ version: 0.53.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -53,7 +53,6 @@ executables: []
53
53
  extensions: []
54
54
  extra_rdoc_files: []
55
55
  files:
56
- - agent.md
57
56
  - context/design-overview.md
58
57
  - context/getting-started.md
59
58
  - context/hypertext-references.md
metadata.gz.sig CHANGED
Binary file
data/agent.md DELETED
@@ -1,145 +0,0 @@
1
- # Agent
2
-
3
- ## Context
4
-
5
- This section provides links to documentation from installed packages. It is automatically generated and may be updated by running `bake agent:context:install`.
6
-
7
- **Important:** Before performing any code, documentation, or analysis tasks, always read and apply the full content of any relevant documentation referenced in the following sections. These context files contain authoritative standards and best practices for documentation, code style, and project-specific workflows. **Do not proceed with any actions until you have read and incorporated the guidance from relevant context files.**
8
-
9
- **Setup Instructions:** If the referenced files are not present or if dependencies have been updated, run `bake agent:context:install` to install the latest context files.
10
-
11
- ### agent-context
12
-
13
- Install and manage context files from Ruby gems.
14
-
15
- #### [Getting Started](.context/agent-context/getting-started.md)
16
-
17
- This guide explains how to use `agent-context`, a tool for discovering and installing contextual information from Ruby gems to help AI agents.
18
-
19
- ### async
20
-
21
- A concurrency framework for Ruby.
22
-
23
- #### [Getting Started](.context/async/getting-started.md)
24
-
25
- This guide shows how to add async to your project and run code asynchronously.
26
-
27
- #### [Scheduler](.context/async/scheduler.md)
28
-
29
- This guide gives an overview of how the scheduler is implemented.
30
-
31
- #### [Tasks](.context/async/tasks.md)
32
-
33
- This guide explains how asynchronous tasks work and how to use them.
34
-
35
- #### [Best Practices](.context/async/best-practices.md)
36
-
37
- This guide gives an overview of best practices for using Async.
38
-
39
- #### [Debugging](.context/async/debugging.md)
40
-
41
- This guide explains how to debug issues with programs that use Async.
42
-
43
- #### [Thread safety](.context/async/thread-safety.md)
44
-
45
- This guide explains thread safety in Ruby, focusing on fibers and threads, common pitfalls, and best practices to avoid problems like data corruption, race conditions, and deadlocks.
46
-
47
- ### async-service
48
-
49
- A service layer for Async.
50
-
51
- #### [Getting Started](.context/async-service/getting-started.md)
52
-
53
- This guide explains how to get started with `async-service` to create and run services in Ruby.
54
-
55
- #### [Service Architecture](.context/async-service/service-architecture.md)
56
-
57
- This guide explains the key architectural components of `async-service` and how they work together to provide a clean separation of concerns.
58
-
59
- #### [Best Practices](.context/async-service/best-practices.md)
60
-
61
- This guide outlines recommended patterns and practices for building robust, maintainable services with `async-service`.
62
-
63
- ### decode
64
-
65
- Code analysis for documentation generation.
66
-
67
- #### [Getting Started with Decode](.context/decode/getting-started.md)
68
-
69
- The Decode gem provides programmatic access to Ruby code structure and metadata. It can parse Ruby files and extract definitions, comments, and documentation pragmas, enabling code analysis, documentation generation, and other programmatic manipulations of Ruby codebases.
70
-
71
- #### [Documentation Coverage](.context/decode/coverage.md)
72
-
73
- This guide explains how to test and monitor documentation coverage in your Ruby projects using the Decode gem's built-in bake tasks.
74
-
75
- #### [Ruby Documentation](.context/decode/ruby-documentation.md)
76
-
77
- This guide covers documentation practices and pragmas supported by the Decode gem for documenting Ruby code. These pragmas provide structured documentation that can be parsed and used to generate API documentation and achieve complete documentation coverage.
78
-
79
- #### [Setting Up RBS Types and Steep Type Checking for Ruby Gems](.context/decode/types.md)
80
-
81
- This guide covers the process for establishing robust type checking in Ruby gems using RBS and Steep, focusing on automated generation from source documentation and proper validation.
82
-
83
- ### falcon
84
-
85
- A fast, asynchronous, rack-compatible web server.
86
-
87
- #### [Getting Started](.context/falcon/getting-started.md)
88
-
89
- This guide gives an overview of how to use Falcon for running Ruby web applications.
90
-
91
- #### [Rails Integration](.context/falcon/rails-integration.md)
92
-
93
- This guide explains how to host Rails applications with Falcon.
94
-
95
- #### [Deployment](.context/falcon/deployment.md)
96
-
97
- This guide explains how to deploy applications using the Falcon web server. It covers the recommended deployment methods, configuration options, and examples for different environments, including systemd and kubernetes.
98
-
99
- #### [Performance Tuning](.context/falcon/performance-tuning.md)
100
-
101
- This guide explains the performance characteristics of Falcon.
102
-
103
- #### [WebSockets](.context/falcon/websockets.md)
104
-
105
- This guide explains how to use WebSockets with Falcon.
106
-
107
- #### [Interim Responses](.context/falcon/interim-responses.md)
108
-
109
- This guide explains how to use interim responses in Falcon to send early hints to the client.
110
-
111
- #### [How It Works](.context/falcon/how-it-works.md)
112
-
113
- This guide gives an overview of how Falcon handles an incoming web request.
114
-
115
- ### sus
116
-
117
- A fast and scalable test runner.
118
-
119
- #### [Using Sus Testing Framework](.context/sus/usage.md)
120
-
121
- Sus is a modern Ruby testing framework that provides a clean, BDD-style syntax for writing tests. It's designed to be fast, simple, and expressive.
122
-
123
- #### [Mocking](.context/sus/mocking.md)
124
-
125
- There are two types of mocking in sus: `receive` and `mock`. The `receive` matcher is a subset of full mocking and is used to set expectations on method calls, while `mock` can be used to replace method implementations or set up more complex behavior.
126
-
127
- #### [Shared Test Behaviors and Fixtures](.context/sus/shared.md)
128
-
129
- Sus provides shared test contexts which can be used to define common behaviours or tests that can be reused across one or more test files.
130
-
131
- ### utopia-project
132
-
133
- A project documentation tool based on Utopia.
134
-
135
- #### [Getting Started](.context/utopia-project/getting-started.md)
136
-
137
- This guide explains how to use `utopia-project` to add documentation to your project.
138
-
139
- #### [Documentation Guides](.context/utopia-project/documentation-guidelines.md)
140
-
141
- This guide explains how to create and maintain documentation for your project using `utopia-project`.
142
-
143
- #### [GitHub Pages Integration](.context/utopia-project/github-pages-integration.md)
144
-
145
- This guide shows you how to use `utopia-project` with GitHub Pages to deploy documentation.