rbs 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -173,6 +173,8 @@ Encoding::Big5_HKSCS_2008: Encoding
173
173
 
174
174
  Encoding::Big5_UAO: Encoding
175
175
 
176
+ Encoding::CESU_8: Encoding
177
+
176
178
  Encoding::CP1250: Encoding
177
179
 
178
180
  Encoding::CP1251: Encoding
@@ -385,7 +385,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
385
385
  | () { (Elem arg0) -> untyped } -> self
386
386
 
387
387
  # variadic type parameter is not supported yet
388
- # https://github.com/ruby/ruby-signature/issues/21
388
+ # https://github.com/ruby/rbs/issues/21
389
389
  def zip: [Elem2, Return2] (::Enumerable[Elem2, Return2] enum) -> ::Array[[Elem, Elem2 | nil]]
390
390
  | [U, Elem2, Return2] (::Enumerable[Elem2, Return2]) { ([Elem, Elem2 | nil]) -> U } -> nil
391
391
 
@@ -250,9 +250,11 @@ class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
250
250
  end
251
251
 
252
252
  class Enumerator::Yielder < Object
253
- def <<: (*untyped arg0) -> void
253
+ def <<: (untyped arg0) -> void
254
254
 
255
255
  def yield: (*untyped arg0) -> void
256
+
257
+ def to_proc: () -> Proc
256
258
  end
257
259
 
258
260
  class Enumerator::Chain[out Elem, out Return] < Object
@@ -62,7 +62,11 @@
62
62
  class Fiber < Object
63
63
  def self.yield: (*untyped args) -> untyped
64
64
 
65
- def initialize: () { () -> void } -> Fiber
65
+ def initialize: () { () -> untyped } -> void
66
66
 
67
67
  def resume: (*untyped args) -> untyped
68
+
69
+ def raise: () -> untyped
70
+ | (string message) -> untyped
71
+ | (_Exception exception, ?string message, ?Array[String] backtrace) -> untyped
68
72
  end
@@ -152,7 +152,7 @@ class Symbol
152
152
  # In general, `to_sym` returns the Symbol corresponding to an object. As *sym*
153
153
  # is already a symbol, `self` is returned in this case.
154
154
  #
155
- def intern: () -> self
155
+ def intern: () -> Symbol
156
156
 
157
157
  # Same as `sym.to_s.length`.
158
158
  #
