fixing issues around typing

This commit is contained in:
HoneyryderChuck 2022-08-13 16:03:57 +01:00
parent c70209db4b
commit 535a30db25
4 changed files with 34 additions and 5 deletions

View File

@ -12,14 +12,22 @@ module HTTPX::Transcoder
MIME_TYPES = %r{\b(application|text)/(.+\+)?xml\b}.freeze
class Encoder < SimpleDelegator
class Encoder
def initialize(xml)
@raw = xml
end
def content_type
charset = respond_to?(:encoding) ? encoding.to_s.downcase : "utf-8"
charset = @raw.respond_to?(:encoding) ? @raw.encoding.to_s.downcase : "utf-8"
"application/xml; charset=#{charset}"
end
def bytesize
to_s.bytesize
@raw.to_s.bytesize
end
def to_s
@raw.to_s
end
end

View File

@ -20,7 +20,7 @@ module HTTPX::Transcoder
private
def initialize: (_ToJson json) -> untyped
def initialize: (_ToJson json) -> void
end
end
end

21
sig/transcoder/xml.rbs Normal file
View File

@ -0,0 +1,21 @@
module HTTPX::Transcoder
module XML
def self?.encode: (untyped xml) -> Encoder
def self?.decode: (HTTPX::Response response) -> _Decoder
class Encoder
@raw: untyped # can be nokogiri object
def content_type: () -> String
def bytesize: () -> (Integer | Float)
def to_s: () -> String
private
def initialize: (String xml) -> void
end
end
end

View File

@ -10,7 +10,7 @@ RUBY_ENGINE=`ruby -e 'puts RUBY_ENGINE'`
IPTABLES=iptables-translate
if [[ "$RUBY_ENGINE" = "truffleruby" ]]; then
dnf install -y iptables iproute which file idn2 git
dnf install -y iptables iproute which file idn2 git xz
elif [[ "$RUBY_PLATFORM" = "java" ]]; then
apt-get update && apt-get install -y build-essential iptables iproute2 file idn2 git
elif [[ ${RUBY_VERSION:0:3} = "2.1" ]]; then