rbs 3.3.0.pre.1 → 3.3.0.pre.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +23 -3
- data/Gemfile +3 -0
- data/Gemfile.lock +7 -1
- data/core/set.rbs +3 -2
- data/lib/rbs/cli.rb +17 -4
- data/lib/rbs/prototype/rbi.rb +1 -1
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +64 -25
- data/lib/rbs/prototype/runtime.rb +8 -12
- data/lib/rbs/version.rb +1 -1
- data/sig/prototype/runtime.rbs +67 -9
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/open-uri/0/manifest.yaml +3 -0
- data/stdlib/open-uri/0/open-uri.rbs +341 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dc5c4dc317f2e52f4626a4fec99d333422d69e6e18ec9fcad02d710bf17a212
|
4
|
+
data.tar.gz: e9da32752089f0d923e82ee304e36751f28263adeb5893860d4f0f84f5b62caf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb722e98a22685907310de9465590da330bf86f4387fc40e65ce692a9fbbd6839d850a706ca7f489954048d40555d3040e83ffddb452494529febfcd98dbeff5
|
7
|
+
data.tar.gz: 2ed8a1e9a4bbb28341f5c578903a94a23ea3b6bcc95721308dcfddce514f269755f0f7baaaf2cb0a4511c7895fc39992fe2cdfe95ad33e66f045971cb137587e
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,25 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 3.3.0.pre.2 (2023-11-02)
|
6
|
+
|
7
|
+
### Signature updates
|
8
|
+
|
9
|
+
* net/smtp ([#1560](https://github.com/ruby/rbs/pull/1560))
|
10
|
+
* open-uri ([#1592](https://github.com/ruby/rbs/pull/1592))
|
11
|
+
* `Set` ([#1595](https://github.com/ruby/rbs/pull/1595))
|
12
|
+
|
13
|
+
### Library changes
|
14
|
+
|
15
|
+
* Fixup validation ([#1596](https://github.com/ruby/rbs/pull/1596))
|
16
|
+
* Print type syntax errors instead of raising error ([#1594](https://github.com/ruby/rbs/pull/1594))
|
17
|
+
|
18
|
+
#### rbs prototype
|
19
|
+
|
20
|
+
* Fix error when MASGN ([#1593](https://github.com/ruby/rbs/pull/1593))
|
21
|
+
* Support cases where `Module#constants` has been redefined ([#1591](https://github.com/ruby/rbs/pull/1591))
|
22
|
+
* [prototype runtime] Fix error if direct inherited ([#1590](https://github.com/ruby/rbs/pull/1590))
|
23
|
+
|
5
24
|
## 3.3.0.pre.1 (2023-10-31)
|
6
25
|
|
7
26
|
### Signature updates
|
@@ -38,7 +57,6 @@
|
|
38
57
|
* `constants.rbs` ([#1531](https://github.com/ruby/rbs/pull/1531))
|
39
58
|
* `::interned` ([#1499](https://github.com/ruby/rbs/pull/1499), [#1488](https://github.com/ruby/rbs/pull/1488))
|
40
59
|
|
41
|
-
|
42
60
|
### Language updates
|
43
61
|
|
44
62
|
* Add `__todo__` type ([#1520](https://github.com/ruby/rbs/pull/1520))
|
@@ -50,8 +68,10 @@
|
|
50
68
|
* Add `Abbrev` to runtime dependency ([#1573](https://github.com/ruby/rbs/pull/1573))
|
51
69
|
* Avoid an error when parsing files including SyntaxError ([#1574](https://github.com/ruby/rbs/pull/1574))
|
52
70
|
* Implement rbs diff command ([#1459](https://github.com/ruby/rbs/pull/1459))
|
53
|
-
* Add another type syntax validation ([#1566](https://github.com/ruby/rbs/pull/1566))
|
54
|
-
*
|
71
|
+
* Add another type syntax validation ([#1566](https://github.com/ruby/rbs/pull/1566))
|
72
|
+
* Mark global variables ([#1551](https://github.com/ruby/rbs/pull/1551))
|
73
|
+
* Show location of type by method command ([#1537](https://github.com/ruby/rbs/pull/1537))
|
74
|
+
* Make alias and interface names absolute ([#1502](https://github.com/ruby/rbs/pull/1502))
|
55
75
|
* Better record type format ([#1501](https://github.com/ruby/rbs/pull/1501))
|
56
76
|
* Should keep escape of alias and attr family ([#1486](https://github.com/ruby/rbs/pull/1486))
|
57
77
|
* Fix error when undefined interface or alias ([#1465](https://github.com/ruby/rbs/pull/1465))
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbs (3.3.0.pre.
|
4
|
+
rbs (3.3.0.pre.2)
|
5
5
|
abbrev
|
6
6
|
|
7
7
|
PATH
|
@@ -30,6 +30,10 @@ GEM
|
|
30
30
|
language_server-protocol (3.17.0.3)
|
31
31
|
marcel (1.0.2)
|
32
32
|
minitest (5.20.0)
|
33
|
+
net-protocol (0.2.1)
|
34
|
+
timeout
|
35
|
+
net-smtp (0.4.0)
|
36
|
+
net-protocol
|
33
37
|
parallel (1.23.0)
|
34
38
|
parser (3.2.2.4)
|
35
39
|
ast (~> 2.4.1)
|
@@ -82,6 +86,7 @@ GEM
|
|
82
86
|
tempfile (0.1.3)
|
83
87
|
test-unit (3.6.1)
|
84
88
|
power_assert
|
89
|
+
timeout (0.4.0)
|
85
90
|
unicode-display_width (2.5.0)
|
86
91
|
|
87
92
|
PLATFORMS
|
@@ -95,6 +100,7 @@ DEPENDENCIES
|
|
95
100
|
json
|
96
101
|
json-schema
|
97
102
|
minitest
|
103
|
+
net-smtp
|
98
104
|
rake
|
99
105
|
rake-compiler
|
100
106
|
rbs!
|
data/core/set.rbs
CHANGED
@@ -439,7 +439,7 @@ class Set[unchecked out A]
|
|
439
439
|
# Set[1, 2, 3].disjoint? [3, 4] #=> false
|
440
440
|
# Set[1, 2, 3].disjoint? 4..5 #=> true
|
441
441
|
#
|
442
|
-
def disjoint?: (
|
442
|
+
def disjoint?: (_Each[A]) -> bool
|
443
443
|
|
444
444
|
# <!--
|
445
445
|
# rdoc-file=lib/set.rb
|
@@ -502,7 +502,7 @@ class Set[unchecked out A]
|
|
502
502
|
# Set[1, 2, 3].intersect? 4..5 #=> false
|
503
503
|
# Set[1, 2, 3].intersect? [3, 4] #=> true
|
504
504
|
#
|
505
|
-
def intersect?: (
|
505
|
+
def intersect?: (_Each[A]) -> bool
|
506
506
|
|
507
507
|
# <!--
|
508
508
|
# rdoc-file=lib/set.rb
|
@@ -625,4 +625,5 @@ module Enumerable[unchecked out Elem]
|
|
625
625
|
# Needs to `require "set"` to use this method.
|
626
626
|
#
|
627
627
|
def to_set: () -> Set[Elem]
|
628
|
+
| [T] { (Elem) -> T } -> Set[T]
|
628
629
|
end
|
data/lib/rbs/cli.rb
CHANGED
@@ -444,6 +444,8 @@ EOU
|
|
444
444
|
end
|
445
445
|
|
446
446
|
def run_validate(args, options)
|
447
|
+
stdout = stdout()
|
448
|
+
|
447
449
|
OptionParser.new do |opts|
|
448
450
|
opts.banner = <<EOU
|
449
451
|
Usage: rbs validate
|
@@ -456,7 +458,7 @@ Examples:
|
|
456
458
|
EOU
|
457
459
|
|
458
460
|
opts.on("--silent") do
|
459
|
-
|
461
|
+
stdout = StringIO.new
|
460
462
|
end
|
461
463
|
end.parse!(args)
|
462
464
|
|
@@ -466,17 +468,19 @@ EOU
|
|
466
468
|
builder = DefinitionBuilder.new(env: env)
|
467
469
|
validator = Validator.new(env: env, resolver: Resolver::TypeNameResolver.new(env))
|
468
470
|
|
471
|
+
syntax_errors = [] #: Array[String]
|
472
|
+
|
469
473
|
no_self_type_validator = ->(type) {
|
470
474
|
# @type var type: Types::t | MethodType
|
471
475
|
if type.has_self_type?
|
472
|
-
|
476
|
+
syntax_errors << "#{type.location}: `self` type is not allowed in this context"
|
473
477
|
end
|
474
478
|
}
|
475
479
|
|
476
480
|
no_classish_type_validator = ->(type) {
|
477
481
|
# @type var type: Types::t | MethodType
|
478
482
|
if type.has_classish_type?
|
479
|
-
|
483
|
+
syntax_errors << "#{type.location}: `instance` or `class` type is not allowed in this context"
|
480
484
|
end
|
481
485
|
}
|
482
486
|
|
@@ -486,7 +490,7 @@ EOU
|
|
486
490
|
next if type.is_a?(Types::Bases::Void)
|
487
491
|
end
|
488
492
|
if type.with_nonreturn_void?
|
489
|
-
|
493
|
+
syntax_errors << "#{type.location}: `void` type is only allowed in return type or generics parameter"
|
490
494
|
end
|
491
495
|
}
|
492
496
|
|
@@ -621,6 +625,15 @@ EOU
|
|
621
625
|
no_classish_type_validator[decl.decl.type]
|
622
626
|
void_type_context_validator[decl.decl.type]
|
623
627
|
end
|
628
|
+
|
629
|
+
unless syntax_errors.empty?
|
630
|
+
syntax_errors.sort!
|
631
|
+
syntax_errors.uniq!
|
632
|
+
syntax_errors.each do |message|
|
633
|
+
self.stdout.puts message
|
634
|
+
end
|
635
|
+
exit(1)
|
636
|
+
end
|
624
637
|
end
|
625
638
|
|
626
639
|
def run_constant(args, options)
|
data/lib/rbs/prototype/rbi.rb
CHANGED
@@ -246,7 +246,7 @@ module RBS
|
|
246
246
|
end
|
247
247
|
end
|
248
248
|
value_node = node.children.last
|
249
|
-
type = if value_node.type == :CALL && value_node.children[1] == :let
|
249
|
+
type = if value_node && value_node.type == :CALL && value_node.children[1] == :let
|
250
250
|
type_node = each_arg(value_node.children[2]).to_a[1]
|
251
251
|
type_of type_node, variables: current_module&.type_params || []
|
252
252
|
else
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBS
|
4
|
+
module Prototype
|
5
|
+
class Runtime
|
6
|
+
module Reflection
|
7
|
+
def self.object_class(value)
|
8
|
+
@object_class ||= Object.instance_method(:class)
|
9
|
+
@object_class.bind_call(value)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.constants_of(mod, inherit = true)
|
13
|
+
@constants_of ||= Module.instance_method(:constants)
|
14
|
+
@constants_of.bind_call(mod, inherit)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -85,6 +85,16 @@ module RBS
|
|
85
85
|
end
|
86
86
|
|
87
87
|
class StructGenerator < ValueObjectBase
|
88
|
+
def self.generatable?(target)
|
89
|
+
return false unless target < Struct
|
90
|
+
# Avoid direct inherited class like `class Option < Struct`
|
91
|
+
return false unless target.respond_to?(:members)
|
92
|
+
|
93
|
+
true
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
88
98
|
CAN_CALL_KEYWORD_INIT_P = Struct.new(:tmp).respond_to?(:keyword_init?)
|
89
99
|
|
90
100
|
def build_super_class
|
@@ -104,31 +114,21 @@ module RBS
|
|
104
114
|
[:new, :[]].map do |name|
|
105
115
|
new_overloads = []
|
106
116
|
|
107
|
-
if CAN_CALL_KEYWORD_INIT_P
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
new_overloads <<
|
122
|
-
annotations: [],
|
123
|
-
method_type: MethodType.new(
|
124
|
-
type: Types::Function.empty(Types::Bases::Instance.new(location: nil)).update(
|
125
|
-
optional_keywords: @target_class.members.to_h { |m| [m, Types::Function::Param.new(name: nil, type: untyped)] },
|
126
|
-
),
|
127
|
-
type_params: [],
|
128
|
-
block: nil,
|
129
|
-
location: nil,
|
130
|
-
)
|
131
|
-
)
|
117
|
+
if CAN_CALL_KEYWORD_INIT_P
|
118
|
+
case @target_class.keyword_init?
|
119
|
+
when false
|
120
|
+
new_overloads << build_overload_for_positional_arguments
|
121
|
+
when true
|
122
|
+
new_overloads << build_overload_for_keyword_arguments
|
123
|
+
when nil
|
124
|
+
new_overloads << build_overload_for_positional_arguments
|
125
|
+
new_overloads << build_overload_for_keyword_arguments
|
126
|
+
else
|
127
|
+
raise
|
128
|
+
end
|
129
|
+
else
|
130
|
+
new_overloads << build_overload_for_positional_arguments
|
131
|
+
new_overloads << build_overload_for_keyword_arguments
|
132
132
|
end
|
133
133
|
|
134
134
|
AST::Members::MethodDefinition.new(
|
@@ -144,6 +144,34 @@ module RBS
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
def build_overload_for_positional_arguments
|
148
|
+
AST::Members::MethodDefinition::Overload.new(
|
149
|
+
annotations: [],
|
150
|
+
method_type: MethodType.new(
|
151
|
+
type: Types::Function.empty(Types::Bases::Instance.new(location: nil)).update(
|
152
|
+
optional_positionals: @target_class.members.map { |m| Types::Function::Param.new(name: m, type: untyped) },
|
153
|
+
),
|
154
|
+
type_params: [],
|
155
|
+
block: nil,
|
156
|
+
location: nil,
|
157
|
+
)
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
def build_overload_for_keyword_arguments
|
162
|
+
AST::Members::MethodDefinition::Overload.new(
|
163
|
+
annotations: [],
|
164
|
+
method_type: MethodType.new(
|
165
|
+
type: Types::Function.empty(Types::Bases::Instance.new(location: nil)).update(
|
166
|
+
optional_keywords: @target_class.members.to_h { |m| [m, Types::Function::Param.new(name: nil, type: untyped)] },
|
167
|
+
),
|
168
|
+
type_params: [],
|
169
|
+
block: nil,
|
170
|
+
location: nil,
|
171
|
+
)
|
172
|
+
)
|
173
|
+
end
|
174
|
+
|
147
175
|
# def self.keyword_init?: () -> bool?
|
148
176
|
def build_s_keyword_init_p
|
149
177
|
return [] unless CAN_CALL_KEYWORD_INIT_P
|
@@ -179,6 +207,17 @@ module RBS
|
|
179
207
|
end
|
180
208
|
|
181
209
|
class DataGenerator < ValueObjectBase
|
210
|
+
def self.generatable?(target)
|
211
|
+
return false unless RUBY_VERSION >= '3.2'
|
212
|
+
return false unless target < Data
|
213
|
+
# Avoid direct inherited class like `class Option < Data`
|
214
|
+
return false unless target.respond_to?(:members)
|
215
|
+
|
216
|
+
true
|
217
|
+
end
|
218
|
+
|
219
|
+
private
|
220
|
+
|
182
221
|
def build_super_class
|
183
222
|
AST::Declarations::Class::Super.new(name: TypeName("::Data"), args: [], location: nil)
|
184
223
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'runtime/helpers'
|
4
4
|
require_relative 'runtime/value_object_generator'
|
5
|
+
require_relative 'runtime/reflection'
|
5
6
|
|
6
7
|
module RBS
|
7
8
|
module Prototype
|
@@ -422,7 +423,7 @@ module RBS
|
|
422
423
|
|
423
424
|
def generate_constants(mod, decls)
|
424
425
|
module_name = const_name!(mod)
|
425
|
-
|
426
|
+
Reflection.constants_of(mod, false).sort.each do |name|
|
426
427
|
next if todo_object&.skip_constant?(module_name: module_name, name: name)
|
427
428
|
|
428
429
|
begin
|
@@ -432,10 +433,10 @@ module RBS
|
|
432
433
|
next
|
433
434
|
end
|
434
435
|
|
435
|
-
next if object_class(value).equal?(Class)
|
436
|
-
next if object_class(value).equal?(Module)
|
436
|
+
next if Reflection.object_class(value).equal?(Class)
|
437
|
+
next if Reflection.object_class(value).equal?(Module)
|
437
438
|
|
438
|
-
unless object_class(value).name
|
439
|
+
unless Reflection.object_class(value).name
|
439
440
|
RBS.logger.warn("Skipping constant #{name} #{value} of #{mod} as an instance of anonymous class")
|
440
441
|
next
|
441
442
|
end
|
@@ -453,7 +454,7 @@ module RBS
|
|
453
454
|
when ENV
|
454
455
|
Types::ClassInstance.new(name: TypeName("::RBS::Unnamed::ENVClass"), args: [], location: nil)
|
455
456
|
else
|
456
|
-
value_type_name = to_type_name(const_name!(object_class(value)), full_name: true).absolute!
|
457
|
+
value_type_name = to_type_name(const_name!(Reflection.object_class(value)), full_name: true).absolute!
|
457
458
|
args = type_args(value_type_name)
|
458
459
|
Types::ClassInstance.new(name: value_type_name, args: args, location: nil)
|
459
460
|
end
|
@@ -493,9 +494,9 @@ module RBS
|
|
493
494
|
end #: AST::Declarations::Class?
|
494
495
|
|
495
496
|
unless decl
|
496
|
-
if mod
|
497
|
+
if StructGenerator.generatable?(mod)
|
497
498
|
decl = StructGenerator.new(mod).build_decl
|
498
|
-
elsif
|
499
|
+
elsif DataGenerator.generatable?(mod)
|
499
500
|
decl = DataGenerator.new(mod).build_decl
|
500
501
|
else
|
501
502
|
decl = AST::Declarations::Class.new(
|
@@ -631,11 +632,6 @@ module RBS
|
|
631
632
|
destination
|
632
633
|
end
|
633
634
|
|
634
|
-
def object_class(value)
|
635
|
-
@object_class ||= Object.instance_method(:class)
|
636
|
-
@object_class.bind_call(value)
|
637
|
-
end
|
638
|
-
|
639
635
|
def type_args(type_name)
|
640
636
|
if class_decl = env.class_decls.fetch(type_name.absolute!, nil)
|
641
637
|
class_decl.type_params.size.times.map { Types::Bases::Any.new(location: nil) }
|
data/lib/rbs/version.rb
CHANGED
data/sig/prototype/runtime.rbs
CHANGED
@@ -1,6 +1,73 @@
|
|
1
1
|
module RBS
|
2
2
|
module Prototype
|
3
3
|
class Runtime
|
4
|
+
module Reflection
|
5
|
+
def self.object_class: (Module value) -> Class
|
6
|
+
|
7
|
+
def self.constants_of: (Module mod, ?bool inherit) -> Array[Symbol]
|
8
|
+
end
|
9
|
+
|
10
|
+
module Helpers
|
11
|
+
private
|
12
|
+
|
13
|
+
def const_name: (Module const) -> String?
|
14
|
+
|
15
|
+
def const_name!: (Module const) -> String
|
16
|
+
|
17
|
+
# Returns the exact name & not compactly declared name
|
18
|
+
def only_name: (Module mod) -> String
|
19
|
+
|
20
|
+
def to_type_name: (String name, ?full_name: bool) -> TypeName
|
21
|
+
|
22
|
+
def untyped: () -> untyped
|
23
|
+
end
|
24
|
+
|
25
|
+
class ValueObjectBase
|
26
|
+
include Helpers
|
27
|
+
|
28
|
+
def build_decl: () -> AST::Declarations::Class
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def build_member_accessors: (untyped ast_members_class) -> untyped
|
33
|
+
|
34
|
+
def build_s_members: () -> Array[AST::Members::MethodDefinition]
|
35
|
+
|
36
|
+
def initialize: (Class target_class) -> void
|
37
|
+
end
|
38
|
+
|
39
|
+
class StructGenerator < ValueObjectBase
|
40
|
+
def self.generatable?: (Class target) -> bool
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def add_decl_members: (AST::Declarations::Class decl) -> void
|
45
|
+
|
46
|
+
def build_overload_for_keyword_arguments: () -> AST::Members::MethodDefinition::Overload
|
47
|
+
|
48
|
+
def build_overload_for_positional_arguments: () -> AST::Members::MethodDefinition::Overload
|
49
|
+
|
50
|
+
def build_s_keyword_init_p: () -> Array[AST::Members::MethodDefinition]
|
51
|
+
|
52
|
+
def build_s_new: () -> Array[AST::Members::MethodDefinition]
|
53
|
+
|
54
|
+
def build_super_class: () -> AST::Declarations::Class::Super
|
55
|
+
|
56
|
+
CAN_CALL_KEYWORD_INIT_P: bool
|
57
|
+
end
|
58
|
+
|
59
|
+
class DataGenerator < ValueObjectBase
|
60
|
+
def self.generatable?: (Class target) -> bool
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def add_decl_members: (AST::Declarations::Class decl) -> void
|
65
|
+
|
66
|
+
def build_s_new: () -> Array[AST::Members::MethodDefinition]
|
67
|
+
|
68
|
+
def build_super_class: () -> AST::Declarations::Class::Super
|
69
|
+
end
|
70
|
+
|
4
71
|
class Todo
|
5
72
|
@builder: DefinitionBuilder
|
6
73
|
|
@@ -58,8 +125,6 @@ module RBS
|
|
58
125
|
|
59
126
|
def decls: () -> Array[AST::Declarations::t]
|
60
127
|
|
61
|
-
def to_type_name: (String name, ?full_name: bool) -> TypeName
|
62
|
-
|
63
128
|
def each_mixined_module: (TypeName type_name, Module mod) { (TypeName, TypeName, mixin_class) -> void } -> void
|
64
129
|
|
65
130
|
def each_mixined_module_one: (TypeName type_name, Module mod) { (TypeName, TypeName, bool) -> void } -> void
|
@@ -87,13 +152,6 @@ module RBS
|
|
87
152
|
# This generates/finds declarations in nested form & returns the last array of declarations
|
88
153
|
def ensure_outer_module_declarations: (Module mod) -> Array[AST::Declarations::Class::member]
|
89
154
|
|
90
|
-
# Returns the exact name & not compactly declared name
|
91
|
-
def only_name: (Module mod) -> String
|
92
|
-
|
93
|
-
def const_name: (Module const) -> String?
|
94
|
-
|
95
|
-
def const_name!: (Module const) -> String
|
96
|
-
|
97
155
|
def object_class: (untyped) -> untyped
|
98
156
|
|
99
157
|
def type_args: (TypeName type_name) -> Array[Types::t]
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Net
|
2
|
+
# Module mixed in to all SMTP error classes
|
3
|
+
module SMTPError
|
4
|
+
attr_reader response: Response
|
5
|
+
|
6
|
+
def initialize: (Response response, ?message: String) -> void
|
7
|
+
|
8
|
+
def message: () -> String?
|
9
|
+
end
|
10
|
+
|
11
|
+
# Represents an SMTP authentication error.
|
12
|
+
class SMTPAuthenticationError < ProtoAuthError
|
13
|
+
include SMTPError
|
14
|
+
end
|
15
|
+
|
16
|
+
# Represents SMTP error code 4xx, a temporary error.
|
17
|
+
class SMTPServerBusy < ProtoServerError
|
18
|
+
include SMTPError
|
19
|
+
end
|
20
|
+
|
21
|
+
# Represents an SMTP command syntax error (error code 500)
|
22
|
+
class SMTPSyntaxError < ProtoSyntaxError
|
23
|
+
include SMTPError
|
24
|
+
end
|
25
|
+
|
26
|
+
# Represents a fatal SMTP error (error code 5xx, except for 500)
|
27
|
+
class SMTPFatalError < ProtoFatalError
|
28
|
+
include SMTPError
|
29
|
+
end
|
30
|
+
|
31
|
+
# Unexpected reply code returned from server.
|
32
|
+
class SMTPUnknownError < ProtoUnknownError
|
33
|
+
include SMTPError
|
34
|
+
end
|
35
|
+
|
36
|
+
# Command is not supported on server.
|
37
|
+
class SMTPUnsupportedCommand < ProtocolError
|
38
|
+
include SMTPError
|
39
|
+
end
|
40
|
+
|
41
|
+
class SMTP < Protocol
|
42
|
+
def self.start: (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) -> instance
|
43
|
+
| [T] (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) { (instance) -> T } -> T
|
44
|
+
| (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) -> instance
|
45
|
+
| [T] (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) { (instance) -> T } -> T
|
46
|
+
|
47
|
+
def initialize: (String address, ?Integer port) -> void
|
48
|
+
def send_message: (_Each[String] mail_src, String from_addr, *String to_addrs) -> void
|
49
|
+
end
|
50
|
+
|
51
|
+
class Response
|
52
|
+
end
|
53
|
+
|
54
|
+
class SMTPSession = SMTP
|
55
|
+
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
%a{annotate:rdoc:skip}
|
2
|
+
module URI
|
3
|
+
# <!--
|
4
|
+
# rdoc-file=lib/open-uri.rb
|
5
|
+
# - open(name, *rest, &block)
|
6
|
+
# -->
|
7
|
+
# Allows the opening of various resources including URIs.
|
8
|
+
#
|
9
|
+
# If the first argument responds to the 'open' method, 'open' is called on it
|
10
|
+
# with the rest of the arguments.
|
11
|
+
#
|
12
|
+
# If the first argument is a string that begins with `(protocol)://`, it is
|
13
|
+
# parsed by URI.parse. If the parsed object responds to the 'open' method,
|
14
|
+
# 'open' is called on it with the rest of the arguments.
|
15
|
+
#
|
16
|
+
# Otherwise, Kernel#open is called.
|
17
|
+
#
|
18
|
+
# OpenURI::OpenRead#open provides URI::HTTP#open, URI::HTTPS#open and
|
19
|
+
# URI::FTP#open, Kernel#open.
|
20
|
+
#
|
21
|
+
# We can accept URIs and strings that begin with http://, https:// and ftp://.
|
22
|
+
# In these cases, the opened file object is extended by OpenURI::Meta.
|
23
|
+
#
|
24
|
+
def self.open: (String name, ?String mode, ?Integer perm, ?untyped options) -> (StringIO & OpenURI::Meta | Tempfile & OpenURI::Meta)
|
25
|
+
| [T] (String name, ?String mode, ?Integer perm, ?untyped options) { (StringIO | Tempfile) -> T } -> T
|
26
|
+
end
|
27
|
+
|
28
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
29
|
+
# OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
|
30
|
+
#
|
31
|
+
# ## Example
|
32
|
+
#
|
33
|
+
# It is possible to open an http, https or ftp URL as though it were a file:
|
34
|
+
#
|
35
|
+
# URI.open("http://www.ruby-lang.org/") {|f|
|
36
|
+
# f.each_line {|line| p line}
|
37
|
+
# }
|
38
|
+
#
|
39
|
+
# The opened file has several getter methods for its meta-information, as
|
40
|
+
# follows, since it is extended by OpenURI::Meta.
|
41
|
+
#
|
42
|
+
# URI.open("http://www.ruby-lang.org/en") {|f|
|
43
|
+
# f.each_line {|line| p line}
|
44
|
+
# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
|
45
|
+
# p f.content_type # "text/html"
|
46
|
+
# p f.charset # "iso-8859-1"
|
47
|
+
# p f.content_encoding # []
|
48
|
+
# p f.last_modified # Thu Dec 05 02:45:02 UTC 2002
|
49
|
+
# }
|
50
|
+
#
|
51
|
+
# Additional header fields can be specified by an optional hash argument.
|
52
|
+
#
|
53
|
+
# URI.open("http://www.ruby-lang.org/en/",
|
54
|
+
# "User-Agent" => "Ruby/#{RUBY_VERSION}",
|
55
|
+
# "From" => "foo@bar.invalid",
|
56
|
+
# "Referer" => "http://www.ruby-lang.org/") {|f|
|
57
|
+
# # ...
|
58
|
+
# }
|
59
|
+
#
|
60
|
+
# The environment variables such as http_proxy, https_proxy and ftp_proxy are in
|
61
|
+
# effect by default. Here we disable proxy:
|
62
|
+
#
|
63
|
+
# URI.open("http://www.ruby-lang.org/en/", :proxy => nil) {|f|
|
64
|
+
# # ...
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# See OpenURI::OpenRead.open and URI.open for more on available options.
|
68
|
+
#
|
69
|
+
# URI objects can be opened in a similar way.
|
70
|
+
#
|
71
|
+
# uri = URI.parse("http://www.ruby-lang.org/en/")
|
72
|
+
# uri.open {|f|
|
73
|
+
# # ...
|
74
|
+
# }
|
75
|
+
#
|
76
|
+
# URI objects can be read directly. The returned string is also extended by
|
77
|
+
# OpenURI::Meta.
|
78
|
+
#
|
79
|
+
# str = uri.read
|
80
|
+
# p str.base_uri
|
81
|
+
#
|
82
|
+
# Author
|
83
|
+
# : Tanaka Akira <akr@m17n.org>
|
84
|
+
#
|
85
|
+
module OpenURI
|
86
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
87
|
+
# Mixin for holding meta-information.
|
88
|
+
#
|
89
|
+
module Meta
|
90
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
91
|
+
# returns an Array that consists of status code and message.
|
92
|
+
#
|
93
|
+
attr_accessor status: [ String, String ]
|
94
|
+
|
95
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
96
|
+
# returns a URI that is the base of relative URIs in the data. It may differ
|
97
|
+
# from the URI supplied by a user due to redirection.
|
98
|
+
#
|
99
|
+
attr_accessor base_uri: URI::Generic
|
100
|
+
|
101
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
102
|
+
# returns a Hash that represents header fields. The Hash keys are downcased for
|
103
|
+
# canonicalization. The Hash values are a field body. If there are multiple
|
104
|
+
# field with same field name, the field values are concatenated with a comma.
|
105
|
+
#
|
106
|
+
attr_reader meta: Hash[String, String]
|
107
|
+
|
108
|
+
# <!--
|
109
|
+
# rdoc-file=lib/open-uri.rb
|
110
|
+
# - last_modified()
|
111
|
+
# -->
|
112
|
+
# returns a Time that represents the Last-Modified field.
|
113
|
+
#
|
114
|
+
def last_modified: () -> Time?
|
115
|
+
|
116
|
+
# <!--
|
117
|
+
# rdoc-file=lib/open-uri.rb
|
118
|
+
# - content_type()
|
119
|
+
# -->
|
120
|
+
# returns "type/subtype" which is MIME Content-Type. It is downcased for
|
121
|
+
# canonicalization. Content-Type parameters are stripped.
|
122
|
+
#
|
123
|
+
def content_type: () -> String
|
124
|
+
|
125
|
+
def charet: () -> String?
|
126
|
+
|
127
|
+
# <!--
|
128
|
+
# rdoc-file=lib/open-uri.rb
|
129
|
+
# - content_encoding()
|
130
|
+
# -->
|
131
|
+
# Returns a list of encodings in Content-Encoding field as an array of strings.
|
132
|
+
#
|
133
|
+
# The encodings are downcased for canonicalization.
|
134
|
+
#
|
135
|
+
def content_encoding: () -> Array[String]
|
136
|
+
end
|
137
|
+
|
138
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
139
|
+
# Mixin for HTTP and FTP URIs.
|
140
|
+
#
|
141
|
+
module OpenRead
|
142
|
+
# <!--
|
143
|
+
# rdoc-file=lib/open-uri.rb
|
144
|
+
# - open(*rest, &block)
|
145
|
+
# -->
|
146
|
+
# OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP.
|
147
|
+
#
|
148
|
+
# OpenURI::OpenRead#open takes optional 3 arguments as:
|
149
|
+
#
|
150
|
+
# OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }]
|
151
|
+
#
|
152
|
+
# OpenURI::OpenRead#open returns an IO-like object if block is not given.
|
153
|
+
# Otherwise it yields the IO object and return the value of the block. The IO
|
154
|
+
# object is extended with OpenURI::Meta.
|
155
|
+
#
|
156
|
+
# `mode` and `perm` are the same as Kernel#open.
|
157
|
+
#
|
158
|
+
# However, `mode` must be read mode because OpenURI::OpenRead#open doesn't
|
159
|
+
# support write mode (yet). Also `perm` is ignored because it is meaningful only
|
160
|
+
# for file creation.
|
161
|
+
#
|
162
|
+
# `options` must be a hash.
|
163
|
+
#
|
164
|
+
# Each option with a string key specifies an extra header field for HTTP. I.e.,
|
165
|
+
# it is ignored for FTP without HTTP proxy.
|
166
|
+
#
|
167
|
+
# The hash may include other options, where keys are symbols:
|
168
|
+
#
|
169
|
+
# :proxy
|
170
|
+
# : Synopsis:
|
171
|
+
# :proxy => "http://proxy.foo.com:8000/"
|
172
|
+
# :proxy => URI.parse("http://proxy.foo.com:8000/")
|
173
|
+
# :proxy => true
|
174
|
+
# :proxy => false
|
175
|
+
# :proxy => nil
|
176
|
+
#
|
177
|
+
# If :proxy option is specified, the value should be String, URI, boolean or
|
178
|
+
# nil.
|
179
|
+
#
|
180
|
+
# When String or URI is given, it is treated as proxy URI.
|
181
|
+
#
|
182
|
+
# When true is given or the option itself is not specified, environment
|
183
|
+
# variable `scheme_proxy' is examined. `scheme' is replaced by `http',
|
184
|
+
# `https' or `ftp'.
|
185
|
+
#
|
186
|
+
# When false or nil is given, the environment variables are ignored and
|
187
|
+
# connection will be made to a server directly.
|
188
|
+
#
|
189
|
+
# :proxy_http_basic_authentication
|
190
|
+
# : Synopsis:
|
191
|
+
# :proxy_http_basic_authentication =>
|
192
|
+
# ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"]
|
193
|
+
# :proxy_http_basic_authentication =>
|
194
|
+
# [URI.parse("http://proxy.foo.com:8000/"),
|
195
|
+
# "proxy-user", "proxy-password"]
|
196
|
+
#
|
197
|
+
# If :proxy option is specified, the value should be an Array with 3
|
198
|
+
# elements. It should contain a proxy URI, a proxy user name and a proxy
|
199
|
+
# password. The proxy URI should be a String, an URI or nil. The proxy
|
200
|
+
# user name and password should be a String.
|
201
|
+
#
|
202
|
+
# If nil is given for the proxy URI, this option is just ignored.
|
203
|
+
#
|
204
|
+
# If :proxy and :proxy_http_basic_authentication is specified, ArgumentError
|
205
|
+
# is raised.
|
206
|
+
#
|
207
|
+
# :http_basic_authentication
|
208
|
+
# : Synopsis:
|
209
|
+
# :http_basic_authentication=>[user, password]
|
210
|
+
#
|
211
|
+
# If :http_basic_authentication is specified, the value should be an array
|
212
|
+
# which contains 2 strings: username and password. It is used for HTTP Basic
|
213
|
+
# authentication defined by RFC 2617.
|
214
|
+
#
|
215
|
+
# :content_length_proc
|
216
|
+
# : Synopsis:
|
217
|
+
# :content_length_proc => lambda {|content_length| ... }
|
218
|
+
#
|
219
|
+
# If :content_length_proc option is specified, the option value procedure is
|
220
|
+
# called before actual transfer is started. It takes one argument, which is
|
221
|
+
# expected content length in bytes.
|
222
|
+
#
|
223
|
+
# If two or more transfers are performed by HTTP redirection, the procedure
|
224
|
+
# is called only once for the last transfer.
|
225
|
+
#
|
226
|
+
# When expected content length is unknown, the procedure is called with nil.
|
227
|
+
# This happens when the HTTP response has no Content-Length header.
|
228
|
+
#
|
229
|
+
# :progress_proc
|
230
|
+
# : Synopsis:
|
231
|
+
# :progress_proc => lambda {|size| ...}
|
232
|
+
#
|
233
|
+
# If :progress_proc option is specified, the proc is called with one
|
234
|
+
# argument each time when `open' gets content fragment from network. The
|
235
|
+
# argument `size` is the accumulated transferred size in bytes.
|
236
|
+
#
|
237
|
+
# If two or more transfer is done by HTTP redirection, the procedure is
|
238
|
+
# called only one for a last transfer.
|
239
|
+
#
|
240
|
+
# :progress_proc and :content_length_proc are intended to be used for
|
241
|
+
# progress bar. For example, it can be implemented as follows using
|
242
|
+
# Ruby/ProgressBar.
|
243
|
+
#
|
244
|
+
# pbar = nil
|
245
|
+
# open("http://...",
|
246
|
+
# :content_length_proc => lambda {|t|
|
247
|
+
# if t && 0 < t
|
248
|
+
# pbar = ProgressBar.new("...", t)
|
249
|
+
# pbar.file_transfer_mode
|
250
|
+
# end
|
251
|
+
# },
|
252
|
+
# :progress_proc => lambda {|s|
|
253
|
+
# pbar.set s if pbar
|
254
|
+
# }) {|f| ... }
|
255
|
+
#
|
256
|
+
# :read_timeout
|
257
|
+
# : Synopsis:
|
258
|
+
# :read_timeout=>nil (no timeout)
|
259
|
+
# :read_timeout=>10 (10 second)
|
260
|
+
#
|
261
|
+
# :read_timeout option specifies a timeout of read for http connections.
|
262
|
+
#
|
263
|
+
# :open_timeout
|
264
|
+
# : Synopsis:
|
265
|
+
# :open_timeout=>nil (no timeout)
|
266
|
+
# :open_timeout=>10 (10 second)
|
267
|
+
#
|
268
|
+
# :open_timeout option specifies a timeout of open for http connections.
|
269
|
+
#
|
270
|
+
# :ssl_ca_cert
|
271
|
+
# : Synopsis:
|
272
|
+
# :ssl_ca_cert=>filename or an Array of filenames
|
273
|
+
#
|
274
|
+
# :ssl_ca_cert is used to specify CA certificate for SSL. If it is given,
|
275
|
+
# default certificates are not used.
|
276
|
+
#
|
277
|
+
# :ssl_verify_mode
|
278
|
+
# : Synopsis:
|
279
|
+
# :ssl_verify_mode=>mode
|
280
|
+
#
|
281
|
+
# :ssl_verify_mode is used to specify openssl verify mode.
|
282
|
+
#
|
283
|
+
# :ssl_min_version
|
284
|
+
# : Synopsis:
|
285
|
+
# :ssl_min_version=>:TLS1_2
|
286
|
+
#
|
287
|
+
# :ssl_min_version option specifies the minimum allowed SSL/TLS protocol
|
288
|
+
# version. See also OpenSSL::SSL::SSLContext#min_version=.
|
289
|
+
#
|
290
|
+
# :ssl_max_version
|
291
|
+
# : Synopsis:
|
292
|
+
# :ssl_max_version=>:TLS1_2
|
293
|
+
#
|
294
|
+
# :ssl_max_version option specifies the maximum allowed SSL/TLS protocol
|
295
|
+
# version. See also OpenSSL::SSL::SSLContext#max_version=.
|
296
|
+
#
|
297
|
+
# :ftp_active_mode
|
298
|
+
# : Synopsis:
|
299
|
+
# :ftp_active_mode=>bool
|
300
|
+
#
|
301
|
+
# `:ftp_active_mode => true` is used to make ftp active mode. Ruby 1.9 uses
|
302
|
+
# passive mode by default. Note that the active mode is default in Ruby 1.8
|
303
|
+
# or prior.
|
304
|
+
#
|
305
|
+
# :redirect
|
306
|
+
# : Synopsis:
|
307
|
+
# :redirect=>bool
|
308
|
+
#
|
309
|
+
# `:redirect` is true by default. `:redirect => false` is used to disable
|
310
|
+
# all HTTP redirects.
|
311
|
+
#
|
312
|
+
# OpenURI::HTTPRedirect exception raised on redirection. Using `true` also
|
313
|
+
# means that redirections between http and ftp are permitted.
|
314
|
+
#
|
315
|
+
def open: (*untyped) -> IO
|
316
|
+
| [T] (*untyped) { (IO) -> T } -> T
|
317
|
+
|
318
|
+
# <!--
|
319
|
+
# rdoc-file=lib/open-uri.rb
|
320
|
+
# - read(options={})
|
321
|
+
# -->
|
322
|
+
# OpenURI::OpenRead#read([ options ]) reads a content referenced by self and
|
323
|
+
# returns the content as string. The string is extended with OpenURI::Meta. The
|
324
|
+
# argument `options` is same as OpenURI::OpenRead#open.
|
325
|
+
#
|
326
|
+
def read: (untyped options) -> String
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
%a{annotate:rdoc:skip}
|
331
|
+
module URI
|
332
|
+
%a{annotate:rdoc:skip}
|
333
|
+
class HTTP
|
334
|
+
include OpenURI::OpenRead
|
335
|
+
end
|
336
|
+
|
337
|
+
%a{annotate:rdoc:skip}
|
338
|
+
class FTP
|
339
|
+
include OpenURI::OpenRead
|
340
|
+
end
|
341
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.0.pre.
|
4
|
+
version: 3.3.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abbrev
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/rbs/prototype/rbi.rb
|
217
217
|
- lib/rbs/prototype/runtime.rb
|
218
218
|
- lib/rbs/prototype/runtime/helpers.rb
|
219
|
+
- lib/rbs/prototype/runtime/reflection.rb
|
219
220
|
- lib/rbs/prototype/runtime/value_object_generator.rb
|
220
221
|
- lib/rbs/repository.rb
|
221
222
|
- lib/rbs/resolver/constant_resolver.rb
|
@@ -397,9 +398,13 @@ files:
|
|
397
398
|
- stdlib/net-http/0/net-http.rbs
|
398
399
|
- stdlib/net-protocol/0/manifest.yaml
|
399
400
|
- stdlib/net-protocol/0/net-protocol.rbs
|
401
|
+
- stdlib/net-smtp/0/manifest.yaml
|
402
|
+
- stdlib/net-smtp/0/net-smtp.rbs
|
400
403
|
- stdlib/nkf/0/nkf.rbs
|
401
404
|
- stdlib/objspace/0/objspace.rbs
|
402
405
|
- stdlib/observable/0/observable.rbs
|
406
|
+
- stdlib/open-uri/0/manifest.yaml
|
407
|
+
- stdlib/open-uri/0/open-uri.rbs
|
403
408
|
- stdlib/openssl/0/manifest.yaml
|
404
409
|
- stdlib/openssl/0/openssl.rbs
|
405
410
|
- stdlib/optparse/0/optparse.rbs
|