rbs 0.17.0 → 0.20.1

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.
@@ -0,0 +1,111 @@
1
+ # The Singleton module implements the Singleton pattern.
2
+ #
3
+ # ## Usage
4
+ #
5
+ # To use Singleton, include the module in your class.
6
+ #
7
+ # class Klass
8
+ # include Singleton
9
+ # # ...
10
+ # end
11
+ #
12
+ # This ensures that only one instance of Klass can be created.
13
+ #
14
+ # a,b = Klass.instance, Klass.instance
15
+ #
16
+ # a == b
17
+ # # => true
18
+ #
19
+ # Klass.new
20
+ # # => NoMethodError - new is private ...
21
+ #
22
+ # The instance is created at upon the first call of Klass.instance().
23
+ #
24
+ # class OtherKlass
25
+ # include Singleton
26
+ # # ...
27
+ # end
28
+ #
29
+ # ObjectSpace.each_object(OtherKlass){}
30
+ # # => 0
31
+ #
32
+ # OtherKlass.instance
33
+ # ObjectSpace.each_object(OtherKlass){}
34
+ # # => 1
35
+ #
36
+ # This behavior is preserved under inheritance and cloning.
37
+ #
38
+ # ## Implementation
39
+ #
40
+ # This above is achieved by:
41
+ #
42
+ # * Making Klass.new and Klass.allocate private.
43
+ #
44
+ # * Overriding Klass.inherited(sub_klass) and Klass.clone() to ensure that the
45
+ # Singleton properties are kept when inherited and cloned.
46
+ #
47
+ # * Providing the Klass.instance() method that returns the same object each
48
+ # time it is called.
49
+ #
50
+ # * Overriding Klass._load(str) to call Klass.instance().
51
+ #
52
+ # * Overriding Klass#clone and Klass#dup to raise TypeErrors to prevent
53
+ # cloning or duping.
54
+ #
55
+ #
56
+ # ## Singleton and Marshal
57
+ #
58
+ # By default Singleton's #_dump(depth) returns the empty string. Marshalling by
59
+ # default will strip state information, e.g. instance variables from the
60
+ # instance. Classes using Singleton can provide custom _load(str) and
61
+ # _dump(depth) methods to retain some of the previous state of the instance.
62
+ #
63
+ # require 'singleton'
64
+ #
65
+ # class Example
66
+ # include Singleton
67
+ # attr_accessor :keep, :strip
68
+ # def _dump(depth)
69
+ # # this strips the @strip information from the instance
70
+ # Marshal.dump(@keep, depth)
71
+ # end
72
+ #
73
+ # def self._load(str)
74
+ # instance.keep = Marshal.load(str)
75
+ # instance
76
+ # end
77
+ # end
78
+ #
79
+ # a = Example.instance
80
+ # a.keep = "keep this"
81
+ # a.strip = "get rid of this"
82
+ #
83
+ # stored_state = Marshal.dump(a)
84
+ #
85
+ # a.keep = nil
86
+ # a.strip = nil
87
+ # b = Marshal.load(stored_state)
88
+ # p a == b # => true
89
+ # p a.keep # => "keep this"
90
+ # p a.strip # => nil
91
+ module Singleton
92
+ def self.__init__: (Class klass) -> Class
93
+
94
+ def self.instance: () -> instance
95
+
96
+ public
97
+
98
+ # By default, do not retain any state when marshalling.
99
+ #
100
+ def _dump: (?Integer depth) -> String
101
+
102
+ # Raises a TypeError to prevent cloning.
103
+ #
104
+ def clone: () -> bot
105
+
106
+ # Raises a TypeError to prevent duping.
107
+ #
108
+ def dup: () -> bot
109
+ end
110
+
111
+ Singleton::VERSION: String
@@ -142,6 +142,8 @@ module TSort[Node] : TSort::_Sortable[Node]
142
142
  #
143
143
  def self.each_strongly_connected_component: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (Array[T]) -> void } -> void
144
144
  | [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[Array[T], void]
145
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) { (Array[T]) -> void } -> void
146
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Enumerator[Array[T], void]
145
147
 
146
148
  # Iterates over strongly connected components in a graph. The graph is
147
149
  # represented by *node* and *each_child*.
@@ -165,6 +167,8 @@ module TSort[Node] : TSort::_Sortable[Node]
165
167
  #
166
168
  def self.each_strongly_connected_component_from: [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) { (Array[T]) -> void } -> void
167
169
  | [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) -> Enumerator[Array[T], void]