@@ -0,0 +1,117 @@
1
+ # Fibers are primitives for implementing light weight cooperative concurrency in
2
+ # Ruby. Basically they are a means of creating code blocks that can be paused
3
+ # and resumed, much like threads. The main difference is that they are never
4
+ # preempted and that the scheduling must be done by the programmer and not the
5
+ # VM.
6
+ #
7
+ # As opposed to other stackless light weight concurrency models, each fiber
8
+ # comes with a stack. This enables the fiber to be paused from deeply nested
9
+ # function calls within the fiber block. See the ruby(1) manpage to configure
10
+ # the size of the fiber stack(s).
11
+ #
12
+ # When a fiber is created it will not run automatically. Rather it must be
13
+ # explicitly asked to run using the Fiber#resume method. The code running inside
14
+ # the fiber can give up control by calling Fiber.yield in which case it yields
15
+ # control back to caller (the caller of the Fiber#resume).
16
+ #
17
+ # Upon yielding or termination the Fiber returns the value of the last executed
18
+ # expression
19
+ #
20
+ # For instance:
21
+ #
22
+ # fiber = Fiber.new do
23
+ # Fiber.yield 1
24
+ # 2
25
+ # end
26
+ #
27
+ # puts fiber.resume
28
+ # puts fiber.resume
29
+ # puts fiber.resume
30
+ #
31
+ # *produces*
32
+ #
33
+ # 1
34
+ # 2
35
+ # FiberError: dead fiber called
36
+ #
37
+ # The Fiber#resume method accepts an arbitrary number of parameters, if it is
38
+ # the first call to #resume then they will be passed as block arguments.
39
+ # Otherwise they will be the return value of the call to Fiber.yield
40
+ #
41
+ # Example:
42
+ #
43
+ # fiber = Fiber.new do |first|
44
+ # second = Fiber.yield first + 2
45
+ # end
46
+ #
47
+ # puts fiber.resume 10
48
+ # puts fiber.resume 1_000_000
49
+ # puts fiber.resume "The fiber will be dead before I can cause trouble"
50
+ #
51
+ # *produces*
52
+ #
53
+ # 12
54
+ # 1000000
55
+ # FiberError: dead fiber called
56
+ #
57
+ extension Fiber (Fiber)
58
+ # Returns the current fiber. You need to `require 'fiber'` before using this
59
+ # method. If you are not running in the context of a fiber this method will
60
+ # return the root fiber.
61
+ #
62
+ def self.current: () -> Fiber
63
+
64
+ public
65
+
66
+ # Returns true if the fiber can still be resumed (or transferred to). After
67
+ # finishing execution of the fiber block this method will always return false.
68
+ # You need to `require 'fiber'` before using this method.
69
+ #
70
+ def alive?: () -> bool
71
+
72
+ # Transfer control to another fiber, resuming it from where it last stopped or
73
+ # starting it if it was not resumed before. The calling fiber will be suspended
74
+ # much like in a call to Fiber.yield. You need to `require 'fiber'` before using
75
+ # this method.
76
+ #
77
+ # The fiber which receives the transfer call is treats it much like a resume
78
+ # call. Arguments passed to transfer are treated like those passed to resume.
79
+ #
80
+ # You cannot call `resume` on a fiber that has been transferred to. If you call
81
+ # `transfer` on a fiber, and later call `resume` on the the fiber, a
82
+ # `FiberError` will be raised. Once you call `transfer` on a fiber, the only way
83
+ # to resume processing the fiber is to call `transfer` on it again.
84
+ #
85
+ # Example:
86
+ #
87
+ # fiber1 = Fiber.new do
88
+ # puts "In Fiber 1"
89
+ # Fiber.yield
90
+ # puts "In Fiber 1 again"
91
+ # end
92
+ #
93
+ # fiber2 = Fiber.new do
94
+ # puts "In Fiber 2"
95
+ # fiber1.transfer
96
+ # puts "Never see this message"
97
+ # end
98
+ #
99
+ # fiber3 = Fiber.new do
100
+ # puts "In Fiber 3"
101
+ # end
102
+ #
103
+ # fiber2.resume
104
+ # fiber3.resume
105
+ # fiber1.resume rescue (p $!)
106
+ # fiber1.transfer
107
+ #
108
+ # *produces*
109
+ #
110
+ # In Fiber 2
111
+ # In Fiber 1
112
+ # In Fiber 3
113
+ # #<FiberError: cannot resume transferred Fiber>
114
+ # In Fiber 1 again
115
+ #
116
+ def transfer: (*untyped) -> untyped
117
+ 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: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 2.3.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: json-schema
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.8'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.8'
125
139
  description: RBS is the language for type signatures for Ruby and standard library
126
140
  definitions.
127
141
  email:
@@ -191,6 +205,14 @@ files:
191
205
  - lib/rbs/writer.rb
192
206
  - lib/ruby/signature.rb
193
207
  - rbs.gemspec
208
+ - schema/annotation.json
209
+ - schema/comment.json
210
+ - schema/decls.json
211
+ - schema/function.json
212
+ - schema/location.json
213
+ - schema/members.json
214
+ - schema/methodType.json
215
+ - schema/types.json
194
216
  - stdlib/abbrev/abbrev.rbs
195
217
  - stdlib/base64/base64.rbs
196
218
  - stdlib/benchmark/benchmark.rbs
@@ -253,6 +275,7 @@ files:
253
275
  - stdlib/coverage/coverage.rbs
254
276
  - stdlib/csv/csv.rbs
255
277
  - stdlib/erb/erb.rbs
278
+ - stdlib/fiber/fiber.rbs
256
279
  - stdlib/find/find.rbs
257
280
  - stdlib/ipaddr/ipaddr.rbs
258
281
  - stdlib/json/json.rbs