streaming-standardization: add stream-based process + process_file convenience - #3
Merged
Merged
Conversation
…nvenience Add IO-based process(io, filename:, ...) and process_async(io, filename:, ...) as the canonical stream input methods. process_file / process_async_file are thin path-based convenience wrappers that open the file in binary mode and delegate. The old process(path_string) / process_async(path_string) signatures remain as deprecated aliases that emit a runtime warn. Internally, lib/scanii/multipart.rb now builds the multipart body as a ChainedIO (prologue StringIO + caller IO + epilogue StringIO) and returns the content-length so Net::HTTP can set it explicitly when using body_stream=. File content is never fully buffered. Version bump 1.0.1 -> 1.1.0 (additive: new public methods, no removals). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the streaming standardization for scanii-ruby per
STREAMING_STANDARDIZATION.md §3.8.What changed
process(io, filename:, ...)andprocess_async(io, filename:, ...)accept any IO-like object (duck-typed onread(n)). BothFileandStringIOwork.process_file(path, ...)andprocess_async_file(path, ...)open the file in binary mode and delegate to the stream-based methods. These replace the oldprocess(path)form.process(String_path, ...)andprocess_async(String_path, ...)still work but emit a runtimewarndirecting callers toprocess_file/process_async_file. Will be removed in a future major version.lib/scanii/multipart.rbrefactored tostream_encode— builds prologue + epilogue as binary Strings, chains them around the caller's IO via aChainedIOclass, and sends the body viaNet::HTTP#body_stream=with an explicitContent-Length. File content is never fully buffered.Version bump: 1.0.1 → 1.1.0
Per
API_VERSIONING_POLICY.md: the change shape is additive (new public methods, no removals, deprecated aliases kept). Additive changes ship as minor version bumps. No existing consumer code breaks; deprecated callers get awarnbut keep working.Tests
StringIOpath,File.openIO path,process_filepath, deprecatedprocess(path)emits warning,process_asyncvariantsTest plan
process_file— result is clean or flagged as expectedStringIOviaprocess(StringIO.new(...), filename: "test.bin")— same resultprocess(path)— confirm deprecation warning appears on stderr🤖 Generated with Claude Code