tash 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +112 -0
- data/lib/tash/version.rb +5 -0
- data/lib/tash.rb +1230 -0
- data/sig/tash.rbs +178 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/tash_spec.rb +1148 -0
- metadata +63 -0
data/sig/tash.rbs
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
module Tash
|
2
|
+
VERSION: String
|
3
|
+
|
4
|
+
class Tash[unchecked out K, unchecked out V] < Object
|
5
|
+
include Enumerable[[ K, V ]]
|
6
|
+
|
7
|
+
def self.[]: [U, V] (Tash[U, V]) -> Tash[U, V]
|
8
|
+
| [U, V] (_ToHash[U, V]) { (U) -> unchecked out U } -> Tash[U, V]
|
9
|
+
| [U, V] (Array[[ U, V ]]) { (U) -> unchecked out U } -> Tash[U, V]
|
10
|
+
| (*untyped) { (U) -> unchecked out U } -> Tash[untyped, untyped]
|
11
|
+
|
12
|
+
public
|
13
|
+
|
14
|
+
def <: [A, B] ((Tash | Hash)[A, B]) -> bool
|
15
|
+
|
16
|
+
def <=: [A, B] ((Tash | Hash)[A, B]) -> bool
|
17
|
+
|
18
|
+
def ==: (untyped other) -> bool
|
19
|
+
|
20
|
+
def >: [A, B] ((Tash | Hash)[A, B]) -> bool
|
21
|
+
|
22
|
+
def >=: [A, B] ((Tash | Hash)[A, B]) -> bool
|
23
|
+
|
24
|
+
def []: (K) -> V
|
25
|
+
|
26
|
+
def []=: (K, V) -> V
|
27
|
+
|
28
|
+
def assoc: (K) -> [ K, V ]?
|
29
|
+
|
30
|
+
def clear: () -> self
|
31
|
+
|
32
|
+
def compact: () -> Tash[K, V]
|
33
|
+
|
34
|
+
def compact!: () -> self?
|
35
|
+
|
36
|
+
def compare_by_identity: () -> self
|
37
|
+
|
38
|
+
def compare_by_identity?: () -> bool
|
39
|
+
|
40
|
+
def deconstruct_keys: (Array[K] | nil) -> self
|
41
|
+
|
42
|
+
def default: (?K) -> V?
|
43
|
+
|
44
|
+
def default=: (V) -> V
|
45
|
+
|
46
|
+
def default_proc: () -> (Proc | nil)
|
47
|
+
|
48
|
+
def default_proc=: (Proc | _ToProc | nil) -> (Proc | _ToProc | nil)
|
49
|
+
|
50
|
+
def delete: (K) -> V?
|
51
|
+
| [U] (K) { (K) -> U } -> (U | V)
|
52
|
+
|
53
|
+
def delete_if: () { (K, V) -> boolish } -> self
|
54
|
+
| () -> Enumerator[[ K, V ], self]
|
55
|
+
|
56
|
+
def dig: (K, *untyped) -> untyped
|
57
|
+
|
58
|
+
def each: () { ([ K, V ]) -> untyped } -> self
|
59
|
+
| () -> ::Enumerator[[ K, V ], self]
|
60
|
+
|
61
|
+
def each_key: () { (K) -> untyped } -> Tash[K, V]
|
62
|
+
| () -> Enumerator[K, self]
|
63
|
+
|
64
|
+
alias each_pair each
|
65
|
+
|
66
|
+
def each_value: () { (V) -> untyped } -> self
|
67
|
+
| () -> Enumerator[V, self]
|
68
|
+
|
69
|
+
def empty?: () -> bool
|
70
|
+
|
71
|
+
def eql?: (untyped) -> bool
|
72
|
+
|
73
|
+
def except: (*K) -> Tash[K, V]
|
74
|
+
|
75
|
+
def fetch: (K) -> V
|
76
|
+
| [X] (K, X) -> (V | X)
|
77
|
+
| [X] (K) { (K) -> X } -> (V | X)
|
78
|
+
|
79
|
+
def fetch_values: (*K) -> Array[V]
|
80
|
+
| [X] (*K) { (K) -> X } -> Array[V | X]
|
81
|
+
|
82
|
+
alias filter select
|
83
|
+
|
84
|
+
alias filter! select!
|
85
|
+
|
86
|
+
def flatten: () -> Array[K | V]
|
87
|
+
| (1 level) -> Array[K | V]
|
88
|
+
| (Integer level) -> Array[untyped]
|
89
|
+
|
90
|
+
alias has_key? key?
|
91
|
+
|
92
|
+
alias has_value? value?
|
93
|
+
|
94
|
+
def hash: () -> Integer
|
95
|
+
|
96
|
+
alias include? has_key?
|
97
|
+
|
98
|
+
def inspect: () -> String
|
99
|
+
|
100
|
+
def invert: () -> Tash[V, K]
|
101
|
+
|
102
|
+
def keep_if: () { (K, V) -> boolish } -> self
|
103
|
+
| () -> Enumerator[[ K, V ], self]
|
104
|
+
|
105
|
+
def key: (V) -> K?
|
106
|
+
|
107
|
+
def key?: (K) -> bool
|
108
|
+
|
109
|
+
def keys: () -> Array[K]
|
110
|
+
|
111
|
+
alias length size
|
112
|
+
|
113
|
+
alias member? has_key?
|
114
|
+
|
115
|
+
def merge: [A, B] (*(Tash | Hash)[A, B] other_tashes_or_hashes) -> Tash[A | K, B | V]
|
116
|
+
| [A, B, C] (*(Tash | Hash)[A, B] other_tashes_or_hashes) { (K key, V oldval, B newval) -> C } -> Tash[A | K, B | V | C]
|
117
|
+
|
118
|
+
def merge!: (*(Tash | Hash)[K, V] other_tashes_or_hashes) -> self
|
119
|
+
| (*(Tash | Hash)[K, V] other_tashes_or_hashes) { (K key, V oldval, V newval) -> V } -> self
|
120
|
+
|
121
|
+
def rassoc: (V) -> [ K, V ]?
|
122
|
+
|
123
|
+
def rehash: () -> self
|
124
|
+
|
125
|
+
def reject: () { (K, V) -> boolish } -> Tash[K, V]
|
126
|
+
| () -> Enumerator[[ K, V ], Tash[K, V]]
|
127
|
+
|
128
|
+
def reject!: () { (K, V) -> boolish } -> self?
|
129
|
+
| () -> Enumerator[[ K, V ], self?]
|
130
|
+
|
131
|
+
def replace: ((Tash | Hash)[K, V]) -> self
|
132
|
+
|
133
|
+
def select: () { (K, V) -> boolish } -> Tash[K, V]
|
134
|
+
| () -> Enumerator[[ K, V ], Tash[K, V]]
|
135
|
+
|
136
|
+
def select!: () { (K, V) -> boolish } -> self?
|
137
|
+
| () -> Enumerator[[ K, V ], self?]
|
138
|
+
|
139
|
+
def shift: () -> [ K, V ]?
|
140
|
+
|
141
|
+
def size: () -> Integer
|
142
|
+
|
143
|
+
def slice: (*K) -> Tash[K, V]
|
144
|
+
|
145
|
+
alias store []=
|
146
|
+
|
147
|
+
def to_a: () -> Array[[ K, V ]]
|
148
|
+
|
149
|
+
def to_h: () -> Hash[K, V]
|
150
|
+
| [A, B] () { (K, V) -> [ A, B ] } -> Hash[A, B]
|
151
|
+
|
152
|
+
def to_hash: () -> Hash[K, V]
|
153
|
+
|
154
|
+
def to_proc: () -> ^(K) -> V?
|
155
|
+
|
156
|
+
alias to_s inspect
|
157
|
+
|
158
|
+
def transform_proc: () -> (Proc | nil)
|
159
|
+
|
160
|
+
def transform_values: () -> Enumerator[V, Tash[K, untyped]]
|
161
|
+
| [A] () { (V) -> A } -> Tash[K, A]
|
162
|
+
|
163
|
+
def transform_values!: () -> Enumerator[V, self]
|
164
|
+
| () { (V) -> V } -> self
|
165
|
+
|
166
|
+
alias update merge!
|
167
|
+
|
168
|
+
def value?: (V) -> bool
|
169
|
+
|
170
|
+
def values: () -> Array[V]
|
171
|
+
|
172
|
+
def values_at: (*K) -> Array[V?]
|
173
|
+
|
174
|
+
private
|
175
|
+
|
176
|
+
def initialize: () { (K) -> unchecked out K } -> void
|
177
|
+
end
|
178
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'tash'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
expectations.on_potential_false_positives = :nothing
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |mocks|
|
10
|
+
mocks.verify_partial_doubles = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
14
|
+
|
15
|
+
config.filter_run_when_matching :focus
|
16
|
+
|
17
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
18
|
+
|
19
|
+
config.disable_monkey_patching!
|
20
|
+
|
21
|
+
config.warnings = true
|
22
|
+
|
23
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
24
|
+
|
25
|
+
config.order = :random
|
26
|
+
Kernel.srand config.seed
|
27
|
+
end
|
28
|
+
|
29
|
+
def when_ruby_above(version)
|
30
|
+
yield if Tash.send(:current_ruby_version) > version
|
31
|
+
end
|