protocol-http 0.48.0 → 0.49.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: 183d448e1ac64631b122da7f8a34c4f506ef5792efdffad906077d206cb7cdd9
4
- data.tar.gz: 848e8e30617a473bd955419605a06625a9dd3735e42239fd11d5fbcfdbe5ca86
3
+ metadata.gz: f32acdbabe7e68c2dac1c6ceb3f697936a6000b23f884e91268578594d710af9
4
+ data.tar.gz: 711a823f045bd93c1de05331937c05847ab37de5765f309689d9fcfa9c4d13d2
5
5
  SHA512:
6
- metadata.gz: 58cfc6bf62399c067ccdd1cb5f4e3d5ff02acd3603918f4e1aaadfcb39d505f2a0ec1e60e8f3cf542f9ae615ada5363c72bd652f1513494f50b67911cbe4d6a0
7
- data.tar.gz: 23befb46df9d7bc48928e08400dec1a11f9028bf0d3cf7549f3f2f2273d833984ea4c1ed37eaa4e68e99d255fd1df98e78c3133c9971d65488f0d06eb41d5c08
6
+ metadata.gz: a6f90cc72dc0262c7555cdc9cb06b04869ec2d1c161a4f394d339e509b2c940f2b0b28150054c7509a3b54b829442d44838d3ff1bab2a6f849d01c269d462b08
7
+ data.tar.gz: 75cc72a22d04106c14e74df1aab2cb48343eb5e9b7032fd13b0671bd15a02f8b9aeb7d9963141d0c078ad070c49923c485e4537363fa31b2d646d707afceddc3
checksums.yaml.gz.sig CHANGED
Binary file
@@ -30,10 +30,16 @@ module Protocol
30
30
 
31
31
  # A single entry in the Accept: header, which includes a mime type and associated parameters. A media range can include wild cards, but a media type is a specific type and subtype.
32
32
  MediaRange = Struct.new(:type, :subtype, :parameters) do
33
+ # Create a new media range.
34
+ #
35
+ # @parameter type [String] the type of the media range.
36
+ # @parameter subtype [String] the subtype of the media range.
37
+ # @parameter parameters [Hash] the parameters associated with the media range.
33
38
  def initialize(type, subtype = "*", parameters = {})
34
39
  super(type, subtype, parameters)
35
40
  end
36
41
 
42
+ # Compare the media range with another media range or a string, based on the quality factor.
37
43
  def <=> other
38
44
  other.quality_factor <=> self.quality_factor
39
45
  end
@@ -46,12 +52,16 @@ module Protocol
46
52
  end.join
47
53
  end
48
54
 
55
+ # The string representation of the media range, including the type, subtype, and any parameters.
49
56
  def to_s
50
57
  "#{type}/#{subtype}#{parameters_string}"
51
58
  end
52
59
 
53
60
  alias to_str to_s
54
61
 
62
+ # The quality factor associated with the media range, which is used to determine the order of preference.
63
+ #
64
+ # @returns [Float] the quality factor, which defaults to 1.0 if not specified.
55
65
  def quality_factor
56
66
  parameters.fetch("q", 1.0).to_f
57
67
  end
@@ -75,9 +75,9 @@ module Protocol
75
75
  end
76
76
 
77
77
  self.each do |name, method|
78
- define_method(name) do |location, *arguments, **options|
78
+ define_method(name) do |*arguments, **options|
79
79
  self.call(
80
- Request[method, location.to_s, *arguments, **options]
80
+ Request[method, *arguments, **options]
81
81
  )
82
82
  end
83
83
  end
@@ -124,7 +124,8 @@ module Protocol
124
124
  # @parameter path [String] The path, e.g. `"/index.html"`, `"/search?q=hello"`, etc.
125
125
  # @parameter headers [Hash] The headers, e.g. `{"accept" => "text/html"}`, etc.
126
126
  # @parameter body [String | Array(String) | Body::Readable] The body, e.g. `"Hello, World!"`, etc. See {Body::Buffered.wrap} for more information about .
127
- def self.[](method, path, _headers = nil, _body = nil, scheme: nil, authority: nil, headers: _headers, body: _body, protocol: nil, interim_response: nil)
127
+ def self.[](method, path = nil, _headers = nil, _body = nil, scheme: nil, authority: nil, headers: _headers, body: _body, protocol: nil, interim_response: nil)
128
+ path = path&.to_s
128
129
  body = Body::Buffered.wrap(body)
129
130
  headers = Headers[headers]
130
131
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.48.0"
8
+ VERSION = "0.49.0"
9
9
  end
10
10
  end
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.48.0
4
+ version: 0.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -46,7 +46,7 @@ cert_chain:
46
46
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
47
47
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
48
48
  -----END CERTIFICATE-----
49
- date: 2025-01-24 00:00:00.000000000 Z
49
+ date: 2025-01-29 00:00:00.000000000 Z
50
50
  dependencies: []
51
51
  executables: []
52
52
  extensions: []
metadata.gz.sig CHANGED
Binary file