Skip to content

Commit ca9e03a

Browse files
use optional record keys for several API options
1 parent 4601d66 commit ca9e03a

File tree

15 files changed

+267
-45
lines changed

15 files changed

+267
-45
lines changed

stdlib/cgi/0/core.rbs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ class CGI
273273

274274
extend CGI::Util
275275

276+
type options_hash = {
277+
?accept_charset: String,
278+
?tag_maker: String,
279+
?max_multipart_length: Integer | ^() -> Integer
280+
}
281+
276282
# <!--
277283
# rdoc-file=lib/cgi/core.rb
278284
# - CGI.new(tag_maker) { block }
@@ -352,7 +358,7 @@ class CGI
352358
# varies according to the REQUEST_METHOD.
353359
#
354360
def initialize: (?String tag_maker) ?{ (String name, String value) -> void } -> void
355-
| (Hash[Symbol, untyped] options_hash) ?{ (String name, String value) -> void } -> void
361+
| (options_hash options_hash) ?{ (String name, String value) -> void } -> void
356362

357363
# <!--
358364
# rdoc-file=lib/cgi/core.rb

stdlib/csv/0/csv.rbs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,38 @@ class CSV < Object
16351635
include Enumerable[untyped]
16361636
extend Forwardable
16371637

1638+
type parsing_options = {
1639+
?row_sep: String | :auto,
1640+
?col_sep: String,
1641+
?quote_char: String,
1642+
?field_size_limit: Integer,
1643+
?converters: Symbol,
1644+
?unconverted_fields: bool,
1645+
?headers: bool | Symbol | String | Array[String],
1646+
?return_headers: bool,
1647+
?header_converters: Symbol,
1648+
?skip_blanks: bool,
1649+
?skip_lines: Regexp | String | nil,
1650+
?strip: bool,
1651+
?liberal_parsing: bool,
1652+
?nil_value: untyped,
1653+
?empty_value: untyped
1654+
}
1655+
1656+
type write_converter = ^(String field) -> String
1657+
1658+
type generating_options = {
1659+
?row_sep: String | :auto,
1660+
?col_sep: String,
1661+
?quote_char: String,
1662+
?write_headers: bool,
1663+
?force_quotes: bool,
1664+
?quote_empty: bool,
1665+
?write_converters: write_converter | Array[write_converter],
1666+
?write_nil_value: string,
1667+
?write_empty_value: string
1668+
}
1669+
16381670
# <!--
16391671
# rdoc-file=lib/csv.rb
16401672
# - foreach(path_or_io, mode='r', **options) {|row| ... )
@@ -1773,7 +1805,7 @@ class CSV < Object
17731805
# # Raises ArgumentError (Cannot parse nil as CSV):
17741806
# CSV.new(nil)
17751807
#
1776-
def initialize: (?String | IO | StringIO io, ?::Hash[Symbol, untyped] options) -> void
1808+
def initialize: (?String | IO | StringIO io, ?(parsing_options | generating_options) options) -> void
17771809

17781810
# <!--
17791811
# rdoc-file=lib/csv.rb
@@ -1895,7 +1927,7 @@ class CSV < Object
18951927
# # Raises NoMethodError (undefined method `close' for :foo:Symbol)
18961928
# CSV.parse(:foo)
18971929
#
1898-
def self.parse: (String str, ?::Hash[Symbol, untyped] options) ?{ (::Array[String?] arg0) -> void } -> ::Array[::Array[String?]]?
1930+
def self.parse: (String str, ?(parsing_options | generating_options) options) ?{ (::Array[String?] arg0) -> void } -> ::Array[::Array[String?]]?
18991931

19001932
# <!--
19011933
# rdoc-file=lib/csv.rb
@@ -1965,7 +1997,7 @@ class CSV < Object
19651997
# # Raises ArgumentError (Cannot parse nil as CSV):
19661998
# CSV.parse_line(nil)
19671999
#
1968-
def self.parse_line: (String str, ?::Hash[Symbol, untyped] options) -> ::Array[String?]?
2000+
def self.parse_line: (String str, ?(parsing_options | generating_options) options) -> ::Array[String?]?
19692001

19702002
# <!--
19712003
# rdoc-file=lib/csv.rb
@@ -2031,7 +2063,7 @@ class CSV < Object
20312063
# File.write(path, string)
20322064
# CSV.read(path, headers: true) # => #<CSV::Table mode:col_or_row row_count:4>
20332065
#
2034-
def self.read: (String path, ?::Hash[Symbol, untyped] options) -> ::Array[::Array[String?]]
2066+
def self.read: (String path, ?(parsing_options | generating_options) options) -> ::Array[::Array[String?]]
20352067

20362068
# <!--
20372069
# rdoc-file=lib/csv.rb

