rbs 0.15.0 → 0.19.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 +8 -4
- data/CHANGELOG.md +29 -1
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +19 -1
- data/Steepfile +0 -1
- data/bin/test_runner.rb +15 -1
- data/{stdlib/builtin → core}/array.rbs +1 -1
- data/{stdlib/builtin → core}/basic_object.rbs +0 -0
- data/{stdlib/builtin → core}/binding.rbs +0 -0
- data/{stdlib/builtin → core}/builtin.rbs +2 -2
- data/{stdlib/builtin → core}/class.rbs +0 -0
- data/{stdlib/builtin → core}/comparable.rbs +0 -0
- data/{stdlib/builtin → core}/complex.rbs +0 -0
- data/{stdlib/builtin → core}/constants.rbs +0 -0
- data/{stdlib/builtin → core}/data.rbs +0 -0
- data/{stdlib/builtin → core}/deprecated.rbs +0 -0
- data/{stdlib/builtin → core}/dir.rbs +1 -1
- data/{stdlib/builtin → core}/encoding.rbs +0 -0
- data/{stdlib/builtin → core}/enumerable.rbs +41 -40
- data/{stdlib/builtin → core}/enumerator.rbs +5 -5
- data/{stdlib/builtin → core}/errno.rbs +0 -0
- data/{stdlib/builtin → core}/errors.rbs +0 -0
- data/{stdlib/builtin → core}/exception.rbs +0 -0
- data/{stdlib/builtin → core}/false_class.rbs +0 -0
- data/{stdlib/builtin → core}/fiber.rbs +0 -0
- data/{stdlib/builtin → core}/fiber_error.rbs +0 -0
- data/{stdlib/builtin → core}/file.rbs +0 -4
- data/{stdlib/builtin → core}/file_test.rbs +0 -0
- data/{stdlib/builtin → core}/float.rbs +0 -0
- data/{stdlib/builtin → core}/gc.rbs +0 -0
- data/{stdlib/builtin → core}/hash.rbs +8 -8
- data/{stdlib/builtin → core}/integer.rbs +0 -0
- data/{stdlib/builtin → core}/io.rbs +1 -1
- data/{stdlib/builtin → core}/kernel.rbs +0 -0
- data/{stdlib/builtin → core}/marshal.rbs +0 -0
- data/{stdlib/builtin → core}/match_data.rbs +0 -0
- data/{stdlib/builtin → core}/math.rbs +0 -0
- data/{stdlib/builtin → core}/method.rbs +0 -0
- data/{stdlib/builtin → core}/module.rbs +0 -0
- data/{stdlib/builtin → core}/nil_class.rbs +0 -0
- data/{stdlib/builtin → core}/numeric.rbs +0 -0
- data/{stdlib/builtin → core}/object.rbs +0 -0
- data/core/object_space.rbs +98 -0
- data/{stdlib/builtin → core}/proc.rbs +0 -0
- data/{stdlib/builtin → core}/process.rbs +0 -0
- data/{stdlib/builtin → core}/random.rbs +0 -0
- data/{stdlib/builtin → core}/range.rbs +1 -1
- data/{stdlib/builtin → core}/rational.rbs +0 -0
- data/{stdlib/builtin → core}/rb_config.rbs +0 -0
- data/{stdlib/builtin → core}/regexp.rbs +0 -0
- data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
- data/{stdlib/builtin → core}/signal.rbs +0 -0
- data/{stdlib/builtin → core}/string.rbs +0 -0
- data/{stdlib/builtin → core}/string_io.rbs +0 -0
- data/{stdlib/builtin → core}/struct.rbs +1 -1
- data/{stdlib/builtin → core}/symbol.rbs +0 -0
- data/{stdlib/builtin → core}/thread.rbs +0 -0
- data/{stdlib/builtin → core}/thread_group.rbs +0 -0
- data/{stdlib/builtin → core}/time.rbs +0 -0
- data/{stdlib/builtin → core}/trace_point.rbs +0 -0
- data/{stdlib/builtin → core}/true_class.rbs +0 -0
- data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
- data/{stdlib/builtin → core}/warning.rbs +0 -0
- data/docs/repo.md +125 -0
- data/lib/rbs.rb +1 -0
- data/lib/rbs/cli.rb +105 -103
- data/lib/rbs/definition.rb +9 -4
- data/lib/rbs/definition_builder.rb +48 -15
- data/lib/rbs/environment_loader.rb +79 -105
- data/lib/rbs/environment_walker.rb +70 -35
- data/lib/rbs/parser.rb +306 -301
- data/lib/rbs/parser.y +15 -8
- data/lib/rbs/prototype/rb.rb +150 -21
- data/lib/rbs/prototype/runtime.rb +1 -0
- data/lib/rbs/repository.rb +121 -0
- data/lib/rbs/test/hook.rb +25 -15
- data/lib/rbs/test/setup.rb +5 -3
- data/lib/rbs/test/type_check.rb +6 -1
- data/lib/rbs/type_name.rb +2 -1
- data/lib/rbs/vendorer.rb +38 -16
- data/lib/rbs/version.rb +1 -1
- data/sig/cli.rbs +58 -0
- data/sig/definition.rbs +8 -3
- data/sig/definition_builder.rbs +4 -1
- data/sig/environment_loader.rbs +92 -46
- data/sig/polyfill.rbs +42 -0
- data/sig/rbs.rbs +8 -0
- data/sig/repository.rbs +79 -0
- data/sig/vendorer.rbs +44 -0
- data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
- data/stdlib/base64/{base64.rbs → 0/base64.rbs} +0 -0
- data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +0 -0
- data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
- data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
- data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +0 -0
- data/stdlib/csv/{csv.rbs → 0/csv.rbs} +3 -3
- data/stdlib/date/{date.rbs → 0/date.rbs} +0 -0
- data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +0 -0
- data/stdlib/dbm/0/dbm.rbs +277 -0
- data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
- data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
- data/stdlib/find/{find.rbs → 0/find.rbs} +0 -0
- data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
- data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
- data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
- data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
- data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +0 -0
- data/stdlib/logger/{logger.rbs → 0/logger.rbs} +0 -0
- data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
- data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
- data/stdlib/monitor/0/monitor.rbs +119 -0
- data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
- data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +0 -0
- data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
- data/stdlib/prime/{prime.rbs → 0/prime.rbs} +1 -1
- data/stdlib/pstore/{pstore.rbs → 0/pstore.rbs} +0 -0
- data/stdlib/pty/{pty.rbs → 0/pty.rbs} +0 -0
- data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
- data/stdlib/set/{set.rbs → 0/set.rbs} +10 -10
- data/stdlib/singleton/0/singleton.rbs +111 -0
- data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +0 -0
- data/stdlib/tsort/0/cyclic.rbs +4 -0
- data/stdlib/tsort/0/interfaces.rbs +19 -0
- data/stdlib/tsort/0/tsort.rbs +363 -0
- data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
- data/stdlib/uri/{generic.rbs → 0/generic.rbs} +0 -0
- data/stdlib/uri/{http.rbs → 0/http.rbs} +0 -0
- data/stdlib/uri/{https.rbs → 0/https.rbs} +0 -0
- data/stdlib/uri/{ldap.rbs → 0/ldap.rbs} +0 -0
- data/stdlib/uri/{ldaps.rbs → 0/ldaps.rbs} +0 -0
- data/stdlib/yaml/0/dbm.rbs +221 -0
- data/stdlib/yaml/0/store.rbs +53 -0
- data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
- data/steep/Gemfile.lock +9 -9
- metadata +108 -94
data/sig/polyfill.rbs
CHANGED
@@ -1,3 +1,45 @@
|
|
1
1
|
module Kernel
|
2
2
|
def to_json: (*untyped) -> String
|
3
3
|
end
|
4
|
+
|
5
|
+
module Gem
|
6
|
+
class Version
|
7
|
+
def self.correct?: (String) -> bool
|
8
|
+
|
9
|
+
def self.create: (String?) -> instance?
|
10
|
+
|
11
|
+
include Comparable
|
12
|
+
|
13
|
+
def prerelease?: () -> bool
|
14
|
+
|
15
|
+
def release: () -> self
|
16
|
+
|
17
|
+
def version: () -> String
|
18
|
+
end
|
19
|
+
|
20
|
+
class Specification
|
21
|
+
attr_reader version (): Version
|
22
|
+
|
23
|
+
attr_reader gem_dir (): String
|
24
|
+
|
25
|
+
def self.find_by_name: (String name, ?String? version) -> instance
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class OptionParser
|
30
|
+
def initialize: () ?{ (instance) -> void } -> void
|
31
|
+
|
32
|
+
def on: (*String) { (String) -> void } -> void
|
33
|
+
|
34
|
+
attr_accessor version: String
|
35
|
+
|
36
|
+
attr_accessor banner: String
|
37
|
+
|
38
|
+
def order!: (Array[String]) -> void
|
39
|
+
|
40
|
+
def parse!: (Array[String]) -> void
|
41
|
+
|
42
|
+
def ver: () -> String
|
43
|
+
|
44
|
+
def help: () -> String
|
45
|
+
end
|
data/sig/rbs.rbs
CHANGED
data/sig/repository.rbs
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
module RBS
|
2
|
+
# Set of RBS repositories.
|
3
|
+
#
|
4
|
+
# A repository object can handle multiple repository roots.
|
5
|
+
#
|
6
|
+
# repo = RBS::Repository.new()
|
7
|
+
# repo.add(Pathname("vendor/rbs/gem-rbs"))
|
8
|
+
# repo.add(Pathname("vendor/rbs/internal-rbs"))
|
9
|
+
# repo.add(Pathname("vendor/rbs/definitely-rbs"))
|
10
|
+
#
|
11
|
+
# repo.lookup("minitest", "2.1.3") => Pathname or nil
|
12
|
+
#
|
13
|
+
# If one gem version can resolve to several directories, the last added dir wins.
|
14
|
+
#
|
15
|
+
class Repository
|
16
|
+
class GemRBS
|
17
|
+
attr_reader name: String
|
18
|
+
|
19
|
+
# Array of gem dirs.
|
20
|
+
# Gem dir contains directories for each version.
|
21
|
+
attr_reader paths: Array[Pathname]
|
22
|
+
|
23
|
+
# Hash from a version to VersionPath object.
|
24
|
+
attr_reader versions(): Hash[Gem::Version, VersionPath]
|
25
|
+
|
26
|
+
@versions: Hash[Gem::Version, VersionPath]?
|
27
|
+
|
28
|
+
def initialize: (name: String) -> void
|
29
|
+
|
30
|
+
def load!: () -> void
|
31
|
+
|
32
|
+
def version_names: () -> Array[Gem::Version]
|
33
|
+
|
34
|
+
def oldest_version: () -> VersionPath
|
35
|
+
|
36
|
+
def latest_version: () -> VersionPath
|
37
|
+
|
38
|
+
def find_best_version: (Gem::Version?) -> VersionPath
|
39
|
+
|
40
|
+
# Returns true if versions is empty.
|
41
|
+
def empty?: () -> bool
|
42
|
+
end
|
43
|
+
|
44
|
+
class VersionPath
|
45
|
+
attr_reader gem: GemRBS
|
46
|
+
attr_reader version: Gem::Version
|
47
|
+
attr_reader path: Pathname
|
48
|
+
|
49
|
+
def initialize: (gem: GemRBS, version: Gem::Version, path: Pathname) -> void
|
50
|
+
end
|
51
|
+
|
52
|
+
DEFAULT_STDLIB_ROOT: Pathname
|
53
|
+
|
54
|
+
# Array of _root dir_s of repositories.
|
55
|
+
#
|
56
|
+
attr_reader dirs: Array[Pathname]
|
57
|
+
|
58
|
+
attr_reader gems: Hash[String, GemRBS]
|
59
|
+
|
60
|
+
# An optional keyword argument `no_stdlib` is to skip adding directory for stdlib classes.
|
61
|
+
# Passing truthy value will skip loading stdlib. (You can add the stdlib root by yourself.)
|
62
|
+
#
|
63
|
+
def initialize: (?no_stdlib: bool) -> void
|
64
|
+
|
65
|
+
# Add new _root dir_ to the repository set.
|
66
|
+
# If two repository dirs have exactly same gem-version definitions, the latter overwrites the prior.
|
67
|
+
#
|
68
|
+
def add: (Pathname dir) -> void
|
69
|
+
|
70
|
+
# Returns a directory for given `gem` name and `version`.
|
71
|
+
# `version` can be `nil` for _any version_.
|
72
|
+
#
|
73
|
+
# If the given gem cannot be found, it returns `nil`.
|
74
|
+
#
|
75
|
+
def lookup: (String gem, String? version) -> Pathname?
|
76
|
+
|
77
|
+
def lookup_path: (String gem, String? version) -> [GemRBS, VersionPath]?
|
78
|
+
end
|
79
|
+
end
|
data/sig/vendorer.rbs
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module RBS
|
2
|
+
# Copies RBS files loaded through `loader` under `vendor_dir`.
|
3
|
+
#
|
4
|
+
# Core libraries and library RBS files will be copied.
|
5
|
+
#
|
6
|
+
# loader = RBS::EnvironmentLoader.new()
|
7
|
+
#
|
8
|
+
# loader.add(library: set) # Libraries will be copied.
|
9
|
+
# loader.add(library: "minitest", version: "1.2.3")
|
10
|
+
#
|
11
|
+
# loader.add(path: Pathname("sig")) # Dirs will be ignored.
|
12
|
+
#
|
13
|
+
# vendorer = RBS::Vendorer.new(vendor_dir: Pathname("vendor/rbs"), loader: loader)
|
14
|
+
# vendorer.clearn!
|
15
|
+
# vendorer.copy!
|
16
|
+
#
|
17
|
+
# The result will be:
|
18
|
+
# vendor/rbs/core => Will include core RBSs
|
19
|
+
# vendor/rbs/set-0 => Will include `set` library RBSs.
|
20
|
+
# vendor/rbs/minitest-1.2.3 => Will include `minitest` library RBSs.
|
21
|
+
#
|
22
|
+
# The vendorerd RBSs will be loaded through :dir source.
|
23
|
+
#
|
24
|
+
# loader = RBS::EnvironmentLoader.new(core_root: nil, repository: RBS::Repository.new(no_stdlib: true))
|
25
|
+
# loader.add(path: Pathname("vendor/rbs"))
|
26
|
+
# loader.add(path: Pathname("sig"))
|
27
|
+
#
|
28
|
+
class Vendorer
|
29
|
+
attr_reader vendor_dir: Pathname
|
30
|
+
attr_reader loader: EnvironmentLoader
|
31
|
+
|
32
|
+
def initialize: (vendor_dir: Pathname, loader: EnvironmentLoader) -> void
|
33
|
+
|
34
|
+
# Copy RBS files into `vendor_dir`.
|
35
|
+
# Ensures the `vendor_dir` exists.
|
36
|
+
def copy!: () -> void
|
37
|
+
|
38
|
+
# Deletes `vendor_dir` and its content if exists.
|
39
|
+
#
|
40
|
+
def clean!: () -> void
|
41
|
+
|
42
|
+
def ensure_dir: [A] () { () -> A } -> A
|
43
|
+
end
|
44
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -159,7 +159,7 @@
|
|
159
159
|
# with it.
|
160
160
|
#
|
161
161
|
class CSV < Object
|
162
|
-
include Enumerable[untyped
|
162
|
+
include Enumerable[untyped]
|
163
163
|
|
164
164
|
# This method is intended as the primary interface for reading CSV files. You
|
165
165
|
# pass a `path` and any `options` you wish to set for the read. Each row of file
|
@@ -407,7 +407,7 @@ CSV::VERSION: String
|
|
407
407
|
# processing is activated.
|
408
408
|
#
|
409
409
|
class CSV::Row < Object
|
410
|
-
include Enumerable[untyped
|
410
|
+
include Enumerable[untyped]
|
411
411
|
|
412
412
|
# If a two-element Array is provided, it is assumed to be a header and field and
|
413
413
|
# the pair is appended. A Hash works the same way with the key being the header
|
@@ -578,7 +578,7 @@ end
|
|
578
578
|
# processing is activated.
|
579
579
|
#
|
580
580
|
class CSV::Table[out Elem] < Object
|
581
|
-
include Enumerable[untyped
|
581
|
+
include Enumerable[untyped]
|
582
582
|
|
583
583
|
# Constructs a new CSV::Table from `array_of_rows`, which are expected to be
|
584
584
|
# CSV::Row objects. All rows are assumed to have the same headers.
|
File without changes
|
File without changes
|
@@ -0,0 +1,277 @@
|
|
1
|
+
# ## Introduction
|
2
|
+
#
|
3
|
+
# The DBM class provides a wrapper to a Unix-style
|
4
|
+
# [dbm](http://en.wikipedia.org/wiki/Dbm) or Database Manager library.
|
5
|
+
#
|
6
|
+
# Dbm databases do not have tables or columns; they are simple key-value data
|
7
|
+
# stores, like a Ruby Hash except not resident in RAM. Keys and values must be
|
8
|
+
# strings.
|
9
|
+
#
|
10
|
+
# The exact library used depends on how Ruby was compiled. It could be any of
|
11
|
+
# the following:
|
12
|
+
#
|
13
|
+
# * The original ndbm library is released in 4.3BSD. It is based on dbm
|
14
|
+
# library in Unix Version 7 but has different API to support multiple
|
15
|
+
# databases in a process.
|
16
|
+
# * [Berkeley DB](http://en.wikipedia.org/wiki/Berkeley_DB) versions 1 thru 6,
|
17
|
+
# also known as BDB and Sleepycat DB, now owned by Oracle Corporation.
|
18
|
+
# * Berkeley DB 1.x, still found in 4.4BSD derivatives (FreeBSD, OpenBSD,
|
19
|
+
# etc).
|
20
|
+
# * [gdbm](http://www.gnu.org/software/gdbm/), the GNU implementation of dbm.
|
21
|
+
# * [qdbm](http://fallabs.com/qdbm/index.html), another open source
|
22
|
+
# reimplementation of dbm.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# All of these dbm implementations have their own Ruby interfaces available,
|
26
|
+
# which provide richer (but varying) APIs.
|
27
|
+
#
|
28
|
+
# ## Cautions
|
29
|
+
#
|
30
|
+
# Before you decide to use DBM, there are some issues you should consider:
|
31
|
+
#
|
32
|
+
# * Each implementation of dbm has its own file format. Generally, dbm
|
33
|
+
# libraries will not read each other's files. This makes dbm files a bad
|
34
|
+
# choice for data exchange.
|
35
|
+
#
|
36
|
+
# * Even running the same OS and the same dbm implementation, the database
|
37
|
+
# file format may depend on the CPU architecture. For example, files may not
|
38
|
+
# be portable between PowerPC and 386, or between 32 and 64 bit Linux.
|
39
|
+
#
|
40
|
+
# * Different versions of Berkeley DB use different file formats. A change to
|
41
|
+
# the OS may therefore break DBM access to existing files.
|
42
|
+
#
|
43
|
+
# * Data size limits vary between implementations. Original Berkeley DB was
|
44
|
+
# limited to 2GB of data. Dbm libraries also sometimes limit the total size
|
45
|
+
# of a key/value pair, and the total size of all the keys that hash to the
|
46
|
+
# same value. These limits can be as little as 512 bytes. That said, gdbm
|
47
|
+
# and recent versions of Berkeley DB do away with these limits.
|
48
|
+
#
|
49
|
+
#
|
50
|
+
# Given the above cautions, DBM is not a good choice for long term storage of
|
51
|
+
# important data. It is probably best used as a fast and easy alternative to a
|
52
|
+
# Hash for processing large amounts of data.
|
53
|
+
#
|
54
|
+
# ## Example
|
55
|
+
#
|
56
|
+
# require 'dbm'
|
57
|
+
# db = DBM.open('rfcs', 0666, DBM::WRCREAT)
|
58
|
+
# db['822'] = 'Standard for the Format of ARPA Internet Text Messages'
|
59
|
+
# db['1123'] = 'Requirements for Internet Hosts - Application and Support'
|
60
|
+
# db['3068'] = 'An Anycast Prefix for 6to4 Relay Routers'
|
61
|
+
# puts db['822']
|
62
|
+
#
|
63
|
+
class DBM
|
64
|
+
include Enumerable[untyped]
|
65
|
+
|
66
|
+
# Open a dbm database and yields it if a block is given. See also `DBM.new`.
|
67
|
+
#
|
68
|
+
def self.open: (*untyped) -> ::DBM
|
69
|
+
|
70
|
+
public
|
71
|
+
|
72
|
+
# Return a value from the database by locating the key string provided. If the
|
73
|
+
# key is not found, returns nil.
|
74
|
+
#
|
75
|
+
def []: (untyped) -> untyped
|
76
|
+
|
77
|
+
# Stores the specified string value in the database, indexed via the string key
|
78
|
+
# provided.
|
79
|
+
#
|
80
|
+
def []=: (untyped, untyped) -> untyped
|
81
|
+
|
82
|
+
# Deletes all data from the database.
|
83
|
+
#
|
84
|
+
def clear: () -> self
|
85
|
+
|
86
|
+
# Closes the database.
|
87
|
+
#
|
88
|
+
def close: () -> NilClass
|
89
|
+
|
90
|
+
# Returns true if the database is closed, false otherwise.
|
91
|
+
#
|
92
|
+
def closed?: () -> bool
|
93
|
+
|
94
|
+
# Deletes an entry from the database.
|
95
|
+
#
|
96
|
+
def delete: (untyped) -> untyped
|
97
|
+
|
98
|
+
# Deletes all entries for which the code block returns true. Returns self.
|
99
|
+
#
|
100
|
+
def delete_if: () ?{ (untyped) -> bool } -> self
|
101
|
+
|
102
|
+
# Calls the block once for each [key, value] pair in the database. Returns self.
|
103
|
+
#
|
104
|
+
def each: (?untyped, ?untyped) -> Enumerator[untyped, ::DBM]
|
105
|
+
|
106
|
+
# Calls the block once for each key string in the database. Returns self.
|
107
|
+
#
|
108
|
+
def each_key: () -> Enumerator[String, ::DBM]
|
109
|
+
|
110
|
+
# Calls the block once for each [key, value] pair in the database. Returns self.
|
111
|
+
#
|
112
|
+
def each_pair: (?untyped, ?untyped) -> Enumerator[untyped, ::DBM]
|
113
|
+
|
114
|
+
# Calls the block once for each value string in the database. Returns self.
|
115
|
+
#
|
116
|
+
def each_value: () -> Enumerator[untyped, ::DBM]
|
117
|
+
|
118
|
+
# Returns true if the database is empty, false otherwise.
|
119
|
+
#
|
120
|
+
def empty?: () -> bool
|
121
|
+
|
122
|
+
# Return a value from the database by locating the key string provided. If the
|
123
|
+
# key is not found, returns `ifnone`. If `ifnone` is not given, raises
|
124
|
+
# IndexError.
|
125
|
+
#
|
126
|
+
def fetch: (*String) -> untyped
|
127
|
+
|
128
|
+
# Returns true if the database contains the specified key, false otherwise.
|
129
|
+
#
|
130
|
+
def has_key?: (String) -> bool
|
131
|
+
|
132
|
+
# Returns true if the database contains the specified string value, false
|
133
|
+
# otherwise.
|
134
|
+
#
|
135
|
+
def has_value?: (untyped) -> bool
|
136
|
+
|
137
|
+
# Returns true if the database contains the specified key, false otherwise.
|
138
|
+
#
|
139
|
+
def include?: (String) -> bool
|
140
|
+
|
141
|
+
def index: (untyped) -> (String | NilClass)
|
142
|
+
|
143
|
+
# Returns a Hash (not a DBM database) created by using each value in the
|
144
|
+
# database as a key, with the corresponding key as its value.
|
145
|
+
#
|
146
|
+
def invert: () -> Hash[untyped, String]
|
147
|
+
|
148
|
+
# Returns the key for the specified value.
|
149
|
+
#
|
150
|
+
def key: (untyped) -> (String | NilClass)
|
151
|
+
|
152
|
+
# Returns true if the database contains the specified key, false otherwise.
|
153
|
+
#
|
154
|
+
def key?: (untyped) -> bool
|
155
|
+
|
156
|
+
# Returns an array of all the string keys in the database.
|
157
|
+
#
|
158
|
+
def keys: () -> Array[String]
|
159
|
+
|
160
|
+
# Returns the number of entries in the database.
|
161
|
+
#
|
162
|
+
def length: () -> Integer
|
163
|
+
|
164
|
+
# Returns true if the database contains the specified key, false otherwise.
|
165
|
+
#
|
166
|
+
def member?: (untyped) -> bool
|
167
|
+
|
168
|
+
# Converts the contents of the database to an in-memory Hash, then calls
|
169
|
+
# Hash#reject with the specified code block, returning a new Hash.
|
170
|
+
#
|
171
|
+
def reject: () -> Hash[untyped, untyped]
|
172
|
+
|
173
|
+
# Deletes all entries for which the code block returns true. Returns self.
|
174
|
+
#
|
175
|
+
def reject!: () { (String, untyped) -> untyped } -> self
|
176
|
+
|
177
|
+
# Replaces the contents of the database with the contents of the specified
|
178
|
+
# object. Takes any object which implements the each_pair method, including Hash
|
179
|
+
# and DBM objects.
|
180
|
+
#
|
181
|
+
def replace: (untyped) -> ::DBM
|
182
|
+
|
183
|
+
# Returns a new array consisting of the [key, value] pairs for which the code
|
184
|
+
# block returns true.
|
185
|
+
#
|
186
|
+
def select: () { () -> untyped } -> Array[untyped]
|
187
|
+
|
188
|
+
# Removes a [key, value] pair from the database, and returns it. If the database
|
189
|
+
# is empty, returns nil. The order in which values are removed/returned is not
|
190
|
+
# guaranteed.
|
191
|
+
#
|
192
|
+
def shift: () -> Array[untyped]
|
193
|
+
|
194
|
+
# Returns the number of entries in the database.
|
195
|
+
#
|
196
|
+
def size: () -> Integer
|
197
|
+
|
198
|
+
# Stores the specified string value in the database, indexed via the string key
|
199
|
+
# provided.
|
200
|
+
#
|
201
|
+
def store: (String, untyped) -> String
|
202
|
+
|
203
|
+
# Converts the contents of the database to an array of [key, value] arrays, and
|
204
|
+
# returns it.
|
205
|
+
#
|
206
|
+
def to_a: () -> Array[untyped]
|
207
|
+
|
208
|
+
# Converts the contents of the database to an in-memory Hash object, and returns
|
209
|
+
# it.
|
210
|
+
#
|
211
|
+
def to_hash: () -> Hash[String, untyped]
|
212
|
+
|
213
|
+
# Updates the database with multiple values from the specified object. Takes any
|
214
|
+
# object which implements the each_pair method, including Hash and DBM objects.
|
215
|
+
#
|
216
|
+
def update: (untyped) -> ::DBM
|
217
|
+
|
218
|
+
# Returns true if the database contains the specified string value, false
|
219
|
+
# otherwise.
|
220
|
+
#
|
221
|
+
def value?: (untyped) -> bool
|
222
|
+
|
223
|
+
# Returns an array of all the string values in the database.
|
224
|
+
#
|
225
|
+
def values: () -> Array[untyped]
|
226
|
+
|
227
|
+
# Returns an array containing the values associated with the given keys.
|
228
|
+
#
|
229
|
+
def values_at: (*String) -> Array[untyped]
|
230
|
+
|
231
|
+
private
|
232
|
+
|
233
|
+
# Open a dbm database with the specified name, which can include a directory
|
234
|
+
# path. Any file extensions needed will be supplied automatically by the dbm
|
235
|
+
# library. For example, Berkeley DB appends '.db', and GNU gdbm uses two
|
236
|
+
# physical files with extensions '.dir' and '.pag'.
|
237
|
+
#
|
238
|
+
# The mode should be an integer, as for Unix chmod.
|
239
|
+
#
|
240
|
+
# Flags should be one of READER, WRITER, WRCREAT or NEWDB.
|
241
|
+
#
|
242
|
+
def initialize: (*untyped) -> self
|
243
|
+
end
|
244
|
+
|
245
|
+
# Indicates that dbm_open() should open the database in read/write mode, create
|
246
|
+
# it if it does not already exist, and delete all contents if it does already
|
247
|
+
# exist.
|
248
|
+
#
|
249
|
+
DBM::NEWDB: Integer
|
250
|
+
|
251
|
+
# Indicates that dbm_open() should open the database in read-only mode
|
252
|
+
#
|
253
|
+
#
|
254
|
+
DBM::READER: Integer
|
255
|
+
|
256
|
+
# Identifies ndbm library version.
|
257
|
+
#
|
258
|
+
# Examples:
|
259
|
+
#
|
260
|
+
# * "ndbm (4.3BSD)"
|
261
|
+
# * "Berkeley DB 4.8.30: (April 9, 2010)"
|
262
|
+
# * "Berkeley DB (unknown)" (4.4BSD, maybe)
|
263
|
+
# * "GDBM version 1.8.3. 10/15/2002 (built Jul 1 2011 12:32:45)"
|
264
|
+
# * "QDBM 1.8.78"
|
265
|
+
#
|
266
|
+
#
|
267
|
+
DBM::VERSION: String
|
268
|
+
|
269
|
+
# Indicates that dbm_open() should open the database in read/write mode, and
|
270
|
+
# create it if it does not already exist
|
271
|
+
#
|
272
|
+
DBM::WRCREAT: Integer
|
273
|
+
|
274
|
+
# Indicates that dbm_open() should open the database in read/write mode
|
275
|
+
#
|
276
|
+
#
|
277
|
+
DBM::WRITER: Integer
|