Skip to content

Commit 76f82c2

Browse files
Merge pull request #584 from OneBusAway/release-please--branches--main--changes--next
release: 1.1.2
2 parents 6a6a420 + f001905 commit 76f82c2

File tree

18 files changed

+161
-52
lines changed

18 files changed

+161
-52
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.1.1"
2+
".": "1.1.2"
33
}

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Metrics/BlockLength:
121121
Metrics/ClassLength:
122122
Enabled: false
123123

124+
Metrics/CollectionLiteralLength:
125+
Exclude:
126+
- "test/**/*"
127+
124128
Metrics/CyclomaticComplexity:
125129
Enabled: false
126130

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
## 1.1.2 (2025-10-15)
4+
5+
Full Changelog: [v1.1.1...v1.1.2](https://github.com/OneBusAway/ruby-sdk/compare/v1.1.1...v1.1.2)
6+
7+
### Bug Fixes
8+
9+
* always send `filename=...` for multipart requests where a file is expected ([ae0a463](https://github.com/OneBusAway/ruby-sdk/commit/ae0a4631df4a0ba4ebb386e4bcd228977b8554c3))
10+
* coroutine leaks from connection pool ([5c3a6f1](https://github.com/OneBusAway/ruby-sdk/commit/5c3a6f121a63c3046f39ce62fba651a5e4e57ba8))
11+
* shorten multipart boundary sep to less than RFC specificed max length ([eee0939](https://github.com/OneBusAway/ruby-sdk/commit/eee0939d23255dbd6b3de367bbba02ea0a346425))
12+
* should not reuse buffers for `IO.copy_stream` interop ([29dd5d7](https://github.com/OneBusAway/ruby-sdk/commit/29dd5d7e0bcfbaf3027fca84a6338c37131843e6))
13+
14+
15+
### Performance Improvements
16+
17+
* faster code formatting ([95c9921](https://github.com/OneBusAway/ruby-sdk/commit/95c99210f84f729076f9c6494a98729946bcb7d9))
18+
19+
20+
### Chores
21+
22+
* allow fast-format to use bsd sed as well ([ac285dc](https://github.com/OneBusAway/ruby-sdk/commit/ac285dcaff516a5d8755da3534f83dfa588bcb6d))
23+
* ignore linter error for tests having large collections ([88b7a09](https://github.com/OneBusAway/ruby-sdk/commit/88b7a092d8bab6f77ee3fdc351e0b7d0fe41713a))
24+
* improve example values ([c2ea3c6](https://github.com/OneBusAway/ruby-sdk/commit/c2ea3c65ba37c82b323cffafad37b17b10d04c3b))
25+
* **internal:** codegen related update ([2a3af55](https://github.com/OneBusAway/ruby-sdk/commit/2a3af55696978980ca69da2e42caecf15c72ba2d))
26+
327
## 1.1.1 (2025-09-20)
428

529
Full Changelog: [v1.1.0...v1.1.1](https://github.com/OneBusAway/ruby-sdk/compare/v1.1.0...v1.1.1)

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GIT
1111
PATH
1212
remote: .
1313
specs:
14-
onebusaway-sdk (1.1.1)
14+
onebusaway-sdk (1.1.2)
1515
connection_pool
1616

1717
GEM

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
1717
<!-- x-release-please-start-version -->
1818

1919
```ruby
20-
gem "onebusaway-sdk", "~> 1.1.1"
20+
gem "onebusaway-sdk", "~> 1.1.2"
2121
```
2222

2323
<!-- x-release-please-end -->

Rakefile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ tapioca = "sorbet/tapioca"
1212
examples = "examples"
1313
ignore_file = ".ignore"
1414

15+
FILES_ENV = "FORMAT_FILE"
16+
1517
CLEAN.push(*%w[.idea/ .ruby-lsp/ .yardoc/ doc/], *FileList["*.gem"], ignore_file)
1618

1719
CLOBBER.push(*%w[sorbet/rbi/annotations/ sorbet/rbi/gems/], tapioca)
@@ -38,6 +40,14 @@ end
3840
xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --]
3941
ruby_opt = {"RUBYOPT" => [ENV["RUBYOPT"], "--encoding=UTF-8"].compact.join(" ")}
4042

43+
filtered = ->(ext, dirs) do
44+
if ENV.key?(FILES_ENV)
45+
%w[sed -E -n -e] << "/\\.#{ext}$/p" << "--" << ENV.fetch(FILES_ENV)
46+
else
47+
(%w[find] + dirs + %w[-type f -and -name]) << "*.#{ext}" << "-print0"
48+
end
49+
end
50+
4151
desc("Lint `*.rb(i)`")
4252
multitask(:"lint:rubocop") do
4353
find = %w[find ./lib ./test ./rbi ./examples -type f -and ( -name *.rb -or -name *.rbi ) -print0]
@@ -52,24 +62,26 @@ multitask(:"lint:rubocop") do
5262
sh("#{find.shelljoin} | #{lint.shelljoin}")
5363
end
5464

65+
norm_lines = %w[tr -- \n \0].shelljoin
66+
5567
desc("Format `*.rb`")
5668
multitask(:"format:rb") do
5769
# while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support
58-
find = %w[find ./lib ./test ./examples -type f -and -name *.rb -print0]
70+
files = filtered["rb", %w[./lib ./test ./examples]]
5971
fmt = xargs + %w[rubocop --fail-level F --autocorrect --format simple --]
60-
sh("#{find.shelljoin} | #{fmt.shelljoin}")
72+
sh("#{files.shelljoin} | #{norm_lines} | #{fmt.shelljoin}")
6173
end
6274

6375
desc("Format `*.rbi`")
6476
multitask(:"format:rbi") do
65-
find = %w[find ./rbi -type f -and -name *.rbi -print0]
77+
files = filtered["rbi", %w[./rbi]]
6678
fmt = xargs + %w[stree write --]
67-
sh(ruby_opt, "#{find.shelljoin} | #{fmt.shelljoin}")
79+
sh(ruby_opt, "#{files.shelljoin} | #{norm_lines} | #{fmt.shelljoin}")
6880
end
6981

7082
desc("Format `*.rbs`")
7183
multitask(:"format:rbs") do
72-
find = %w[find ./sig -type f -name *.rbs -print0]
84+
files = filtered["rbs", %w[./sig]]
7385
inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? ["-i", ""] : %w[-i]
7486
uuid = SecureRandom.uuid
7587

@@ -98,13 +110,13 @@ multitask(:"format:rbs") do
98110
success = false
99111

100112
# transform class aliases to type aliases, which syntax tree has no trouble with
101-
sh("#{find.shelljoin} | #{pre.shelljoin}")
113+
sh("#{files.shelljoin} | #{norm_lines} | #{pre.shelljoin}")
102114
# run syntax tree to format `*.rbs` files
103-
sh(ruby_opt, "#{find.shelljoin} | #{fmt.shelljoin}") do
115+
sh(ruby_opt, "#{files.shelljoin} | #{norm_lines} | #{fmt.shelljoin}") do
104116
success = _1
105117
end
106118
# transform type aliases back to class aliases
107-
sh("#{find.shelljoin} | #{pst.shelljoin}")
119+
sh("#{files.shelljoin} | #{norm_lines} | #{pst.shelljoin}")
108120

109121
# always run post-processing to remove comment marker
110122
fail unless success

lib/onebusaway_sdk/file_part.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,21 @@ def to_json(*a) = read.to_json(*a)
3838
def to_yaml(*a) = read.to_yaml(*a)
3939

4040
# @param content [Pathname, StringIO, IO, String]
41-
# @param filename [String, nil]
41+
# @param filename [Pathname, String, nil]
4242
# @param content_type [String, nil]
4343
def initialize(content, filename: nil, content_type: nil)
44-
@content = content
44+
@content_type = content_type
4545
@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
4953
else
50-
filename.nil? ? nil : ::File.basename(filename)
54+
filename
5155
end
52-
@content_type = content_type
5356
end
5457
end
5558
end

lib/onebusaway_sdk/internal/transport/pooled_net_requester.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def execute(request)
134134

135135
# rubocop:disable Metrics/BlockLength
136136
enum = Enumerator.new do |y|
137-
with_pool(url, deadline: deadline) do |conn|
138-
next if finished
137+
next if finished
139138

139+
with_pool(url, deadline: deadline) do |conn|
140140
req, closing = self.class.build_request(request) do
141141
self.class.calibrate_socket_timeout(conn, deadline)
142142
end
@@ -149,7 +149,7 @@ def execute(request)
149149

150150
self.class.calibrate_socket_timeout(conn, deadline)
151151
conn.request(req) do |rsp|
152-
y << [conn, req, rsp]
152+
y << [req, rsp]
153153
break if finished
154154

155155
rsp.read_body do |bytes|
@@ -160,6 +160,8 @@ def execute(request)
160160
end
161161
eof = true
162162
end
163+
ensure
164+
conn.finish if !eof && conn&.started?
163165
end
164166
rescue Timeout::Error
165167
raise OnebusawaySDK::Errors::APITimeoutError.new(url: url, request: req)
@@ -168,16 +170,11 @@ def execute(request)
168170
end
169171
# rubocop:enable Metrics/BlockLength
170172

171-
conn, _, response = enum.next
173+
_, response = enum.next
172174
body = OnebusawaySDK::Internal::Util.fused_enum(enum, external: true) do
173175
finished = true
174-
tap do
175-
enum.next
176-
rescue StopIteration
177-
nil
178-
end
176+
loop { enum.next }
179177
ensure
180-
conn.finish if !eof && conn&.started?
181178
closing&.call
182179
end
183180
[Integer(response.code), response, body]

lib/onebusaway_sdk/internal/type/file_input.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,20 @@ def coerce(value, state:)
8282
#
8383
# @return [Pathname, StringIO, IO, String, Object]
8484
def dump(value, state:)
85-
# rubocop:disable Lint/DuplicateBranch
8685
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+
OnebusawaySDK::FilePart.new(value, filename: "upload")
8790
in IO
8891
state[:can_retry] = false
92+
value.to_path.nil? ? OnebusawaySDK::FilePart.new(value, filename: "upload") : value
8993
in OnebusawaySDK::FilePart if value.content.is_a?(IO)
9094
state[:can_retry] = false
95+
value
9196
else
97+
value
9298
end
93-
# rubocop:enable Lint/DuplicateBranch
94-
95-
value
9699
end
97100

98101
# @api private

lib/onebusaway_sdk/internal/util.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,9 @@ class << self
473473
# @return [Enumerable<String>]
474474
def writable_enum(&blk)
475475
Enumerator.new do |y|
476-
buf = String.new
477476
y.define_singleton_method(:write) do
478-
self << buf.replace(_1)
479-
buf.bytesize
477+
self << _1.dup
478+
_1.bytesize
480479
end
481480

482481
blk.call(y)
@@ -566,7 +565,8 @@ class << self
566565
#
567566
# @return [Array(String, Enumerable<String>)]
568567
private def encode_multipart_streaming(body)
569-
boundary = SecureRandom.urlsafe_base64(60)
568+
# RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
569+
boundary = SecureRandom.urlsafe_base64(46)
570570

571571
closing = []
572572
strio = writable_enum do |y|

0 commit comments

Comments
 (0)