added signatures to new modules

This commit is contained in:
HoneyryderChuck 2021-01-11 03:10:17 +00:00
parent 80f0ddfbc8
commit 7fa283097d
6 changed files with 42 additions and 9 deletions

View File

@ -3,18 +3,41 @@ module HTTPX
module Multipart
def self.load_dependencies: (singleton(Session)) -> void
def self.configure: (*untyped) -> void
def self?.encode: (untyped) -> Encoder
def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
type multipart_value = string | Pathname | File | _Reader
type record_multipart_value = multipart_value |
{ content_type: String, filename: String, body: multipart_value } |
{ content_type: String, body: multipart_value }
type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
type multipart_input = Enumerable[[string, multipart_value], untyped]
class Encoder
include Transcoder::_Encoder
include _ToS
include _Reader
def content_type: () -> String
private
def initialize: (Hash[Symbol | string, HTTP::FormData::Part | string] multipart_data) -> untyped
def initialize: (Hash[Symbol | string, multipart_nested_value] multipart_data) -> untyped
def multipart?: (top) -> bool
def header_part: (string key, String content_type, String? filename) -> StringIO
def read_chunks: (String buffer, Integer? length) -> void
def read_from_part: (Integer? max_length) -> void
end
module Part
def self?.call: (multipart_nested_value) -> ([_Reader, String, String?] | [_Reader, String])
end
module MimeTypeDetector
def self?.call: (IO file, ?String filename) -> String?
end
end
end

View File

@ -4,8 +4,8 @@ module HTTPX
module Transcoder
extend HTTPX::Registry[String, Class]
def self.normalize_keys: (string | Symbol, top) { (string, top) -> void } -> void
| (string | Symbol, top) { (string) -> void } -> void
def self.normalize_keys: (string | Symbol, top, ?Proc?) { (string, top) -> void } -> void
| (string | Symbol, top, ?Proc?) { (string) -> void } -> void
interface _Encoder
def bytesize: () -> Numeric

View File

@ -7,6 +7,8 @@ module HTTPX
@raw: bodyIO
def content_type: () -> String
private
def initialize: (untyped body ) -> untyped

View File

@ -1,5 +1,9 @@
module HTTPX::Transcoder
type urlencoded_input = Enumerable[[string, string], untyped]
type form_value = string
type form_nested_value = form_value | _ToAry[form_value] | _ToHash[string, form_value]
type urlencoded_input = Enumerable[[string, form_nested_value], untyped]
module Form
def self?.encode: (urlencoded_input form) -> Encoder
@ -8,6 +12,8 @@ module HTTPX::Transcoder
include _Encoder
include _ToS
def content_type: () -> String
private
def initialize: (urlencoded_input form) -> untyped

View File

@ -6,9 +6,11 @@ module HTTPX::Transcoder
include _Encoder
include _ToS
def content_type: () -> String
private
def initalize: (_ToJson json) -> untyped
def initialize: (_ToJson json) -> untyped
end
end
end

View File

@ -35,7 +35,7 @@ if [[ ${RUBY_VERSION:0:1} = "3" ]]; then
export RUBYOPT="$RUBYOPT -rbundler/setup -rrbs/test/setup"
export RBS_TEST_RAISE=true
export RBS_TEST_LOGLEVEL=error
export RBS_TEST_OPT="-Isig -ruri -rjson -ripaddr -rhttp-2-next"
export RBS_TEST_OPT="-Isig -ruri -rjson -ripaddr -rpathname -rhttp-2-next"
export RBS_TEST_TARGET="HTTP*"
fi