170
+ | [T] (T node, ^(T) { (T) -> void } -> void each_child, ?untyped id_map, ?untyped stack) { (Array[T]) -> void } -> void
171
+ | [T] (T node, ^(T) { (T) -> void } -> void each_child, ?untyped id_map, ?untyped stack) -> Enumerator[Array[T], void]
168
172
 
169
173
  # Returns strongly connected components as an array of arrays of nodes. The
170
174
  # array is sorted from children to parents. Each elements of the array
@@ -188,6 +192,7 @@ module TSort[Node] : TSort::_Sortable[Node]
188
192
  # #=> [[4], [2, 3], [1]]
189
193
  #
190
194
  def self.strongly_connected_components: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[Array[T]]
195
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Array[Array[T]]
191
196
 
192
197
  # Returns a topologically sorted array of nodes. The array is sorted from
193
198
  # children to parents, i.e. the first element has no child and the last node has
@@ -211,6 +216,7 @@ module TSort[Node] : TSort::_Sortable[Node]
211
216
  # p TSort.tsort(each_node, each_child) # raises TSort::Cyclic
212
217
  #
213
218
  def self.tsort: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[T]
219
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Array[T]
214
220
 
215
221
  # The iterator version of the TSort.tsort method.
216
222
  #
@@ -230,6 +236,8 @@ module TSort[Node] : TSort::_Sortable[Node]
230
236
  #
231
237
  def self.tsort_each: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (T) -> void } -> void
232
238
  | [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[T, void]
239
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) { (T) -> void } -> void
240
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Enumerator[T, void]
233
241
 
234
242
  # The iterator version of the #strongly_connected_components method.
235
243
  # *`obj*.each_strongly_connected_component` is similar to