stdlib/date/0/date.rbs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
# * Other non-numeric: raises TypeError.
7272
#
7373
class Date
74+
type date_record = { mday: Integer, mon: Integer, year: Integer }
75+
76+
type datetime_with_timezone_record = { ?wday: Integer, ?mday: Integer, ?mon: Integer, ?year: Integer, ?hour: Integer, ?min: Integer, ?sec: Integer, ?zone: String, ?offset: Integer}
77+
7478
# <!--
7579
# rdoc-file=ext/date/date_core.c
7680
# - Date.new(year = -4712, month = 1, mday = 1, start = Date::ITALY) -> date
@@ -112,7 +116,7 @@ class Date
112116
#
113117
# Related: Date.httpdate (returns a Date object).
114118
#
115-
def self._httpdate: (String str) -> Hash[Symbol, Integer]
119+
def self._httpdate: (String str, ?limit: Integer) -> datetime_with_timezone_record
116120

117121
# <!--
118122
# rdoc-file=ext/date/date_core.c
@@ -130,7 +134,7 @@ class Date
130134
#
131135
# Related: Date.iso8601 (returns a Date object).
132136
#
133-
def self._iso8601: (String str) -> Hash[Symbol, Integer]
137+
def self._iso8601: (String str, ?limit: Integer) -> date_record
134138

135139
# <!--
136140
# rdoc-file=ext/date/date_core.c
@@ -147,7 +151,7 @@ class Date
147151
#
148152
# Related: Date.jisx0301 (returns a Date object).
149153
#
150-
def self._jisx0301: (String str) -> Hash[Symbol, Integer]
154+
def self._jisx0301: (String str, ?limit: Integer) -> date_record
151155

152156
# <!--
153157
# rdoc-file=ext/date/date_core.c
@@ -192,7 +196,7 @@ class Date
192196
#
193197
# Related: Date.rfc2822 (returns a Date object).
194198
#
195-
def self._rfc2822: (String str) -> Hash[Symbol, Integer | String]
199+
def self._rfc2822: (String str, ?limit: Integer) -> datetime_with_timezone_record
196200

197201
# <!--
198202
# rdoc-file=ext/date/date_core.c
@@ -210,7 +214,7 @@ class Date
210214
#
211215
# Related: Date.rfc3339 (returns a Date object).
212216
#
213-
def self._rfc3339: (String str) -> Hash[Symbol, Integer | String]
217+
def self._rfc3339: (String str, ?limit: Integer) -> datetime_with_timezone_record
214218

215219
# <!--
216220
# rdoc-file=ext/date/date_core.c
@@ -228,7 +232,7 @@ class Date
228232
#
229233
# Related: Date.rfc2822 (returns a Date object).
230234
#
231-
def self._rfc822: (String str) -> Hash[Symbol, Integer | String]
235+
def self._rfc822: (String str, ?limit: Integer) -> datetime_with_timezone_record
232236

233237
# <!--
234238
# rdoc-file=ext/date/date_core.c

stdlib/json/0/json.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface _JsonRead
1818
def read: () -> string
1919
end
2020

21-
type json_options = Hash[Symbol, untyped]
21+
type json_options = { ?max_nesting: bool, ?allow_nan: bool, ?script_safe: bool }
2222

2323
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
2424
# The base exception for JSON errors.

stdlib/net-http/0/manifest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dependencies:
22
- name: net-protocol
33
- name: uri
4+
- name: openssl

stdlib/net-http/0/net-http.rbs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,27 @@ module Net
913913
#
914914
def self.https_default_port: () -> Integer
915915

916+
type start_options = {
917+
?ca_file: String,
918+
?ca_path: String,
919+
?cert: OpenSSL::X509::Certificate,
920+
?cert_store: OpenSSL::X509::Store,
921+
?ciphers: Array[String],
922+
?close_on_empty_response: bool,
923+
?ipaddr: String,
924+
?keep_alive_timeout: Numeric,
925+
?key: OpenSSL::PKey::PKey,
926+
?open_timeout: Numeric,
927+
?read_timeout: Numeric,
928+
?ssl_timeout: Numeric,
929+
?ssl_version: OpenSSL::SSL::tls_version,
930+
?use_ssl: bool,
931+
?verify_callback: ^(bool preverify_ok, OpenSSL::X509::StoreContext store_ctx) -> boolish,
932+
?verify_depth: Integer,
933+
?verify_mode: OpenSSL::SSL::verify_mode,
934+
?write_timeout: Numeric
935+
}
936+
916937
# <!--
917938
# rdoc-file=lib/net/http.rb
918939
# - HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) -> http
@@ -1003,8 +1024,8 @@ module Net
10031024
# Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value
10041025
# passed to `new` is Net::HTTP.https_default_port, not `port`.
10051026
#
1006-
def self.start: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]? opt) -> Net::HTTP
1007-
| [T] (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]? opt) { (Net::HTTP) -> T } -> T
1027+
def self.start: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?start_options opt) -> Net::HTTP
1028+
| [T] (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?start_options opt) { (Net::HTTP) -> T } -> T
10081029

10091030
# <!--
10101031
# rdoc-file=lib/net/http.rb

0 commit comments

Comments
 (0)