improving sigs for new components

This commit is contained in:
HoneyryderChuck 2021-08-10 10:23:03 +01:00
parent e19041aaad
commit 8ded86cec6
4 changed files with 35 additions and 1 deletions

View File

@ -4,6 +4,7 @@ module HTTPX
def self.load_dependencies: (singleton(Session)) -> void
def self.configure: (*untyped) -> void
def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
def self?.decode: (HTTPX::Response response) -> Transcoder::_Decoder
type multipart_value = string | Pathname | File | _Reader
@ -30,6 +31,37 @@ module HTTPX
def read_from_part: (Integer? max_length) -> void
end
class Decoder
BOUNDARY_RE: Regexp
@state: :idle | :part_header | :part_body | :parse_boundary | :done
@buffer: String
@parts: Hash[String, untyped]
@boundary: String
@intermediate_boundary: String
def call: (Response response, untyped) -> Hash[String, untyped]
private
def initialize: (Response response) -> void
def parse: () -> void
def get_filename: (String head) -> String?
end
class FilePart # < SimpleDelegator
attr_reader original_filename: String
attr_reader content_type: String
# @file: Tempfile
# private
def initialize: (String filename, String content_type) -> void
end
module Part
def self?.call: (multipart_nested_value) -> ([_Reader, String, String?])
end

View File

@ -21,7 +21,7 @@ module HTTPX
end
interface _Decoder
def decode: (string) -> String
def call: (Response response, untyped options) -> untyped
end
end
end

View File

@ -7,6 +7,7 @@ module HTTPX::Transcoder
module Form
def self?.encode: (urlencoded_input form) -> Encoder
def self?.decode: (HTTPX::Response response) -> _Decoder
class Encoder
extend Forwardable

View File

@ -1,6 +1,7 @@
module HTTPX::Transcoder
module JSON
def self?.encode: (_ToJson json) -> Encoder
def self?.decode: (HTTPX::Response response) -> _Decoder
class Encoder
extend Forwardable