steep 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +27 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +48 -90
- data/Rakefile +10 -6
- data/Steepfile +1 -0
- data/bin/setup +1 -0
- data/bin/smoke_runner.rb +9 -14
- data/exe/rbs +3 -0
- data/exe/ruby-signature +3 -0
- data/exe/steep +1 -0
- data/lib/steep.rb +32 -26
- data/lib/steep/annotation_parser.rb +167 -0
- data/lib/steep/ast/annotation/collection.rb +7 -7
- data/lib/steep/ast/types.rb +60 -0
- data/lib/steep/ast/types/any.rb +1 -1
- data/lib/steep/ast/types/factory.rb +535 -0
- data/lib/steep/ast/types/name.rb +3 -3
- data/lib/steep/ast/types/var.rb +1 -1
- data/lib/steep/cli.rb +56 -240
- data/lib/steep/drivers/annotations.rb +36 -19
- data/lib/steep/drivers/check.rb +55 -91
- data/lib/steep/drivers/init.rb +54 -0
- data/lib/steep/drivers/langserver.rb +241 -150
- data/lib/steep/drivers/print_project.rb +56 -0
- data/lib/steep/drivers/signature_error_printer.rb +25 -0
- data/lib/steep/drivers/trace_printer.rb +25 -0
- data/lib/steep/drivers/utils/driver_helper.rb +26 -0
- data/lib/steep/drivers/validate.rb +18 -38
- data/lib/steep/drivers/vendor.rb +46 -0
- data/lib/steep/drivers/watch.rb +78 -140
- data/lib/steep/errors.rb +22 -13
- data/lib/steep/interface/interface.rb +91 -0
- data/lib/steep/interface/method.rb +0 -4
- data/lib/steep/interface/method_type.rb +362 -2
- data/lib/steep/interface/substitution.rb +22 -0
- data/lib/steep/project.rb +25 -233
- data/lib/steep/project/dsl.rb +132 -0
- data/lib/steep/project/file.rb +93 -76
- data/lib/steep/project/file_loader.rb +63 -0
- data/lib/steep/project/options.rb +7 -0
- data/lib/steep/project/target.rb +190 -0
- data/lib/steep/signature/errors.rb +25 -77
- data/lib/steep/signature/validator.rb +122 -0
- data/lib/steep/source.rb +12 -7
- data/lib/steep/subtyping/check.rb +357 -633
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/subtyping/trace.rb +23 -0
- data/lib/steep/type_construction.rb +509 -455
- data/lib/steep/type_inference/constant_env.rb +16 -24
- data/lib/steep/type_inference/type_env.rb +26 -18
- data/lib/steep/version.rb +1 -1
- data/sample/Steepfile +6 -0
- data/sample/lib/conference.rb +12 -0
- data/sample/sig/conference.rbs +6 -0
- data/smoke/alias/Steepfile +4 -0
- data/smoke/alias/a.rb +2 -2
- data/smoke/alias/{a.rbi → a.rbs} +1 -1
- data/smoke/and/Steepfile +4 -0
- data/smoke/array/Steepfile +4 -0
- data/smoke/array/a.rb +2 -2
- data/smoke/array/b.rb +4 -4
- data/smoke/array/c.rb +2 -2
- data/smoke/block/Steepfile +5 -0
- data/smoke/block/{a.rbi → a.rbs} +1 -1
- data/smoke/block/{c.rbi → c.rbs} +0 -0
- data/smoke/block/d.rb +6 -6
- data/smoke/case/Steepfile +4 -0
- data/smoke/case/a.rb +4 -3
- data/smoke/class/Steepfile +4 -0
- data/smoke/class/a.rb +1 -4
- data/smoke/class/a.rbs +24 -0
- data/smoke/class/h.rb +6 -2
- data/smoke/class/{h.rbi → h.rbs} +1 -2
- data/smoke/class/i.rb +1 -2
- data/smoke/class/i.rbs +9 -0
- data/smoke/const/Steepfile +4 -0
- data/smoke/dstr/Steepfile +4 -0
- data/smoke/ensure/Steepfile +4 -0
- data/smoke/ensure/a.rb +1 -1
- data/smoke/enumerator/Steepfile +4 -0
- data/smoke/enumerator/a.rb +7 -7
- data/smoke/enumerator/b.rb +6 -6
- data/smoke/extension/Steepfile +4 -0
- data/smoke/extension/{a.rbi → a.rbs} +2 -2
- data/smoke/extension/{e.rbi → e.rbs} +2 -2
- data/smoke/hash/Steepfile +4 -0
- data/smoke/hash/{a.rbi → a.rbs} +0 -0
- data/smoke/hash/b.rb +2 -2
- data/smoke/hash/c.rb +1 -1
- data/smoke/hash/e.rbs +3 -0
- data/smoke/hash/f.rb +1 -1
- data/smoke/hello/Steepfile +4 -0
- data/smoke/hello/hello.rbs +7 -0
- data/smoke/if/Steepfile +4 -0
- data/smoke/implements/Steepfile +4 -0
- data/smoke/implements/a.rbs +6 -0
- data/smoke/initialize/Steepfile +4 -0
- data/smoke/initialize/a.rbs +3 -0
- data/smoke/integer/Steepfile +4 -0
- data/smoke/integer/a.rb +5 -3
- data/smoke/interface/Steepfile +4 -0
- data/smoke/interface/{a.rbi → a.rbs} +0 -0
- data/smoke/kwbegin/Steepfile +4 -0
- data/smoke/lambda/Steepfile +4 -0
- data/smoke/lambda/a.rb +9 -2
- data/smoke/literal/Steepfile +4 -0
- data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
- data/smoke/map/Steepfile +4 -0
- data/smoke/map/a.rb +1 -1
- data/smoke/method/Steepfile +4 -0
- data/smoke/method/{a.rbi → a.rbs} +0 -0
- data/smoke/method/b.rb +1 -4
- data/smoke/method/d.rb +1 -0
- data/smoke/method/d.rbs +3 -0
- data/smoke/module/Steepfile +4 -0
- data/smoke/module/a.rb +1 -1
- data/smoke/module/a.rbs +16 -0
- data/smoke/module/c.rb +1 -1
- data/smoke/regexp/Steepfile +4 -0
- data/smoke/regexp/a.rb +2 -2
- data/smoke/regexp/b.rb +16 -16
- data/smoke/regression/Steepfile +5 -0
- data/smoke/regression/array.rb +2 -2
- data/smoke/regression/hash.rb +2 -2
- data/smoke/regression/poly_new.rb +2 -0
- data/smoke/regression/poly_new.rbs +4 -0
- data/smoke/regression/set_divide.rb +2 -2
- data/smoke/rescue/Steepfile +4 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +4 -0
- data/smoke/self/a.rbs +4 -0
- data/smoke/skip/Steepfile +4 -0
- data/smoke/stdout/Steepfile +4 -0
- data/smoke/stdout/{a.rbi → a.rbs} +1 -1
- data/smoke/super/Steepfile +4 -0
- data/smoke/super/a.rbs +10 -0
- data/smoke/type_case/Steepfile +4 -0
- data/smoke/type_case/a.rb +1 -1
- data/smoke/yield/Steepfile +4 -0
- data/smoke/yield/a.rb +2 -2
- data/steep.gemspec +14 -7
- data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
- data/vendor/ruby-signature/.gitignore +12 -0
- data/vendor/ruby-signature/.rubocop.yml +15 -0
- data/vendor/ruby-signature/BSDL +22 -0
- data/vendor/ruby-signature/COPYING +56 -0
- data/vendor/ruby-signature/Gemfile +6 -0
- data/vendor/ruby-signature/README.md +93 -0
- data/vendor/ruby-signature/Rakefile +66 -0
- data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
- data/vendor/ruby-signature/bin/console +14 -0
- data/vendor/ruby-signature/bin/query-rdoc +103 -0
- data/vendor/ruby-signature/bin/setup +10 -0
- data/vendor/ruby-signature/bin/sort +88 -0
- data/vendor/ruby-signature/bin/test_runner.rb +17 -0
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
- data/vendor/ruby-signature/docs/sigs.md +148 -0
- data/vendor/ruby-signature/docs/stdlib.md +152 -0
- data/vendor/ruby-signature/docs/syntax.md +528 -0
- data/vendor/ruby-signature/exe/rbs +3 -0
- data/vendor/ruby-signature/exe/ruby-signature +7 -0
- data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
- data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
- data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
- data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
- metadata +244 -54
- data/.travis.yml +0 -7
- data/lib/steep/ast/signature/alias.rb +0 -19
- data/lib/steep/ast/signature/class.rb +0 -33
- data/lib/steep/ast/signature/const.rb +0 -17
- data/lib/steep/ast/signature/env.rb +0 -138
- data/lib/steep/ast/signature/extension.rb +0 -21
- data/lib/steep/ast/signature/gvar.rb +0 -17
- data/lib/steep/ast/signature/interface.rb +0 -31
- data/lib/steep/ast/signature/members.rb +0 -115
- data/lib/steep/ast/signature/module.rb +0 -21
- data/lib/steep/drivers/print_interface.rb +0 -94
- data/lib/steep/drivers/scaffold.rb +0 -321
- data/lib/steep/drivers/utils/each_signature.rb +0 -31
- data/lib/steep/interface/abstract.rb +0 -68
- data/lib/steep/interface/builder.rb +0 -637
- data/lib/steep/interface/instantiated.rb +0 -163
- data/lib/steep/interface/ivar_chain.rb +0 -26
- data/lib/steep/parser.y +0 -1278
- data/lib/steep/project/listener.rb +0 -53
- data/smoke/class/a.rbi +0 -24
- data/smoke/class/d.rb +0 -9
- data/smoke/class/e.rb +0 -12
- data/smoke/class/i.rbi +0 -9
- data/smoke/hash/e.rbi +0 -3
- data/smoke/hello/hello.rbi +0 -7
- data/smoke/implements/a.rbi +0 -6
- data/smoke/initialize/a.rbi +0 -3
- data/smoke/module/a.rbi +0 -16
- data/smoke/self/a.rbi +0 -4
- data/smoke/super/a.rbi +0 -10
- data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,426 @@
|
|
1
|
+
# A `Proc` object is an encapsulation of a block of code, which can be
|
2
|
+
# stored in a local variable, passed to a method or another
|
3
|
+
# [Proc](Proc), and can be called.
|
4
|
+
# [Proc](Proc) is an essential concept in Ruby and a
|
5
|
+
# core of its functional programming features.
|
6
|
+
#
|
7
|
+
# ```ruby
|
8
|
+
# square = Proc.new {|x| x**2 }
|
9
|
+
#
|
10
|
+
# square.call(3) #=> 9
|
11
|
+
# # shorthands:
|
12
|
+
# square.(3) #=> 9
|
13
|
+
# square[3] #=> 9
|
14
|
+
# ```
|
15
|
+
#
|
16
|
+
# [Proc](Proc) objects are *closures* , meaning they
|
17
|
+
# remember and can use the entire context in which they were created.
|
18
|
+
#
|
19
|
+
# ```ruby
|
20
|
+
# def gen_times(factor)
|
21
|
+
# Proc.new {|n| n*factor } # remembers the value of factor at the moment of creation
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# times3 = gen_times(3)
|
25
|
+
# times5 = gen_times(5)
|
26
|
+
#
|
27
|
+
# times3.call(12) #=> 36
|
28
|
+
# times5.call(5) #=> 25
|
29
|
+
# times3.call(times5.call(4)) #=> 60
|
30
|
+
# ```
|
31
|
+
#
|
32
|
+
#
|
33
|
+
# There are several methods to create a [Proc](Proc)
|
34
|
+
#
|
35
|
+
# - Use the [Proc](Proc) class constructor:
|
36
|
+
#
|
37
|
+
# ```ruby
|
38
|
+
# proc1 = Proc.new {|x| x**2 }
|
39
|
+
# ```
|
40
|
+
#
|
41
|
+
# - Use the
|
42
|
+
# [Kernel\#proc](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-proc)
|
43
|
+
# method as a shorthand of
|
44
|
+
# [::new](Proc#method-c-new):
|
45
|
+
#
|
46
|
+
# ```ruby
|
47
|
+
# proc2 = proc {|x| x**2 }
|
48
|
+
# ```
|
49
|
+
#
|
50
|
+
# - Receiving a block of code into proc argument (note the `&` ):
|
51
|
+
#
|
52
|
+
# ```ruby
|
53
|
+
# def make_proc(&block)
|
54
|
+
# block
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# proc3 = make_proc {|x| x**2 }
|
58
|
+
# ```
|
59
|
+
#
|
60
|
+
# - Construct a proc with lambda semantics using the
|
61
|
+
# [Kernel\#lambda](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-lambda)
|
62
|
+
# method (see below for explanations about lambdas):
|
63
|
+
#
|
64
|
+
# ```ruby
|
65
|
+
# lambda1 = lambda {|x| x**2 }
|
66
|
+
# ```
|
67
|
+
#
|
68
|
+
# - Use the Lambda literal syntax (also constructs a proc with lambda
|
69
|
+
# semantics):
|
70
|
+
#
|
71
|
+
# ```ruby
|
72
|
+
# lambda2 = ->(x) { x**2 }
|
73
|
+
# ```
|
74
|
+
#
|
75
|
+
#
|
76
|
+
# Procs are coming in two flavors: lambda and non-lambda (regular procs).
|
77
|
+
# Differences are:
|
78
|
+
#
|
79
|
+
# - In lambdas, `return` means exit from this lambda;
|
80
|
+
#
|
81
|
+
# - In regular procs, `return` means exit from embracing method (and
|
82
|
+
# will throw `LocalJumpError` if invoked outside the method);
|
83
|
+
#
|
84
|
+
# - In lambdas, arguments are treated in the same way as in methods:
|
85
|
+
# strict, with `ArgumentError` for mismatching argument number, and no
|
86
|
+
# additional argument processing;
|
87
|
+
#
|
88
|
+
# - Regular procs accept arguments more generously: missing arguments
|
89
|
+
# are filled with `nil`, single
|
90
|
+
# [Array](https://ruby-doc.org/core-2.6.3/Array.html) arguments are
|
91
|
+
# deconstructed if the proc has multiple arguments, and there is no
|
92
|
+
# error raised on extra arguments.
|
93
|
+
#
|
94
|
+
# Examples:
|
95
|
+
#
|
96
|
+
# ```ruby
|
97
|
+
# p = proc {|x, y| "x=#{x}, y=#{y}" }
|
98
|
+
# p.call(1, 2) #=> "x=1, y=2"
|
99
|
+
# p.call([1, 2]) #=> "x=1, y=2", array deconstructed
|
100
|
+
# p.call(1, 2, 8) #=> "x=1, y=2", extra argument discarded
|
101
|
+
# p.call(1) #=> "x=1, y=", nil substituted instead of error
|
102
|
+
#
|
103
|
+
# l = lambda {|x, y| "x=#{x}, y=#{y}" }
|
104
|
+
# l.call(1, 2) #=> "x=1, y=2"
|
105
|
+
# l.call([1, 2]) # ArgumentError: wrong number of arguments (given 1, expected 2)
|
106
|
+
# l.call(1, 2, 8) # ArgumentError: wrong number of arguments (given 3, expected 2)
|
107
|
+
# l.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
|
108
|
+
#
|
109
|
+
# def test_return
|
110
|
+
# -> { return 3 }.call # just returns from lambda into method body
|
111
|
+
# proc { return 4 }.call # returns from method
|
112
|
+
# return 5
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# test_return # => 4, return from proc
|
116
|
+
# ```
|
117
|
+
#
|
118
|
+
# Lambdas are useful as self-sufficient functions, in particular useful as
|
119
|
+
# arguments to higher-order functions, behaving exactly like Ruby methods.
|
120
|
+
#
|
121
|
+
# Procs are useful for implementing iterators:
|
122
|
+
#
|
123
|
+
# ```ruby
|
124
|
+
# def test
|
125
|
+
# [[1, 2], [3, 4], [5, 6]].map {|a, b| return a if a + b > 10 }
|
126
|
+
# # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
127
|
+
# end
|
128
|
+
# ```
|
129
|
+
#
|
130
|
+
# Inside `map`, the block of code is treated as a regular (non-lambda)
|
131
|
+
# proc, which means that the internal arrays will be deconstructed to
|
132
|
+
# pairs of arguments, and `return` will exit from the method `test` . That
|
133
|
+
# would not be possible with a stricter lambda.
|
134
|
+
#
|
135
|
+
# You can tell a lambda from a regular proc by using the
|
136
|
+
# [lambda?](Proc#method-i-lambda-3F) instance method.
|
137
|
+
#
|
138
|
+
# Lambda semantics is typically preserved during the proc lifetime,
|
139
|
+
# including `&` -deconstruction to a block of code:
|
140
|
+
#
|
141
|
+
# ```ruby
|
142
|
+
# p = proc {|x, y| x }
|
143
|
+
# l = lambda {|x, y| x }
|
144
|
+
# [[1, 2], [3, 4]].map(&p) #=> [1, 2]
|
145
|
+
# [[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2)
|
146
|
+
# ```
|
147
|
+
#
|
148
|
+
# The only exception is dynamic method definition: even if defined by
|
149
|
+
# passing a non-lambda proc, methods still have normal semantics of
|
150
|
+
# argument checking.
|
151
|
+
#
|
152
|
+
# ```ruby
|
153
|
+
# class C
|
154
|
+
# define_method(:e, &proc {})
|
155
|
+
# end
|
156
|
+
# C.new.e(1,2) #=> ArgumentError
|
157
|
+
# C.new.method(:e).to_proc.lambda? #=> true
|
158
|
+
# ```
|
159
|
+
#
|
160
|
+
# This exception ensures that methods never have unusual argument passing
|
161
|
+
# conventions, and makes it easy to have wrappers defining methods that
|
162
|
+
# behave as usual.
|
163
|
+
#
|
164
|
+
# ```ruby
|
165
|
+
# class C
|
166
|
+
# def self.def2(name, &body)
|
167
|
+
# define_method(name, &body)
|
168
|
+
# end
|
169
|
+
#
|
170
|
+
# def2(:f) {}
|
171
|
+
# end
|
172
|
+
# C.new.f(1,2) #=> ArgumentError
|
173
|
+
# ```
|
174
|
+
#
|
175
|
+
# The wrapper *def2* receives `body` as a non-lambda proc, yet defines a
|
176
|
+
# method which has normal semantics.
|
177
|
+
#
|
178
|
+
#
|
179
|
+
# Any object that implements the `to_proc` method can be converted into a
|
180
|
+
# proc by the `&` operator, and therefore con be consumed by iterators.
|
181
|
+
#
|
182
|
+
# ```ruby
|
183
|
+
# class Greater
|
184
|
+
# def initialize(greating)
|
185
|
+
# @greating = greating
|
186
|
+
# end
|
187
|
+
#
|
188
|
+
# def to_proc
|
189
|
+
# proc {|name| "#{@greating}, #{name}!" }
|
190
|
+
# end
|
191
|
+
# end
|
192
|
+
#
|
193
|
+
# hi = Greater.new("Hi")
|
194
|
+
# hey = Greater.new("Hey")
|
195
|
+
# ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"]
|
196
|
+
# ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"]
|
197
|
+
# ```
|
198
|
+
#
|
199
|
+
# Of the Ruby core classes, this method is implemented by
|
200
|
+
# [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html),
|
201
|
+
# [Method](https://ruby-doc.org/core-2.6.3/Method.html), and
|
202
|
+
# [Hash](https://ruby-doc.org/core-2.6.3/Hash.html).
|
203
|
+
#
|
204
|
+
# :to_s.to_proc.call(1) #=> "1"
|
205
|
+
# [1, 2].map(&:to_s) #=> ["1", "2"]
|
206
|
+
#
|
207
|
+
# method(:puts).to_proc.call(1) # prints 1
|
208
|
+
# [1, 2].each(&method(:puts)) # prints 1, 2
|
209
|
+
#
|
210
|
+
# {test: 1}.to_proc.call(:test) #=> 1
|
211
|
+
# %i[test many keys].map(&{test: 1}) #=> [1, nil, nil]
|
212
|
+
class Proc < Object
|
213
|
+
# Returns the number of mandatory arguments. If the block is declared to
|
214
|
+
# take no arguments, returns 0. If the block is known to take exactly n
|
215
|
+
# arguments, returns n. If the block has optional arguments, returns -n-1,
|
216
|
+
# where n is the number of mandatory arguments, with the exception for
|
217
|
+
# blocks that are not lambdas and have only a finite number of optional
|
218
|
+
# arguments; in this latter case, returns n. Keyword arguments will be
|
219
|
+
# considered as a single additional argument, that argument being
|
220
|
+
# mandatory if any keyword argument is mandatory. A `proc` with no
|
221
|
+
# argument declarations is the same as a block declaring `||` as its
|
222
|
+
# arguments.
|
223
|
+
#
|
224
|
+
# proc {}.arity #=> 0
|
225
|
+
# proc { || }.arity #=> 0
|
226
|
+
# proc { |a| }.arity #=> 1
|
227
|
+
# proc { |a, b| }.arity #=> 2
|
228
|
+
# proc { |a, b, c| }.arity #=> 3
|
229
|
+
# proc { |*a| }.arity #=> -1
|
230
|
+
# proc { |a, *b| }.arity #=> -2
|
231
|
+
# proc { |a, *b, c| }.arity #=> -3
|
232
|
+
# proc { |x:, y:, z:0| }.arity #=> 1
|
233
|
+
# proc { |*a, x:, y:0| }.arity #=> -2
|
234
|
+
#
|
235
|
+
# proc { |a=0| }.arity #=> 0
|
236
|
+
# lambda { |a=0| }.arity #=> -1
|
237
|
+
# proc { |a=0, b| }.arity #=> 1
|
238
|
+
# lambda { |a=0, b| }.arity #=> -2
|
239
|
+
# proc { |a=0, b=0| }.arity #=> 0
|
240
|
+
# lambda { |a=0, b=0| }.arity #=> -1
|
241
|
+
# proc { |a, b=0| }.arity #=> 1
|
242
|
+
# lambda { |a, b=0| }.arity #=> -2
|
243
|
+
# proc { |(a, b), c=0| }.arity #=> 1
|
244
|
+
# lambda { |(a, b), c=0| }.arity #=> -2
|
245
|
+
# proc { |a, x:0, y:0| }.arity #=> 1
|
246
|
+
# lambda { |a, x:0, y:0| }.arity #=> -2
|
247
|
+
def arity: () -> Integer
|
248
|
+
|
249
|
+
# Returns the binding associated with *prc* .
|
250
|
+
#
|
251
|
+
# ```ruby
|
252
|
+
# def fred(param)
|
253
|
+
# proc {}
|
254
|
+
# end
|
255
|
+
#
|
256
|
+
# b = fred(99)
|
257
|
+
# eval("param", b.binding) #=> 99
|
258
|
+
# ```
|
259
|
+
def binding: () -> Binding
|
260
|
+
|
261
|
+
def call: (*untyped arg0) -> untyped
|
262
|
+
|
263
|
+
def []: (*untyped arg0) -> untyped
|
264
|
+
|
265
|
+
def curry: (?Integer arity) -> Proc
|
266
|
+
|
267
|
+
# Returns a hash value corresponding to proc body.
|
268
|
+
#
|
269
|
+
# See also Object\#hash.
|
270
|
+
def hash: () -> Integer
|
271
|
+
|
272
|
+
# Returns `true` for a [Proc](Proc.downloaded.ruby_doc) object for which
|
273
|
+
# argument handling is rigid. Such procs are typically generated by
|
274
|
+
# `lambda` .
|
275
|
+
#
|
276
|
+
# A [Proc](Proc.downloaded.ruby_doc) object generated by `proc` ignores
|
277
|
+
# extra arguments.
|
278
|
+
#
|
279
|
+
# ```ruby
|
280
|
+
# proc {|a,b| [a,b] }.call(1,2,3) #=> [1,2]
|
281
|
+
# ```
|
282
|
+
#
|
283
|
+
# It provides `nil` for missing arguments.
|
284
|
+
#
|
285
|
+
# ```ruby
|
286
|
+
# proc {|a,b| [a,b] }.call(1) #=> [1,nil]
|
287
|
+
# ```
|
288
|
+
#
|
289
|
+
# It expands a single array argument.
|
290
|
+
#
|
291
|
+
# ```ruby
|
292
|
+
# proc {|a,b| [a,b] }.call([1,2]) #=> [1,2]
|
293
|
+
# ```
|
294
|
+
#
|
295
|
+
# A [Proc](Proc.downloaded.ruby_doc) object generated by `lambda` doesn’t
|
296
|
+
# have such tricks.
|
297
|
+
#
|
298
|
+
# ```ruby
|
299
|
+
# lambda {|a,b| [a,b] }.call(1,2,3) #=> ArgumentError
|
300
|
+
# lambda {|a,b| [a,b] }.call(1) #=> ArgumentError
|
301
|
+
# lambda {|a,b| [a,b] }.call([1,2]) #=> ArgumentError
|
302
|
+
# ```
|
303
|
+
#
|
304
|
+
# [\#lambda?](Proc.downloaded.ruby_doc#method-i-lambda-3F) is a predicate
|
305
|
+
# for the tricks. It returns `true` if no tricks apply.
|
306
|
+
#
|
307
|
+
# ```ruby
|
308
|
+
# lambda {}.lambda? #=> true
|
309
|
+
# proc {}.lambda? #=> false
|
310
|
+
# ```
|
311
|
+
#
|
312
|
+
# [::new](Proc.downloaded.ruby_doc#method-c-new) is the same as `proc` .
|
313
|
+
#
|
314
|
+
# ```ruby
|
315
|
+
# Proc.new {}.lambda? #=> false
|
316
|
+
# ```
|
317
|
+
#
|
318
|
+
# `lambda`, `proc` and [::new](Proc.downloaded.ruby_doc#method-c-new)
|
319
|
+
# preserve the tricks of a [Proc](Proc.downloaded.ruby_doc) object given
|
320
|
+
# by `&` argument.
|
321
|
+
#
|
322
|
+
# ```ruby
|
323
|
+
# lambda(&lambda {}).lambda? #=> true
|
324
|
+
# proc(&lambda {}).lambda? #=> true
|
325
|
+
# Proc.new(&lambda {}).lambda? #=> true
|
326
|
+
#
|
327
|
+
# lambda(&proc {}).lambda? #=> false
|
328
|
+
# proc(&proc {}).lambda? #=> false
|
329
|
+
# Proc.new(&proc {}).lambda? #=> false
|
330
|
+
# ```
|
331
|
+
#
|
332
|
+
# A [Proc](Proc.downloaded.ruby_doc) object generated by `&` argument has
|
333
|
+
# the tricks
|
334
|
+
#
|
335
|
+
# ```ruby
|
336
|
+
# def n(&b) b.lambda? end
|
337
|
+
# n {} #=> false
|
338
|
+
# ```
|
339
|
+
#
|
340
|
+
# The `&` argument preserves the tricks if a
|
341
|
+
# [Proc](Proc.downloaded.ruby_doc) object is given by `&` argument.
|
342
|
+
#
|
343
|
+
# ```ruby
|
344
|
+
# n(&lambda {}) #=> true
|
345
|
+
# n(&proc {}) #=> false
|
346
|
+
# n(&Proc.new {}) #=> false
|
347
|
+
# ```
|
348
|
+
#
|
349
|
+
# A [Proc](Proc.downloaded.ruby_doc) object converted from a method has no
|
350
|
+
# tricks.
|
351
|
+
#
|
352
|
+
# ```ruby
|
353
|
+
# def m() end
|
354
|
+
# method(:m).to_proc.lambda? #=> true
|
355
|
+
#
|
356
|
+
# n(&method(:m)) #=> true
|
357
|
+
# n(&method(:m).to_proc) #=> true
|
358
|
+
# ```
|
359
|
+
#
|
360
|
+
# `define_method` is treated the same as method definition. The defined
|
361
|
+
# method has no tricks.
|
362
|
+
#
|
363
|
+
# ```ruby
|
364
|
+
# class C
|
365
|
+
# define_method(:d) {}
|
366
|
+
# end
|
367
|
+
# C.new.d(1,2) #=> ArgumentError
|
368
|
+
# C.new.method(:d).to_proc.lambda? #=> true
|
369
|
+
# ```
|
370
|
+
#
|
371
|
+
# `define_method` always defines a method without the tricks, even if a
|
372
|
+
# non-lambda [Proc](Proc.downloaded.ruby_doc) object is given. This is the
|
373
|
+
# only exception for which the tricks are not preserved.
|
374
|
+
#
|
375
|
+
# ```ruby
|
376
|
+
# class C
|
377
|
+
# define_method(:e, &proc {})
|
378
|
+
# end
|
379
|
+
# C.new.e(1,2) #=> ArgumentError
|
380
|
+
# C.new.method(:e).to_proc.lambda? #=> true
|
381
|
+
# ```
|
382
|
+
#
|
383
|
+
# This exception ensures that methods never have tricks and makes it easy
|
384
|
+
# to have wrappers to define methods that behave as usual.
|
385
|
+
#
|
386
|
+
# ```ruby
|
387
|
+
# class C
|
388
|
+
# def self.def2(name, &body)
|
389
|
+
# define_method(name, &body)
|
390
|
+
# end
|
391
|
+
#
|
392
|
+
# def2(:f) {}
|
393
|
+
# end
|
394
|
+
# C.new.f(1,2) #=> ArgumentError
|
395
|
+
# ```
|
396
|
+
#
|
397
|
+
# The wrapper *def2* defines a method which has no tricks.
|
398
|
+
def lambda?: () -> bool
|
399
|
+
|
400
|
+
# Returns the parameter information of this proc.
|
401
|
+
#
|
402
|
+
# ```ruby
|
403
|
+
# prc = lambda{|x, y=42, *other|}
|
404
|
+
# prc.parameters #=> [[:req, :x], [:opt, :y], [:rest, :other]]
|
405
|
+
# ```
|
406
|
+
def parameters: () -> ::Array[[ Symbol, Symbol ]]
|
407
|
+
|
408
|
+
# Returns the Ruby source filename and line number containing this proc or
|
409
|
+
# `nil` if this proc was not defined in Ruby (i.e. native).
|
410
|
+
def source_location: () -> [ String, Integer ]
|
411
|
+
|
412
|
+
# Part of the protocol for converting objects to `Proc` objects. Instances
|
413
|
+
# of class `Proc` simply return themselves.
|
414
|
+
def to_proc: () -> self
|
415
|
+
|
416
|
+
# Returns the unique identifier for this proc, along with an indication of
|
417
|
+
# where the proc was defined.
|
418
|
+
#
|
419
|
+
#
|
420
|
+
#
|
421
|
+
# Also aliased as: [inspect](Proc.downloaded.ruby_doc#method-i-inspect)
|
422
|
+
def to_s: () -> String
|
423
|
+
|
424
|
+
# Alias for: [to\_s](Proc.downloaded.ruby_doc#method-i-to_s)
|
425
|
+
def inspect: () -> String
|
426
|
+
end
|
@@ -0,0 +1,354 @@
|
|
1
|
+
# [Module](https://ruby-doc.org/core-2.6.3/Module.html) to handle
|
2
|
+
# processes.
|
3
|
+
module Process
|
4
|
+
# Returns the name of the script being executed. The value is not affected
|
5
|
+
# by assigning a new value to $0.
|
6
|
+
#
|
7
|
+
# This method first appeared in Ruby 2.1 to serve as a global variable
|
8
|
+
# free means to get the script name.
|
9
|
+
def self.argv0: () -> String
|
10
|
+
|
11
|
+
def self.clock_getres: (Symbol | Integer clock_id, ?Symbol unit) -> (Float | Integer)
|
12
|
+
|
13
|
+
def self.clock_gettime: (Symbol | Integer clock_id, ?Symbol unit) -> (Float | Integer)
|
14
|
+
|
15
|
+
def self.daemon: (?untyped nochdir, ?untyped noclose) -> Integer
|
16
|
+
|
17
|
+
def self.detach: (Integer pid) -> Thread
|
18
|
+
|
19
|
+
# Returns the effective group ID for this process. Not available on all
|
20
|
+
# platforms.
|
21
|
+
#
|
22
|
+
# ```ruby
|
23
|
+
# Process.egid #=> 500
|
24
|
+
# ```
|
25
|
+
def self.egid: () -> Integer
|
26
|
+
|
27
|
+
def self.egid=: (Integer arg0) -> Integer
|
28
|
+
|
29
|
+
# Returns the effective user ID for this process.
|
30
|
+
#
|
31
|
+
# ```ruby
|
32
|
+
# Process.euid #=> 501
|
33
|
+
# ```
|
34
|
+
def self.euid: () -> Integer
|
35
|
+
|
36
|
+
def self.euid=: (Integer arg0) -> Integer
|
37
|
+
|
38
|
+
def self.getpgid: (Integer pid) -> Integer
|
39
|
+
|
40
|
+
# Returns the process group ID for this process. Not available on all
|
41
|
+
# platforms.
|
42
|
+
#
|
43
|
+
# ```ruby
|
44
|
+
# Process.getpgid(0) #=> 25527
|
45
|
+
# Process.getpgrp #=> 25527
|
46
|
+
# ```
|
47
|
+
def self.getpgrp: () -> Integer
|
48
|
+
|
49
|
+
def self.getpriority: (Integer kind, Integer arg0) -> Integer
|
50
|
+
|
51
|
+
def self.getrlimit: (Symbol | String | Integer resource) -> [ Integer, Integer ]
|
52
|
+
|
53
|
+
def self.getsid: (?Integer pid) -> Integer
|
54
|
+
|
55
|
+
# Returns the (real) group ID for this process.
|
56
|
+
#
|
57
|
+
# ```ruby
|
58
|
+
# Process.gid #=> 500
|
59
|
+
# ```
|
60
|
+
def self.gid: () -> Integer
|
61
|
+
|
62
|
+
def self.gid=: (Integer arg0) -> Integer
|
63
|
+
|
64
|
+
# Get an `Array` of the group IDs in the supplemental group access list
|
65
|
+
# for this process.
|
66
|
+
#
|
67
|
+
# ```ruby
|
68
|
+
# Process.groups #=> [27, 6, 10, 11]
|
69
|
+
# ```
|
70
|
+
#
|
71
|
+
# Note that this method is just a wrapper of getgroups(2). This means that
|
72
|
+
# the following characteristics of the result completely depend on your
|
73
|
+
# system:
|
74
|
+
#
|
75
|
+
# - the result is sorted
|
76
|
+
#
|
77
|
+
# - the result includes effective GIDs
|
78
|
+
#
|
79
|
+
# - the result does not include duplicated GIDs
|
80
|
+
#
|
81
|
+
# You can make sure to get a sorted unique
|
82
|
+
# [GID](https://ruby-doc.org/core-2.6.3/Process/GID.html) list of the
|
83
|
+
# current process by this expression:
|
84
|
+
#
|
85
|
+
# ```ruby
|
86
|
+
# Process.groups.uniq.sort
|
87
|
+
# ```
|
88
|
+
def self.groups: () -> ::Array[Integer]
|
89
|
+
|
90
|
+
def self.groups=: (::Array[Integer] arg0) -> ::Array[Integer]
|
91
|
+
|
92
|
+
def self.initgroups: (String username, Integer gid) -> ::Array[Integer]
|
93
|
+
|
94
|
+
def self.kill: (Integer | Symbol | String signal, *Integer pids) -> Integer
|
95
|
+
|
96
|
+
# Returns the maximum number of gids allowed in the supplemental group
|
97
|
+
# access list.
|
98
|
+
#
|
99
|
+
# ```ruby
|
100
|
+
# Process.maxgroups #=> 32
|
101
|
+
# ```
|
102
|
+
def self.maxgroups: () -> Integer
|
103
|
+
|
104
|
+
def self.maxgroups=: (Integer arg0) -> Integer
|
105
|
+
|
106
|
+
# Returns the process id of this process. Not available on all platforms.
|
107
|
+
#
|
108
|
+
# ```ruby
|
109
|
+
# Process.pid #=> 27415
|
110
|
+
# ```
|
111
|
+
def self.pid: () -> Integer
|
112
|
+
|
113
|
+
# Returns the process id of the parent of this process. Returns
|
114
|
+
# untrustworthy value on Win32/64. Not available on all platforms.
|
115
|
+
#
|
116
|
+
# ```ruby
|
117
|
+
# puts "I am #{Process.pid}"
|
118
|
+
# Process.fork { puts "Dad is #{Process.ppid}" }
|
119
|
+
# ```
|
120
|
+
#
|
121
|
+
# *produces:*
|
122
|
+
#
|
123
|
+
# ```ruby
|
124
|
+
# I am 27417
|
125
|
+
# Dad is 27417
|
126
|
+
# ```
|
127
|
+
def self.ppid: () -> Integer
|
128
|
+
|
129
|
+
def self.setpgid: (Integer pid, Integer arg0) -> Integer
|
130
|
+
|
131
|
+
def self.setpriority: (Integer kind, Integer arg0, Integer priority) -> Integer
|
132
|
+
|
133
|
+
def self.setproctitle: (String arg0) -> String
|
134
|
+
|
135
|
+
def self.setrlimit: (Symbol | String | Integer resource, Integer cur_limit, ?Integer max_limit) -> NilClass
|
136
|
+
|
137
|
+
# Establishes this process as a new session and process group leader, with
|
138
|
+
# no controlling tty. Returns the session id. Not available on all
|
139
|
+
# platforms.
|
140
|
+
#
|
141
|
+
# ```ruby
|
142
|
+
# Process.setsid #=> 27422
|
143
|
+
# ```
|
144
|
+
def self.setsid: () -> Integer
|
145
|
+
|
146
|
+
# Returns a `Tms` structure (see `Process::Tms` ) that contains user and
|
147
|
+
# system CPU times for this process, and also for children processes.
|
148
|
+
#
|
149
|
+
# ```ruby
|
150
|
+
# t = Process.times
|
151
|
+
# [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00]
|
152
|
+
# ```
|
153
|
+
def self.times: () -> Process::Tms
|
154
|
+
|
155
|
+
# Returns the (real) user ID of this process.
|
156
|
+
#
|
157
|
+
# ```ruby
|
158
|
+
# Process.uid #=> 501
|
159
|
+
# ```
|
160
|
+
def self.uid: () -> Integer
|
161
|
+
|
162
|
+
def self.uid=: (Integer user) -> Integer
|
163
|
+
|
164
|
+
def self.wait: (?Integer pid, ?Integer flags) -> Integer
|
165
|
+
|
166
|
+
def self.wait2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
|
167
|
+
|
168
|
+
def self.waitall: () -> ::Array[[ Integer, Process::Status ]]
|
169
|
+
|
170
|
+
def self.waitpid: (?Integer pid, ?Integer flags) -> Integer
|
171
|
+
|
172
|
+
def self.waitpid2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
|
173
|
+
end
|
174
|
+
|
175
|
+
Process::CLOCK_BOOTTIME: Integer
|
176
|
+
|
177
|
+
Process::CLOCK_BOOTTIME_ALARM: Integer
|
178
|
+
|
179
|
+
Process::CLOCK_MONOTONIC: Integer
|
180
|
+
|
181
|
+
Process::CLOCK_MONOTONIC_COARSE: Integer
|
182
|
+
|
183
|
+
Process::CLOCK_MONOTONIC_RAW: Integer
|
184
|
+
|
185
|
+
Process::CLOCK_PROCESS_CPUTIME_ID: Integer
|
186
|
+
|
187
|
+
Process::CLOCK_REALTIME: Integer
|
188
|
+
|
189
|
+
Process::CLOCK_REALTIME_ALARM: Integer
|
190
|
+
|
191
|
+
Process::CLOCK_REALTIME_COARSE: Integer
|
192
|
+
|
193
|
+
Process::CLOCK_THREAD_CPUTIME_ID: Integer
|
194
|
+
|
195
|
+
Process::PRIO_PGRP: Integer
|
196
|
+
|
197
|
+
Process::PRIO_PROCESS: Integer
|
198
|
+
|
199
|
+
Process::PRIO_USER: Integer
|
200
|
+
|
201
|
+
Process::RLIMIT_AS: Integer
|
202
|
+
|
203
|
+
Process::RLIMIT_CORE: Integer
|
204
|
+
|
205
|
+
Process::RLIMIT_CPU: Integer
|
206
|
+
|
207
|
+
Process::RLIMIT_DATA: Integer
|
208
|
+
|
209
|
+
Process::RLIMIT_FSIZE: Integer
|
210
|
+
|
211
|
+
Process::RLIMIT_MEMLOCK: Integer
|
212
|
+
|
213
|
+
Process::RLIMIT_MSGQUEUE: Integer
|
214
|
+
|
215
|
+
Process::RLIMIT_NICE: Integer
|
216
|
+
|
217
|
+
Process::RLIMIT_NOFILE: Integer
|
218
|
+
|
219
|
+
Process::RLIMIT_NPROC: Integer
|
220
|
+
|
221
|
+
Process::RLIMIT_RSS: Integer
|
222
|
+
|
223
|
+
Process::RLIMIT_RTPRIO: Integer
|
224
|
+
|
225
|
+
Process::RLIMIT_RTTIME: Integer
|
226
|
+
|
227
|
+
Process::RLIMIT_SIGPENDING: Integer
|
228
|
+
|
229
|
+
Process::RLIMIT_STACK: Integer
|
230
|
+
|
231
|
+
Process::RLIM_INFINITY: Integer
|
232
|
+
|
233
|
+
Process::RLIM_SAVED_CUR: Integer
|
234
|
+
|
235
|
+
Process::RLIM_SAVED_MAX: Integer
|
236
|
+
|
237
|
+
Process::WNOHANG: Integer
|
238
|
+
|
239
|
+
Process::WUNTRACED: Integer
|
240
|
+
|
241
|
+
module Process::GID
|
242
|
+
def self.change_privilege: (Integer group) -> Integer
|
243
|
+
|
244
|
+
def self.eid: () -> Integer
|
245
|
+
|
246
|
+
def self.from_name: (String name) -> Integer
|
247
|
+
|
248
|
+
def self.grant_privilege: (Integer group) -> Integer
|
249
|
+
|
250
|
+
def self.re_exchange: () -> Integer
|
251
|
+
|
252
|
+
def self.re_exchangeable?: () -> bool
|
253
|
+
|
254
|
+
def self.rid: () -> Integer
|
255
|
+
|
256
|
+
def self.sid_available?: () -> bool
|
257
|
+
|
258
|
+
def self.switch: () -> Integer
|
259
|
+
| [T] () { () -> T } -> T
|
260
|
+
|
261
|
+
def self.eid=: (Integer group) -> Integer
|
262
|
+
end
|
263
|
+
|
264
|
+
class Process::Status < Object
|
265
|
+
def &: (Integer num) -> Integer
|
266
|
+
|
267
|
+
def ==: (untyped other) -> bool
|
268
|
+
|
269
|
+
def >>: (Integer num) -> Integer
|
270
|
+
|
271
|
+
def coredump?: () -> bool
|
272
|
+
|
273
|
+
def exited?: () -> bool
|
274
|
+
|
275
|
+
def exitstatus: () -> Integer?
|
276
|
+
|
277
|
+
def inspect: () -> String
|
278
|
+
|
279
|
+
def pid: () -> Integer
|
280
|
+
|
281
|
+
def signaled?: () -> bool
|
282
|
+
|
283
|
+
def stopped?: () -> bool
|
284
|
+
|
285
|
+
def stopsig: () -> Integer?
|
286
|
+
|
287
|
+
def success?: () -> bool
|
288
|
+
|
289
|
+
def termsig: () -> Integer?
|
290
|
+
|
291
|
+
def to_i: () -> Integer
|
292
|
+
|
293
|
+
def to_s: () -> String
|
294
|
+
end
|
295
|
+
|
296
|
+
module Process::Sys
|
297
|
+
def self.geteuid: () -> Integer
|
298
|
+
|
299
|
+
def self.getgid: () -> Integer
|
300
|
+
|
301
|
+
def self.getuid: () -> Integer
|
302
|
+
|
303
|
+
def self.issetugid: () -> bool
|
304
|
+
|
305
|
+
def self.setegid: (Integer group) -> NilClass
|
306
|
+
|
307
|
+
def self.seteuid: (Integer user) -> NilClass
|
308
|
+
|
309
|
+
def self.setgid: (Integer group) -> NilClass
|
310
|
+
|
311
|
+
def self.setregid: (Integer rid, Integer eid) -> NilClass
|
312
|
+
|
313
|
+
def self.setresgid: (Integer rid, Integer eid, Integer sid) -> NilClass
|
314
|
+
|
315
|
+
def self.setresuid: (Integer rid, Integer eid, Integer sid) -> NilClass
|
316
|
+
|
317
|
+
def self.setreuid: (Integer rid, Integer eid) -> NilClass
|
318
|
+
|
319
|
+
def self.setrgid: (Integer group) -> NilClass
|
320
|
+
|
321
|
+
def self.setruid: (Integer user) -> NilClass
|
322
|
+
|
323
|
+
def self.setuid: (Integer user) -> NilClass
|
324
|
+
end
|
325
|
+
|
326
|
+
module Process::UID
|
327
|
+
def self.change_privilege: (Integer user) -> Integer
|
328
|
+
|
329
|
+
def self.eid: () -> Integer
|
330
|
+
|
331
|
+
def self.from_name: (String name) -> Integer
|
332
|
+
|
333
|
+
def self.grant_privilege: (Integer user) -> Integer
|
334
|
+
|
335
|
+
def self.re_exchange: () -> Integer
|
336
|
+
|
337
|
+
def self.re_exchangeable?: () -> bool
|
338
|
+
|
339
|
+
def self.rid: () -> Integer
|
340
|
+
|
341
|
+
def self.sid_available?: () -> bool
|
342
|
+
|
343
|
+
def self.switch: () -> Integer
|
344
|
+
| [T] () { () -> T } -> T
|
345
|
+
|
346
|
+
def self.eid=: (Integer user) -> Integer
|
347
|
+
end
|
348
|
+
|
349
|
+
class Process::Tms < Struct[Float]
|
350
|
+
end
|
351
|
+
|
352
|
+
class Process::Waiter < Thread
|
353
|
+
def pid: () -> Integer
|
354
|
+
end
|