sports-odds-api 1.0.0 → 1.0.1

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: ed23b744aefd6897f1ffe2c1b8b6ec7d2017a5c38f9f61407e9036a64c4b539c
4
- data.tar.gz: 330d785ea83722954b4a1861bce87df552f61bf5640cd43d28a19b24ce39699b
3
+ metadata.gz: 0b2d3224b7a512959a77bc026bb7db55363c95d3f3b1ff6b595b3de3da3582fe
4
+ data.tar.gz: 984de9885de8b49aa3f1abffd1e1eef409db256dd171c6d9dde16cc60fa8cab2
5
5
  SHA512:
6
- metadata.gz: a294de700247d92d72620d6ecd464313dc711d36bcccba1c848dbe1ce8a7da399559a4dcb59bfe3fcaf70982c6a86423af8d45ef3cb6bc0fbcf02bdedc20337b
7
- data.tar.gz: b482d8805041a5b6d2efd02090c05f598b3b998619ba553502633be7406285304e8608f88f4c6d548b0b27d7c2a8c333639638d9faf8770757eb44fc21be5e2d
6
+ metadata.gz: 14bf0836a12cc6de42b06f89cd54ca7b5a9fcc13673f7da6e0a8f28f6426e76742e4e8598be9ec9712d3a5a770df0d63f190d1d2ef9435b8c66de2c3d3b3e768
7
+ data.tar.gz: 3d89ccf0592090be52aeb320ba0cd7a29b67d685950c8bbf6efc49aa5319354cbce9cac394802d8c9f5eb3e342f04eee1314a01d657ece0f339668429f0ec618
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1 (2025-10-01)
4
+
5
+ Full Changelog: [v1.0.0...v1.0.1](https://github.com/SportsGameOdds/sports-odds-api-ruby/compare/v1.0.0...v1.0.1)
6
+
7
+ ### Bug Fixes
8
+
9
+ * always send `filename=...` for multipart requests where a file is expected ([28e1cb8](https://github.com/SportsGameOdds/sports-odds-api-ruby/commit/28e1cb8e5af175c4c0afa49da5596c939dcd9758))
10
+ * coroutine leaks from connection pool ([6c9b16e](https://github.com/SportsGameOdds/sports-odds-api-ruby/commit/6c9b16e9c830d664af77e6a25bf3110b32e60091))
11
+ * shorten multipart boundary sep to less than RFC specificed max length ([cda53c9](https://github.com/SportsGameOdds/sports-odds-api-ruby/commit/cda53c9aa624162299230dccbd47838f3e6e4e30))
12
+
13
+
14
+ ### Chores
15
+
16
+ * allow fast-format to use bsd sed as well ([de4c0f0](https://github.com/SportsGameOdds/sports-odds-api-ruby/commit/de4c0f0a2e46a2f8c1e04540a31ac7a17202d467))
17
+ * **internal:** codegen related update ([8101617](https://github.com/SportsGameOdds/sports-odds-api-ruby/commit/81016173ee5cadb07e1ea09785adbc79fa8ccf5b))
18
+ * **internal:** codegen related update ([b1186c6](https://github.com/SportsGameOdds/sports-odds-api-ruby/commit/b1186c6bee86fe8b82456612407a78f33c6a655e))
19
+
3
20
  ## 1.0.0 (2025-09-23)
4
21
 
5
22
  Full Changelog: [v0.0.1...v1.0.0](https://github.com/SportsGameOdds/sports-odds-api-ruby/compare/v0.0.1...v1.0.0)
data/README.md CHANGED
@@ -26,7 +26,7 @@ The REST API documentation can be found on [sportsgameodds.com](https://sportsga
26
26
  Add to your application's `Gemfile`:
27
27
 
28
28
  ```ruby
29
- gem "sports-odds-api", "~> 1.0.0"
29
+ gem "sports-odds-api", "~> 1.0.1"
30
30
  ```
31
31
 
32
32
  Or install manually:
@@ -38,18 +38,21 @@ module SportsOddsAPI
38
38
  def to_yaml(*a) = read.to_yaml(*a)
39
39
 
40
40
  # @param content [Pathname, StringIO, IO, String]
41
- # @param filename [String, nil]
41
+ # @param filename [Pathname, String, nil]
42
42
  # @param content_type [String, nil]
43
43
  def initialize(content, filename: nil, content_type: nil)
44
- @content = content
44
+ @content_type = content_type
45
45
  @filename =
46
- case content
47
- in Pathname
48
- filename.nil? ? content.basename.to_path : ::File.basename(filename)
46
+ case [filename, (@content = content)]
47
+ in [String | Pathname, _]
48
+ ::File.basename(filename)
49
+ in [nil, Pathname]
50
+ content.basename.to_path
51
+ in [nil, IO]
52
+ content.to_path
49
53
  else
50
- filename.nil? ? nil : ::File.basename(filename)
54
+ filename
51
55
  end
52
- @content_type = content_type
53
56
  end
54
57
  end
55
58
  end
@@ -134,9 +134,9 @@ module SportsOddsAPI
134
134
 
135
135
  # rubocop:disable Metrics/BlockLength
136
136
  enum = Enumerator.new do |y|
137
- with_pool(url, deadline: deadline) do |conn|
138
- next if finished
137
+ next if finished
139
138
 
139
+ with_pool(url, deadline: deadline) do |conn|
140
140
  req, closing = self.class.build_request(request) do
141
141
  self.class.calibrate_socket_timeout(conn, deadline)
142
142
  end
@@ -149,7 +149,7 @@ module SportsOddsAPI
149
149
 
150
150
  self.class.calibrate_socket_timeout(conn, deadline)
151
151
  conn.request(req) do |rsp|
152
- y << [conn, req, rsp]
152
+ y << [req, rsp]
153
153
  break if finished
154
154
 
155
155
  rsp.read_body do |bytes|
@@ -160,6 +160,8 @@ module SportsOddsAPI
160
160
  end
161
161
  eof = true
162
162
  end
163
+ ensure
164
+ conn.finish if !eof && conn&.started?
163
165
  end
164
166
  rescue Timeout::Error
165
167
  raise SportsOddsAPI::Errors::APITimeoutError.new(url: url, request: req)
@@ -168,16 +170,11 @@ module SportsOddsAPI
168
170
  end
169
171
  # rubocop:enable Metrics/BlockLength
170
172
 
171
- conn, _, response = enum.next
173
+ _, response = enum.next
172
174
  body = SportsOddsAPI::Internal::Util.fused_enum(enum, external: true) do
173
175
  finished = true
174
- tap do
175
- enum.next
176
- rescue StopIteration
177
- nil
178
- end
176
+ loop { enum.next }
179
177
  ensure
180
- conn.finish if !eof && conn&.started?
181
178
  closing&.call
182
179
  end
183
180
  [Integer(response.code), response, body]
@@ -82,17 +82,20 @@ module SportsOddsAPI
82
82
  #
83
83
  # @return [Pathname, StringIO, IO, String, Object]
84
84
  def dump(value, state:)
85
- # rubocop:disable Lint/DuplicateBranch
86
85
  case value
86
+ in StringIO | String
87
+ # https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
88
+ # while not required, a filename is recommended, and in practice many servers do expect this
89
+ SportsOddsAPI::FilePart.new(value, filename: "upload")
87
90
  in IO
88
91
  state[:can_retry] = false
92
+ value.to_path.nil? ? SportsOddsAPI::FilePart.new(value, filename: "upload") : value
89
93
  in SportsOddsAPI::FilePart if value.content.is_a?(IO)
90
94
  state[:can_retry] = false
95
+ value
91
96
  else
97
+ value
92
98
  end
93
- # rubocop:enable Lint/DuplicateBranch
94
-
95
- value
96
99
  end
97
100
 
98
101
  # @api private
@@ -566,7 +566,8 @@ module SportsOddsAPI
566
566
  #
567
567
  # @return [Array(String, Enumerable<String>)]
568
568
  private def encode_multipart_streaming(body)
569
- boundary = SecureRandom.urlsafe_base64(60)
569
+ # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
570
+ boundary = SecureRandom.urlsafe_base64(46)
570
571
 
571
572
  closing = []
572
573
  strio = writable_enum do |y|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SportsOddsAPI
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
@@ -27,7 +27,7 @@ module SportsOddsAPI
27
27
  sig do
28
28
  params(
29
29
  content: T.any(Pathname, StringIO, IO, String),
30
- filename: T.nilable(String),
30
+ filename: T.nilable(T.any(Pathname, String)),
31
31
  content_type: T.nilable(String)
32
32
  ).returns(T.attached_class)
33
33
  end
@@ -14,7 +14,7 @@ module SportsOddsAPI
14
14
 
15
15
  def initialize: (
16
16
  Pathname | StringIO | IO | String content,
17
- ?filename: String?,
17
+ ?filename: (Pathname | String)?,
18
18
  ?content_type: String?
19
19
  ) -> void
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sports-odds-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sports Game Odds
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-23 00:00:00.000000000 Z
11
+ date: 2025-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool