rbs 1.5.0 → 1.6.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/.github/dependabot.yml +10 -0
- data/CHANGELOG.md +51 -0
- data/Gemfile +1 -0
- data/Steepfile +9 -1
- data/core/enumerator.rbs +1 -0
- data/core/io.rbs +3 -1
- data/docs/collection.md +116 -0
- data/lib/rbs/builtin_names.rb +1 -0
- data/lib/rbs/cli.rb +93 -2
- data/lib/rbs/collection/cleaner.rb +29 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +95 -0
- data/lib/rbs/collection/config.rb +85 -0
- data/lib/rbs/collection/installer.rb +27 -0
- data/lib/rbs/collection/sources/git.rb +147 -0
- data/lib/rbs/collection/sources/rubygems.rb +40 -0
- data/lib/rbs/collection/sources/stdlib.rb +38 -0
- data/lib/rbs/collection/sources.rb +22 -0
- data/lib/rbs/collection.rb +13 -0
- data/lib/rbs/environment_loader.rb +12 -0
- data/lib/rbs/errors.rb +2 -0
- data/lib/rbs/repository.rb +13 -7
- data/lib/rbs/validator.rb +4 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -0
- data/sig/builtin_names.rbs +1 -0
- data/sig/cli.rbs +5 -0
- data/sig/collection/cleaner.rbs +13 -0
- data/sig/collection/collections.rbs +112 -0
- data/sig/collection/config.rbs +69 -0
- data/sig/collection/installer.rbs +15 -0
- data/sig/collection.rbs +4 -0
- data/sig/environment_loader.rbs +3 -0
- data/sig/polyfill.rbs +12 -3
- data/sig/repository.rbs +4 -0
- data/stdlib/objspace/0/objspace.rbs +406 -0
- data/stdlib/openssl/0/openssl.rbs +1 -1
- data/stdlib/tempfile/0/tempfile.rbs +270 -0
- data/steep/Gemfile.lock +10 -10
- metadata +21 -3
@@ -0,0 +1,270 @@
|
|
1
|
+
# A utility class for managing temporary files. When you create a Tempfile
|
2
|
+
# object, it will create a temporary file with a unique filename. A Tempfile
|
3
|
+
# objects behaves just like a File object, and you can perform all the usual
|
4
|
+
# file operations on it: reading data, writing data, changing its permissions,
|
5
|
+
# etc. So although this class does not explicitly document all instance methods
|
6
|
+
# supported by File, you can in fact call any File instance method on a Tempfile
|
7
|
+
# object.
|
8
|
+
#
|
9
|
+
# ## Synopsis
|
10
|
+
#
|
11
|
+
# require 'tempfile'
|
12
|
+
#
|
13
|
+
# file = Tempfile.new('foo')
|
14
|
+
# file.path # => A unique filename in the OS's temp directory,
|
15
|
+
# # e.g.: "/tmp/foo.24722.0"
|
16
|
+
# # This filename contains 'foo' in its basename.
|
17
|
+
# file.write("hello world")
|
18
|
+
# file.rewind
|
19
|
+
# file.read # => "hello world"
|
20
|
+
# file.close
|
21
|
+
# file.unlink # deletes the temp file
|
22
|
+
#
|
23
|
+
# ## Good practices
|
24
|
+
#
|
25
|
+
# ### Explicit close
|
26
|
+
#
|
27
|
+
# When a Tempfile object is garbage collected, or when the Ruby interpreter
|
28
|
+
# exits, its associated temporary file is automatically deleted. This means
|
29
|
+
# that's it's unnecessary to explicitly delete a Tempfile after use, though it's
|
30
|
+
# good practice to do so: not explicitly deleting unused Tempfiles can
|
31
|
+
# potentially leave behind large amounts of tempfiles on the filesystem until
|
32
|
+
# they're garbage collected. The existence of these temp files can make it
|
33
|
+
# harder to determine a new Tempfile filename.
|
34
|
+
#
|
35
|
+
# Therefore, one should always call #unlink or close in an ensure block, like
|
36
|
+
# this:
|
37
|
+
#
|
38
|
+
# file = Tempfile.new('foo')
|
39
|
+
# begin
|
40
|
+
# # ...do something with file...
|
41
|
+
# ensure
|
42
|
+
# file.close
|
43
|
+
# file.unlink # deletes the temp file
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# Tempfile.create { ... } exists for this purpose and is more convenient to use.
|
47
|
+
# Note that Tempfile.create returns a File instance instead of a Tempfile, which
|
48
|
+
# also avoids the overhead and complications of delegation.
|
49
|
+
#
|
50
|
+
# Tempfile.open('foo') do |file|
|
51
|
+
# # ...do something with file...
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# ### Unlink after creation
|
55
|
+
#
|
56
|
+
# On POSIX systems, it's possible to unlink a file right after creating it, and
|
57
|
+
# before closing it. This removes the filesystem entry without closing the file
|
58
|
+
# handle, so it ensures that only the processes that already had the file handle
|
59
|
+
# open can access the file's contents. It's strongly recommended that you do
|
60
|
+
# this if you do not want any other processes to be able to read from or write
|
61
|
+
# to the Tempfile, and you do not need to know the Tempfile's filename either.
|
62
|
+
#
|
63
|
+
# For example, a practical use case for unlink-after-creation would be this: you
|
64
|
+
# need a large byte buffer that's too large to comfortably fit in RAM, e.g. when
|
65
|
+
# you're writing a web server and you want to buffer the client's file upload
|
66
|
+
# data.
|
67
|
+
#
|
68
|
+
# Please refer to #unlink for more information and a code example.
|
69
|
+
#
|
70
|
+
# ## Minor notes
|
71
|
+
#
|
72
|
+
# Tempfile's filename picking method is both thread-safe and inter-process-safe:
|
73
|
+
# it guarantees that no other threads or processes will pick the same filename.
|
74
|
+
#
|
75
|
+
# Tempfile itself however may not be entirely thread-safe. If you access the
|
76
|
+
# same Tempfile object from multiple threads then you should protect it with a
|
77
|
+
# mutex.
|
78
|
+
class Tempfile < File
|
79
|
+
# Creates a temporary file as a usual File object (not a Tempfile). It does not
|
80
|
+
# use finalizer and delegation, which makes it more efficient and reliable.
|
81
|
+
#
|
82
|
+
# If no block is given, this is similar to Tempfile.new except creating File
|
83
|
+
# instead of Tempfile. In that case, the created file is not removed
|
84
|
+
# automatically. You should use File.unlink to remove it.
|
85
|
+
#
|
86
|
+
# If a block is given, then a File object will be constructed, and the block is
|
87
|
+
# invoked with the object as the argument. The File object will be automatically
|
88
|
+
# closed and the temporary file is removed after the block terminates, releasing
|
89
|
+
# all resources that the block created. The call returns the value of the block.
|
90
|
+
#
|
91
|
+
# In any case, all arguments (`basename`, `tmpdir`, `mode`, and `**options`)
|
92
|
+
# will be treated the same as for Tempfile.new.
|
93
|
+
#
|
94
|
+
# Tempfile.create('foo', '/home/temp') do |f|
|
95
|
+
# # ... do something with f ...
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
def self.create: (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) -> File
|
99
|
+
| [A] (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) { (File) -> A } -> A
|
100
|
+
|
101
|
+
# Creates a new Tempfile.
|
102
|
+
#
|
103
|
+
# This method is not recommended and exists mostly for backward compatibility.
|
104
|
+
# Please use Tempfile.create instead, which avoids the cost of delegation, does
|
105
|
+
# not rely on a finalizer, and also unlinks the file when given a block.
|
106
|
+
#
|
107
|
+
# Tempfile.open is still appropriate if you need the Tempfile to be unlinked by
|
108
|
+
# a finalizer and you cannot explicitly know where in the program the Tempfile
|
109
|
+
# can be unlinked safely.
|
110
|
+
#
|
111
|
+
# If no block is given, this is a synonym for Tempfile.new.
|
112
|
+
#
|
113
|
+
# If a block is given, then a Tempfile object will be constructed, and the block
|
114
|
+
# is run with the Tempfile object as argument. The Tempfile object will be
|
115
|
+
# automatically closed after the block terminates. However, the file will
|
116
|
+
# **not** be unlinked and needs to be manually unlinked with Tempfile#close! or
|
117
|
+
# Tempfile#unlink. The finalizer will try to unlink but should not be relied
|
118
|
+
# upon as it can keep the file on the disk much longer than intended. For
|
119
|
+
# instance, on CRuby, finalizers can be delayed due to conservative stack
|
120
|
+
# scanning and references left in unused memory.
|
121
|
+
#
|
122
|
+
# The call returns the value of the block.
|
123
|
+
#
|
124
|
+
# In any case, all arguments (`*args`) will be passed to Tempfile.new.
|
125
|
+
#
|
126
|
+
# Tempfile.open('foo', '/home/temp') do |f|
|
127
|
+
# # ... do something with f ...
|
128
|
+
# end
|
129
|
+
#
|
130
|
+
# # Equivalent:
|
131
|
+
# f = Tempfile.open('foo', '/home/temp')
|
132
|
+
# begin
|
133
|
+
# # ... do something with f ...
|
134
|
+
# ensure
|
135
|
+
# f.close
|
136
|
+
# end
|
137
|
+
#
|
138
|
+
def self.open: (*untyped args, **untyped) -> Tempfile
|
139
|
+
| [A] (*untyped args, **untyped) { (Tempfile) -> A } -> A
|
140
|
+
|
141
|
+
public
|
142
|
+
|
143
|
+
# Closes the file. If `unlink_now` is true, then the file will be unlinked
|
144
|
+
# (deleted) after closing. Of course, you can choose to later call #unlink if
|
145
|
+
# you do not unlink it now.
|
146
|
+
#
|
147
|
+
# If you don't explicitly unlink the temporary file, the removal will be delayed
|
148
|
+
# until the object is finalized.
|
149
|
+
#
|
150
|
+
def close: (?boolish unlink_now) -> void
|
151
|
+
|
152
|
+
# Closes and unlinks (deletes) the file. Has the same effect as called
|
153
|
+
# `close(true)`.
|
154
|
+
#
|
155
|
+
def close!: () -> void
|
156
|
+
|
157
|
+
alias delete unlink
|
158
|
+
|
159
|
+
def inspect: () -> String
|
160
|
+
|
161
|
+
alias length size
|
162
|
+
|
163
|
+
# Opens or reopens the file with mode "r+".
|
164
|
+
#
|
165
|
+
def open: () -> File
|
166
|
+
|
167
|
+
# Returns the full path name of the temporary file. This will be nil if #unlink
|
168
|
+
# has been called.
|
169
|
+
#
|
170
|
+
def path: () -> String?
|
171
|
+
|
172
|
+
# Returns the size of the temporary file. As a side effect, the IO buffer is
|
173
|
+
# flushed before determining the size.
|
174
|
+
#
|
175
|
+
def size: () -> Integer
|
176
|
+
|
177
|
+
# Unlinks (deletes) the file from the filesystem. One should always unlink the
|
178
|
+
# file after using it, as is explained in the "Explicit close" good practice
|
179
|
+
# section in the Tempfile overview:
|
180
|
+
#
|
181
|
+
# file = Tempfile.new('foo')
|
182
|
+
# begin
|
183
|
+
# # ...do something with file...
|
184
|
+
# ensure
|
185
|
+
# file.close
|
186
|
+
# file.unlink # deletes the temp file
|
187
|
+
# end
|
188
|
+
#
|
189
|
+
# ### Unlink-before-close
|
190
|
+
#
|
191
|
+
# On POSIX systems it's possible to unlink a file before closing it. This
|
192
|
+
# practice is explained in detail in the Tempfile overview (section "Unlink
|
193
|
+
# after creation"); please refer there for more information.
|
194
|
+
#
|
195
|
+
# However, unlink-before-close may not be supported on non-POSIX operating
|
196
|
+
# systems. Microsoft Windows is the most notable case: unlinking a non-closed
|
197
|
+
# file will result in an error, which this method will silently ignore. If you
|
198
|
+
# want to practice unlink-before-close whenever possible, then you should write
|
199
|
+
# code like this:
|
200
|
+
#
|
201
|
+
# file = Tempfile.new('foo')
|
202
|
+
# file.unlink # On Windows this silently fails.
|
203
|
+
# begin
|
204
|
+
# # ... do something with file ...
|
205
|
+
# ensure
|
206
|
+
# file.close! # Closes the file handle. If the file wasn't unlinked
|
207
|
+
# # because #unlink failed, then this method will attempt
|
208
|
+
# # to do so again.
|
209
|
+
# end
|
210
|
+
#
|
211
|
+
def unlink: () -> void
|
212
|
+
|
213
|
+
class Remover
|
214
|
+
public
|
215
|
+
|
216
|
+
def call: (*untyped args) -> void
|
217
|
+
|
218
|
+
private
|
219
|
+
|
220
|
+
def initialize: (::Tempfile tmpfile) -> void
|
221
|
+
end
|
222
|
+
|
223
|
+
private
|
224
|
+
|
225
|
+
# Creates a temporary file with permissions 0600 (= only readable and writable
|
226
|
+
# by the owner) and opens it with mode "w+".
|
227
|
+
#
|
228
|
+
# It is recommended to use Tempfile.create { ... } instead when possible,
|
229
|
+
# because that method avoids the cost of delegation and does not rely on a
|
230
|
+
# finalizer to close and unlink the file, which is unreliable.
|
231
|
+
#
|
232
|
+
# The `basename` parameter is used to determine the name of the temporary file.
|
233
|
+
# You can either pass a String or an Array with 2 String elements. In the former
|
234
|
+
# form, the temporary file's base name will begin with the given string. In the
|
235
|
+
# latter form, the temporary file's base name will begin with the array's first
|
236
|
+
# element, and end with the second element. For example:
|
237
|
+
#
|
238
|
+
# file = Tempfile.new('hello')
|
239
|
+
# file.path # => something like: "/tmp/hello2843-8392-92849382--0"
|
240
|
+
#
|
241
|
+
# # Use the Array form to enforce an extension in the filename:
|
242
|
+
# file = Tempfile.new(['hello', '.jpg'])
|
243
|
+
# file.path # => something like: "/tmp/hello2843-8392-92849382--0.jpg"
|
244
|
+
#
|
245
|
+
# The temporary file will be placed in the directory as specified by the
|
246
|
+
# `tmpdir` parameter. By default, this is `Dir.tmpdir`.
|
247
|
+
#
|
248
|
+
# file = Tempfile.new('hello', '/home/aisaka')
|
249
|
+
# file.path # => something like: "/home/aisaka/hello2843-8392-92849382--0"
|
250
|
+
#
|
251
|
+
# You can also pass an options hash. Under the hood, Tempfile creates the
|
252
|
+
# temporary file using `File.open`. These options will be passed to `File.open`.
|
253
|
+
# This is mostly useful for specifying encoding options, e.g.:
|
254
|
+
#
|
255
|
+
# Tempfile.new('hello', '/home/aisaka', encoding: 'ascii-8bit')
|
256
|
+
#
|
257
|
+
# # You can also omit the 'tmpdir' parameter:
|
258
|
+
# Tempfile.new('hello', encoding: 'ascii-8bit')
|
259
|
+
#
|
260
|
+
# Note: `mode` keyword argument, as accepted by Tempfile, can only be numeric,
|
261
|
+
# combination of the modes defined in File::Constants.
|
262
|
+
#
|
263
|
+
# ### Exceptions
|
264
|
+
#
|
265
|
+
# If Tempfile.new cannot find a unique filename within a limited number of
|
266
|
+
# tries, then it will raise an exception.
|
267
|
+
#
|
268
|
+
def self.new: (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) -> instance
|
269
|
+
| [A] (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) { (instance) -> A } -> A
|
270
|
+
end
|
data/steep/Gemfile.lock
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (6.1.
|
4
|
+
activesupport (6.1.4.1)
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
6
|
i18n (>= 1.6, < 2)
|
7
7
|
minitest (>= 5.1)
|
8
8
|
tzinfo (~> 2.0)
|
9
9
|
zeitwerk (~> 2.3)
|
10
10
|
ast (2.4.2)
|
11
|
-
concurrent-ruby (1.1.
|
12
|
-
ffi (1.15.
|
11
|
+
concurrent-ruby (1.1.9)
|
12
|
+
ffi (1.15.3)
|
13
13
|
i18n (1.8.10)
|
14
14
|
concurrent-ruby (~> 1.0)
|
15
|
-
language_server-protocol (3.16.0.
|
16
|
-
listen (3.
|
15
|
+
language_server-protocol (3.16.0.3)
|
16
|
+
listen (3.7.0)
|
17
17
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
18
18
|
rb-inotify (~> 0.9, >= 0.9.10)
|
19
19
|
minitest (5.14.4)
|
20
20
|
parallel (1.20.1)
|
21
|
-
parser (3.0.
|
21
|
+
parser (3.0.2.0)
|
22
22
|
ast (~> 2.4.1)
|
23
23
|
rainbow (3.0.0)
|
24
24
|
rb-fsevent (0.11.0)
|
25
25
|
rb-inotify (0.10.1)
|
26
26
|
ffi (~> 1.0)
|
27
|
-
rbs (1.
|
28
|
-
steep (0.
|
27
|
+
rbs (1.5.1)
|
28
|
+
steep (0.46.0)
|
29
29
|
activesupport (>= 5.1)
|
30
30
|
language_server-protocol (>= 3.15, < 4.0)
|
31
31
|
listen (~> 3.0)
|
32
32
|
parallel (>= 1.0.0)
|
33
|
-
parser (>=
|
33
|
+
parser (>= 3.0)
|
34
34
|
rainbow (>= 2.2.2, < 4.0)
|
35
35
|
rbs (>= 1.2.0)
|
36
36
|
terminal-table (>= 2, < 4)
|
@@ -48,4 +48,4 @@ DEPENDENCIES
|
|
48
48
|
steep
|
49
49
|
|
50
50
|
BUNDLED WITH
|
51
|
-
2.2.
|
51
|
+
2.2.22
|
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: 1.
|
4
|
+
version: 1.6.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: 2021-
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: RBS is the language for type signatures for Ruby and standard library
|
14
14
|
definitions.
|
@@ -19,6 +19,7 @@ executables:
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- ".github/dependabot.yml"
|
22
23
|
- ".github/workflows/ruby.yml"
|
23
24
|
- ".gitignore"
|
24
25
|
- ".rubocop.yml"
|
@@ -89,6 +90,7 @@ files:
|
|
89
90
|
- core/unbound_method.rbs
|
90
91
|
- core/warning.rbs
|
91
92
|
- docs/CONTRIBUTING.md
|
93
|
+
- docs/collection.md
|
92
94
|
- docs/rbs_by_example.md
|
93
95
|
- docs/repo.md
|
94
96
|
- docs/sigs.md
|
@@ -106,6 +108,15 @@ files:
|
|
106
108
|
- lib/rbs/builtin_names.rb
|
107
109
|
- lib/rbs/char_scanner.rb
|
108
110
|
- lib/rbs/cli.rb
|
111
|
+
- lib/rbs/collection.rb
|
112
|
+
- lib/rbs/collection/cleaner.rb
|
113
|
+
- lib/rbs/collection/config.rb
|
114
|
+
- lib/rbs/collection/config/lockfile_generator.rb
|
115
|
+
- lib/rbs/collection/installer.rb
|
116
|
+
- lib/rbs/collection/sources.rb
|
117
|
+
- lib/rbs/collection/sources/git.rb
|
118
|
+
- lib/rbs/collection/sources/rubygems.rb
|
119
|
+
- lib/rbs/collection/sources/stdlib.rb
|
109
120
|
- lib/rbs/constant.rb
|
110
121
|
- lib/rbs/constant_table.rb
|
111
122
|
- lib/rbs/definition.rb
|
@@ -163,6 +174,11 @@ files:
|
|
163
174
|
- sig/builtin_names.rbs
|
164
175
|
- sig/char_scanner.rbs
|
165
176
|
- sig/cli.rbs
|
177
|
+
- sig/collection.rbs
|
178
|
+
- sig/collection/cleaner.rbs
|
179
|
+
- sig/collection/collections.rbs
|
180
|
+
- sig/collection/config.rbs
|
181
|
+
- sig/collection/installer.rbs
|
166
182
|
- sig/comment.rbs
|
167
183
|
- sig/constant.rbs
|
168
184
|
- sig/constant_table.rbs
|
@@ -221,6 +237,7 @@ files:
|
|
221
237
|
- stdlib/monitor/0/monitor.rbs
|
222
238
|
- stdlib/mutex_m/0/mutex_m.rbs
|
223
239
|
- stdlib/net-http/0/net-http.rbs
|
240
|
+
- stdlib/objspace/0/objspace.rbs
|
224
241
|
- stdlib/openssl/0/openssl.rbs
|
225
242
|
- stdlib/optparse/0/optparse.rbs
|
226
243
|
- stdlib/pathname/0/pathname.rbs
|
@@ -258,6 +275,7 @@ files:
|
|
258
275
|
- stdlib/socket/0/unix_server.rbs
|
259
276
|
- stdlib/socket/0/unix_socket.rbs
|
260
277
|
- stdlib/strscan/0/string_scanner.rbs
|
278
|
+
- stdlib/tempfile/0/tempfile.rbs
|
261
279
|
- stdlib/time/0/time.rbs
|
262
280
|
- stdlib/timeout/0/timeout.rbs
|
263
281
|
- stdlib/tmpdir/0/tmpdir.rbs
|
@@ -301,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
301
319
|
- !ruby/object:Gem::Version
|
302
320
|
version: '0'
|
303
321
|
requirements: []
|
304
|
-
rubygems_version: 3.2.
|
322
|
+
rubygems_version: 3.2.22
|
305
323
|
signing_key:
|
306
324
|
specification_version: 4
|
307
325
|
summary: Type signature for Ruby.
|