@@ -0,0 +1,221 @@
1
+ # YAML Ain't Markup Language
2
+ #
3
+ # This module provides a Ruby interface for data serialization in YAML format.
4
+ #
5
+ # The YAML module is an alias of Psych, the YAML engine for Ruby.
6
+ #
7
+ # ## Usage
8
+ #
9
+ # Working with YAML can be very simple, for example:
10
+ #
11
+ # require 'yaml'
12
+ # # Parse a YAML string
13
+ # YAML.load("--- foo") #=> "foo"
14
+ #
15
+ # # Emit some YAML
16
+ # YAML.dump("foo") # => "--- foo\n...\n"
17
+ # { :a => 'b'}.to_yaml # => "---\n:a: b\n"
18
+ #
19
+ # As the implementation is provided by the Psych library, detailed documentation
20
+ # can be found in that library's docs (also part of standard library).
21
+ #
22
+ # ## Security
23
+ #
24
+ # Do not use YAML to load untrusted data. Doing so is unsafe and could allow
25
+ # malicious input to execute arbitrary code inside your application. Please see
26
+ # doc/security.rdoc for more information.
27
+ #
28
+ # ## History
29
+ #
30
+ # Syck was the original for YAML implementation in Ruby's standard library
31
+ # developed by why the lucky stiff.
32
+ #
33
+ # You can still use Syck, if you prefer, for parsing and emitting YAML, but you
34
+ # must install the 'syck' gem now in order to use it.
35
+ #
36
+ # In older Ruby versions, ie. <= 1.9, Syck is still provided, however it was
37
+ # completely removed with the release of Ruby 2.0.0.
38
+ #
39
+ # ## More info
40
+ #
41
+ # For more advanced details on the implementation see Psych, and also check out
42
+ # http://yaml.org for spec details and other helpful information.
43
+ #
44
+ # Psych is maintained by Aaron Patterson on github:
45
+ # https://github.com/ruby/psych
46
+ #
47
+ # Syck can also be found on github: https://github.com/ruby/syck
48
+ #
49
+ module YAML
50
+ # YAML + DBM = YDBM
51
+ #
52
+ # YAML::DBM provides the same interface as ::DBM.
53
+ #
54
+ # However, while DBM only allows strings for both keys and values,
55
+ # this library allows one to use most Ruby objects for values
56
+ # by first converting them to YAML. Keys must be strings.
57
+ #
58
+ # Conversion to and from YAML is performed automatically.
59
+ #
60
+ # See the documentation for ::DBM and ::YAML for more information.
61
+ class DBM < ::DBM
62
+ VERSION: ::String
63
+
64
+ # :call-seq:
65
+ # ydbm[key] -> value
66
+ #
67
+ # Return value associated with +key+ from database.
68
+ #
69
+ # Returns +nil+ if there is no such +key+.
70
+ #
71
+ # See #fetch for more information.
72
+ def []: (String key) -> untyped
73
+
74
+ # :call-seq:
75
+ # ydbm[key] = value
76
+ #
77
+ # Set +key+ to +value+ in database.
78
+ #
79
+ # +value+ will be converted to YAML before storage.
80
+ #
81
+ # See #store for more information.
82
+ def []=: (String key, untyped val) -> untyped
83
+
84
+ # :call-seq:
85
+ # ydbm.fetch( key, ifnone = nil )
86
+ # ydbm.fetch( key ) { |key| ... }
87
+ #
88
+ # Return value associated with +key+.
89
+ #
90
+ # If there is no value for +key+ and no block is given, returns +ifnone+.
91
+ #
92
+ # Otherwise, calls block passing in the given +key+.
93
+ #
94
+ # See ::DBM#fetch for more information.
95
+ def fetch: (String keystr, ?untyped? ifnone) { (untyped) -> untyped } -> untyped
96
+
97
+ # Deprecated, used YAML::DBM#key instead.
98
+ # ----
99
+ # Note:
100
+ # YAML::DBM#index makes warning from internal of ::DBM#index.
101
+ # It says 'DBM#index is deprecated; use DBM#key', but DBM#key
102
+ # behaves not same as DBM#index.
103
+ #
104
+ def index: (String keystr) -> untyped
105
+
106
+ # :call-seq:
107
+ # ydbm.key(value) -> string
108
+ #
109
+ # Returns the key for the specified value.
110
+ def key: (String keystr) -> String
111
+
112
+ # :call-seq:
113
+ # ydbm.values_at(*keys)
114
+ #
115
+ # Returns an array containing the values associated with the given keys.
116
+ def values_at: (*untyped keys) -> Array[untyped]
117
+
118
+ # :call-seq:
119
+ # ydbm.delete(key)
120
+ #
121
+ # Deletes value from database associated with +key+.
122
+ #
123
+ # Returns value or +nil+.
124
+ def delete: (String key) -> untyped
125
+
126
+ def delete_if: () { (untyped, untyped) -> untyped } -> untyped
127
+
128
+ # :call-seq:
129
+ # ydbm.reject { |key, value| ... }
130
+ #
131
+ # Converts the contents of the database to an in-memory Hash, then calls
132
+ # Hash#reject with the specified code block, returning a new Hash.
133
+ def reject: () { (untyped, untyped) -> untyped } -> Hash[untyped, untyped]
134
+
135
+ def each_pair: () { (untyped, untyped) -> untyped } -> untyped
136
+
137
+ def each_value: () { (untyped) -> untyped } -> untyped
138
+
139
+ # :call-seq:
140
+ # ydbm.values
141
+ #
142
+ # Returns an array of values from the database.
143
+ def values: () -> untyped
144
+
145
+ # :call-seq:
146
+ # ydbm.has_value?(value)
147
+ #
148
+ # Returns true if specified +value+ is found in the database.
149
+ def has_value?: (untyped val) -> (::TrueClass | ::FalseClass)
150
+
151
+ # :call-seq:
152
+ # ydbm.invert -> hash
153
+ #
154
+ # Returns a Hash (not a DBM database) created by using each value in the
155
+ # database as a key, with the corresponding key as its value.
156
+ #
157
+ # Note that all values in the hash will be Strings, but the keys will be
158
+ # actual objects.
159
+ def invert: () -> Hash[untyped, untyped]
160
+
161
+ # :call-seq:
162
+ # ydbm.replace(hash) -> ydbm
163
+ #
164
+ # Replaces the contents of the database with the contents of the specified
165
+ # object. Takes any object which implements the each_pair method, including
166
+ # Hash and DBM objects.
167
+ def replace: (Hash[untyped, untyped] | DBM hsh) -> YAML::DBM
168
+
169
+ # :call-seq:
170
+ # ydbm.shift -> [key, value]
171
+ #
172
+ # Removes a [key, value] pair from the database, and returns it.
173
+ # If the database is empty, returns +nil+.
174
+ #
175
+ # The order in which values are removed/returned is not guaranteed.
176
+ def shift: () -> (Array[untyped] | untyped)
177
+
178
+ # :call-seq:
179
+ # ydbm.select { |key, value| ... }
180
+ # ydbm.select(*keys)
181
+ #
182
+ # If a block is provided, returns a new array containing [key, value] pairs
183
+ # for which the block returns true.
184
+ #
185
+ # Otherwise, same as #values_at
186
+ def select: (*untyped keys) { (untyped, untyped) -> untyped } -> Array[untyped]
187
+
188
+ # :call-seq:
189
+ # ydbm.store(key, value) -> value
190
+ #
191
+ # Stores +value+ in database with +key+ as the index. +value+ is converted
192
+ # to YAML before being stored.
193
+ #
194
+ # Returns +value+
195
+ def store: (String key, untyped val) -> untyped
196
+
197
+ # :call-seq:
198
+ # ydbm.update(hash) -> ydbm
199
+ #
200
+ # Updates the database with multiple values from the specified object.
201
+ # Takes any object which implements the each_pair method, including
202
+ # Hash and DBM objects.
203
+ #
204
+ # Returns +self+.
205
+ def update: (Hash[untyped, untyped]) -> YAML::DBM
206
+
207
+ # :call-seq:
208
+ # ydbm.to_a -> array
209
+ #
210
+ # Converts the contents of the database to an array of [key, value] arrays,
211
+ # and returns it.
212
+ def to_a: () -> Array [untyped]
213
+
214
+ # :call-seq:
215
+ # ydbm.to_hash -> hash
216
+ #
217
+ # Converts the contents of the database to an in-memory Hash object, and
218
+ # returns it.
219
+ def to_hash: () -> Hash[untyped, untyped]
220
+ end
221
+ end
@@ -0,0 +1,53 @@
1
+ # YAML::Store provides the same functionality as PStore, except it uses YAML to
2
+ # dump objects instead of Marshal.
3
+ #
4
+ # ## Example
5
+ #
6
+ # require 'yaml/store'
7
+ #
8
+ # Person = Struct.new :first_name, :last_name
9
+ #
10
+ # people = [Person.new("Bob", "Smith"), Person.new("Mary", "Johnson")]
11
+ #
12
+ # store = YAML::Store.new "test.store"
13
+ #
14
+ # store.transaction do
15
+ # store["people"] = people
16
+ # store["greeting"] = { "hello" => "world" }
17
+ # end
18
+ #
19
+ # After running the above code, the contents of "test.store" will be:
20
+ #
21
+ # ---
22
+ # people:
23
+ # - !ruby/struct:Person
24
+ # first_name: Bob
25
+ # last_name: Smith
26
+ # - !ruby/struct:Person
27
+ # first_name: Mary
28
+ # last_name: Johnson
29
+ # greeting:
30
+ # hello: world
31
+ #
32
+ class YAML::Store < ::PStore
33
+ # Creates a new YAML::Store object, which will store data in `file_name`. If the
34
+ # file does not already exist, it will be created.
35
+ #
36
+ # YAML::Store objects are always reentrant. But if *thread_safe* is set to true,
37
+ # then it will become thread-safe at the cost of a minor performance hit.
38
+ #
39
+ # Options passed in through `yaml_opts` will be used when converting the store
40
+ # to YAML via Hash#to_yaml().
41
+ #
42
+ def initialize: (*untyped o) -> YAML::Store
43
+
44
+ def dump: (untyped table) -> String
45
+
46
+ def empty_marshal_checksum: () -> String
47
+
48
+ def empty_marshal_data: () -> String
49
+
50
+ def load: (String) -> untyped
51
+
52
+ def marshal_dump_supports_canonical_option?: () -> ::FalseClass
53
+ end
@@ -16,7 +16,7 @@ GEM
16
16
  i18n (1.8.5)
17
17
  concurrent-ruby (~> 1.0)
18
18
  language_server-protocol (3.15.0.1)
19
- listen (3.2.1)
19
+ listen (3.3.3)
20
20
  rb-fsevent (~> 0.10, >= 0.10.3)
21
21
  rb-inotify (~> 0.9, >= 0.9.10)
22
22
  minitest (5.14.2)
@@ -26,20 +26,20 @@ GEM
26
26
  rb-fsevent (0.10.4)
27
27
  rb-inotify (0.10.1)
28
28
  ffi (~> 1.0)
29
- rbs (0.14.0)
30
- steep (0.34.0)
29
+ rbs (0.17.0)
30
+ steep (0.36.0)
31
31
  activesupport (>= 5.1)
32
32
  ast_utils (~> 0.3.0)
33
33
  language_server-protocol (~> 3.15.0.1)
34
34
  listen (~> 3.0)
35
35
  parser (~> 2.7.0)
36
36
  rainbow (>= 2.2.2, < 4.0)
37
- rbs (~> 0.14.0)
37
+ rbs (~> 0.17.0)
38
38
  thor (1.0.1)
39
39
  thread_safe (0.3.6)
40
- tzinfo (1.2.7)
40
+ tzinfo (1.2.8)
41
41
  thread_safe (~> 0.1)
42
- zeitwerk (2.4.1)
42
+ zeitwerk (2.4.2)
43
43
 
44
44
  PLATFORMS
45
45
  ruby
@@ -48,4 +48,4 @@ DEPENDENCIES
48
48
  steep
49
49
 
50
50
  BUNDLED WITH
51
- 2.1.4
51
+ 2.2.0.rc.2