linguadata 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/.idea/linguadata.iml +53 -45
- data/.idea/misc.xml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +21 -1
- data/README.md +2 -0
- data/Rakefile +5 -1
- data/lib/linguadata/version.rb +1 -1
- data/lib/linguadata.rb +99 -31
- data/sig/linguadata.rbs +19 -8
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19c3b2ee58bec38f656da894f3451359003d5ffa3c1eb5d88f04d785045ffe03
|
|
4
|
+
data.tar.gz: 90d39bda8a6e4d4b3d5471ab95da02d93a7456370f65f05dc7b414db12444ca2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a61866d502824d73ff82286d4187f79a2db950ececa50482c5b722db08bd8c04c3e730d4f28a95d5dc610c80271ded81c70ce9594c22210c0e8a17dfdaf51a3
|
|
7
|
+
data.tar.gz: 7c0c2a3931d87cf6e4baf36daa792055411dbb6642b557629f33b4ead1f296deb3b4f65158814600d52924558322046b0a15ad0a831e5af74c19c865919b5714
|
data/.idea/linguadata.iml
CHANGED
|
@@ -8,74 +8,81 @@
|
|
|
8
8
|
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
|
9
9
|
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
10
10
|
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
|
11
|
+
<excludeFolder url="file://$MODULE_DIR$/coverage" />
|
|
12
|
+
<excludeFolder url="file://$MODULE_DIR$/pkg" />
|
|
11
13
|
</content>
|
|
12
14
|
<orderEntry type="jdk" jdkName="rbenv: 3.2.2" jdkType="RUBY_SDK" />
|
|
13
15
|
<orderEntry type="sourceFolder" forTests="false" />
|
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="activesupport (v7.1.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 3.2.2) [gem]" level="application" />
|
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.1.4, rbenv: 3.2.2) [gem]" level="application" />
|
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v7.1.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.1.4, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
17
19
|
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.4.10, rbenv: 3.2.2) [gem]" level="application" />
|
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.2.2, rbenv: 3.2.2) [gem]" level="application" />
|
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.4.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="csv (v3.2.7, rbenv: 3.2.2) [gem]" level="application" />
|
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, rbenv: 3.2.2) [gem]" level="application" />
|
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.2.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.4.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="csv (v3.2.7, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
22
24
|
<orderEntry type="library" scope="PROVIDED" name="drb (v2.1.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.16.3, rbenv: 3.2.2) [gem]" level="application" />
|
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="fileutils (v1.7.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.16.3, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="fileutils (v1.7.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
26
28
|
<orderEntry type="library" scope="PROVIDED" name="json (v2.6.3, rbenv: 3.2.2) [gem]" level="application" />
|
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.3, rbenv: 3.2.2) [gem]" level="application" />
|
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, rbenv: 3.2.2) [gem]" level="application" />
|
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="listen (v3.8.0, rbenv: 3.2.2) [gem]" level="application" />
|
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.3, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="listen (v3.8.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
30
32
|
<orderEntry type="library" scope="PROVIDED" name="logger (v1.5.3, rbenv: 3.2.2) [gem]" level="application" />
|
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.20.0, rbenv: 3.2.2) [gem]" level="application" />
|
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
35
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.20.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="mutant (v0.11.24, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="mutant-license (v0.1.1.2.0526686720282068589522783053343094335875.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="mutant-rspec (v0.11.24, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.23.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v3.2.2.4, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="racc (v1.7.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
36
41
|
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 3.2.2) [gem]" level="application" />
|
|
37
|
-
<orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.11.2, rbenv: 3.2.2) [gem]" level="application" />
|
|
38
|
-
<orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.10.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
39
|
-
<orderEntry type="library" scope="PROVIDED" name="rbs (v3.2.2, rbenv: 3.2.2) [gem]" level="application" />
|
|
40
|
-
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.8.2, rbenv: 3.2.2) [gem]" level="application" />
|
|
41
|
-
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.6, rbenv: 3.2.2) [gem]" level="application" />
|
|
42
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, rbenv: 3.2.2) [gem]" level="application" />
|
|
43
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.2, rbenv: 3.2.2) [gem]" level="application" />
|
|
44
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.3, rbenv: 3.2.2) [gem]" level="application" />
|
|
45
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.6, rbenv: 3.2.2) [gem]" level="application" />
|
|
46
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
47
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.56.4, rbenv: 3.2.2) [gem]" level="application" />
|
|
48
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.29.0, rbenv: 3.2.2) [gem]" level="application" />
|
|
49
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.19.1, rbenv: 3.2.2) [gem]" level="application" />
|
|
50
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, rbenv: 3.2.2) [gem]" level="application" />
|
|
51
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
52
|
-
<orderEntry type="library" scope="PROVIDED" name="standard
|
|
53
|
-
<orderEntry type="library" scope="PROVIDED" name="standard-
|
|
54
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
55
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
56
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
57
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
58
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.11.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.10.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="rbs (v3.2.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
45
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.8.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.6, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
47
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
49
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.3, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
50
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.6, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
51
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
52
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.56.4, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
53
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.29.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
54
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.19.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
55
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
56
|
+
<orderEntry type="library" scope="PROVIDED" name="sorbet-runtime (v0.5.11120, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
57
|
+
<orderEntry type="library" scope="PROVIDED" name="standard (v1.31.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
58
|
+
<orderEntry type="library" scope="PROVIDED" name="standard-custom (v1.0.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
59
|
+
<orderEntry type="library" scope="PROVIDED" name="standard-performance (v1.2.1, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
60
|
+
<orderEntry type="library" scope="PROVIDED" name="steep (v1.5.3, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
61
|
+
<orderEntry type="library" scope="PROVIDED" name="strscan (v3.0.7, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
62
|
+
<orderEntry type="library" scope="PROVIDED" name="terminal-table (v3.0.2, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
63
|
+
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
64
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.5.0, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
65
|
+
<orderEntry type="library" scope="PROVIDED" name="unparser (v0.6.10, rbenv: 3.2.2, linguadata) [gem]" level="application" />
|
|
59
66
|
</component>
|
|
60
67
|
<component name="RakeTasksCache">
|
|
61
68
|
<option name="myRootTask">
|
|
62
69
|
<RakeTaskImpl id="rake">
|
|
63
70
|
<subtasks>
|
|
64
|
-
<RakeTaskImpl description="Build linguadata-0.1.
|
|
71
|
+
<RakeTaskImpl description="Build linguadata-0.1.2.gem into the pkg directory" fullCommand="build" id="build" />
|
|
65
72
|
<RakeTaskImpl id="build">
|
|
66
73
|
<subtasks>
|
|
67
|
-
<RakeTaskImpl description="Generate SHA512 checksum if linguadata-0.1.
|
|
74
|
+
<RakeTaskImpl description="Generate SHA512 checksum if linguadata-0.1.2.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
|
68
75
|
</subtasks>
|
|
69
76
|
</RakeTaskImpl>
|
|
70
77
|
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
|
71
78
|
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
|
72
|
-
<RakeTaskImpl description="Build and install linguadata-0.1.
|
|
79
|
+
<RakeTaskImpl description="Build and install linguadata-0.1.2.gem into system gems" fullCommand="install" id="install" />
|
|
73
80
|
<RakeTaskImpl id="install">
|
|
74
81
|
<subtasks>
|
|
75
|
-
<RakeTaskImpl description="Build and install linguadata-0.1.
|
|
82
|
+
<RakeTaskImpl description="Build and install linguadata-0.1.2.gem into system gems without network access" fullCommand="install:local" id="local" />
|
|
76
83
|
</subtasks>
|
|
77
84
|
</RakeTaskImpl>
|
|
78
|
-
<RakeTaskImpl description="Create tag v0.1.
|
|
85
|
+
<RakeTaskImpl description="Create tag v0.1.2 and build and push linguadata-0.1.2.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
|
79
86
|
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
|
80
87
|
<RakeTaskImpl description="Lint with the Standard Ruby style guide" fullCommand="standard" id="standard" />
|
|
81
88
|
<RakeTaskImpl id="standard">
|
|
@@ -93,6 +100,7 @@
|
|
|
93
100
|
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
|
94
101
|
</subtasks>
|
|
95
102
|
</RakeTaskImpl>
|
|
103
|
+
<RakeTaskImpl description="" fullCommand="typecheck" id="typecheck" />
|
|
96
104
|
</subtasks>
|
|
97
105
|
</RakeTaskImpl>
|
|
98
106
|
</option>
|
data/.idea/misc.xml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
linguadata (0.1.
|
|
4
|
+
linguadata (0.1.3)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://oss:7Cp4pNQG3WbtluEGXnLC2QmucJ17q7Zw@gem.mutant.dev/
|
|
8
|
+
specs:
|
|
9
|
+
mutant-license (0.1.1.2.0526686720282068589522783053343094335875.0)
|
|
5
10
|
|
|
6
11
|
GEM
|
|
7
12
|
remote: https://rubygems.org/
|
|
@@ -37,6 +42,15 @@ GEM
|
|
|
37
42
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
38
43
|
logger (1.5.3)
|
|
39
44
|
minitest (5.20.0)
|
|
45
|
+
mutant (0.11.24)
|
|
46
|
+
diff-lcs (~> 1.3)
|
|
47
|
+
parser (~> 3.2.2, >= 3.2.2.4)
|
|
48
|
+
regexp_parser (~> 2.8.2)
|
|
49
|
+
sorbet-runtime (~> 0.5.0)
|
|
50
|
+
unparser (~> 0.6.9)
|
|
51
|
+
mutant-rspec (0.11.24)
|
|
52
|
+
mutant (= 0.11.24)
|
|
53
|
+
rspec-core (>= 3.8.0, < 4.0.0)
|
|
40
54
|
mutex_m (0.1.2)
|
|
41
55
|
parallel (1.23.0)
|
|
42
56
|
parser (3.2.2.4)
|
|
@@ -84,6 +98,7 @@ GEM
|
|
|
84
98
|
ruby-progressbar (1.13.0)
|
|
85
99
|
ruby2_keywords (0.0.5)
|
|
86
100
|
securerandom (0.2.2)
|
|
101
|
+
sorbet-runtime (0.5.11120)
|
|
87
102
|
standard (1.31.2)
|
|
88
103
|
language_server-protocol (~> 3.17.0.2)
|
|
89
104
|
lint_roller (~> 1.0)
|
|
@@ -117,6 +132,9 @@ GEM
|
|
|
117
132
|
tzinfo (2.0.6)
|
|
118
133
|
concurrent-ruby (~> 1.0)
|
|
119
134
|
unicode-display_width (2.5.0)
|
|
135
|
+
unparser (0.6.10)
|
|
136
|
+
diff-lcs (~> 1.3)
|
|
137
|
+
parser (>= 3.2.2.4)
|
|
120
138
|
|
|
121
139
|
PLATFORMS
|
|
122
140
|
arm64-darwin-23
|
|
@@ -124,6 +142,8 @@ PLATFORMS
|
|
|
124
142
|
|
|
125
143
|
DEPENDENCIES
|
|
126
144
|
linguadata!
|
|
145
|
+
mutant-license!
|
|
146
|
+
mutant-rspec
|
|
127
147
|
rake
|
|
128
148
|
rbs
|
|
129
149
|
rspec
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/linguadata/version.rb
CHANGED
data/lib/linguadata.rb
CHANGED
|
@@ -5,21 +5,31 @@ require_relative "linguadata/version"
|
|
|
5
5
|
module Linguadata
|
|
6
6
|
module Option
|
|
7
7
|
class Some < Data.define(:value)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def map(&block) = Some[block.call(value)]
|
|
8
|
+
alias_method :unwrap, :value
|
|
11
9
|
|
|
12
10
|
def some? = true
|
|
13
11
|
|
|
14
12
|
def none? = false
|
|
15
13
|
|
|
16
|
-
def unwrap_or_else(&_block) = value
|
|
17
|
-
|
|
18
14
|
def unwrap_or(_other) = value
|
|
19
15
|
|
|
20
|
-
def
|
|
16
|
+
def unwrap_or_else(&block)
|
|
17
|
+
raise RequiredBlockError if block.nil?
|
|
18
|
+
value
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def map(&block)
|
|
22
|
+
raise RequiredBlockError if block.nil?
|
|
23
|
+
Some[block.call(value)]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def and_then(&block)
|
|
27
|
+
raise RequiredBlockError if block.nil?
|
|
28
|
+
block.call(value)
|
|
29
|
+
end
|
|
21
30
|
|
|
22
31
|
def filter(&block)
|
|
32
|
+
raise RequiredBlockError if block.nil?
|
|
23
33
|
if block.call(value)
|
|
24
34
|
self
|
|
25
35
|
else
|
|
@@ -29,26 +39,38 @@ module Linguadata
|
|
|
29
39
|
end
|
|
30
40
|
|
|
31
41
|
class None < Data.define
|
|
32
|
-
def value = raise
|
|
33
|
-
|
|
34
|
-
def unwrap = value
|
|
42
|
+
def value = raise NoValueError
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
alias_method :unwrap, :value
|
|
37
45
|
|
|
38
46
|
def some? = false
|
|
39
47
|
|
|
40
48
|
def none? = true
|
|
41
49
|
|
|
42
|
-
def unwrap_or_else(&block) = block.call
|
|
43
|
-
|
|
44
50
|
def unwrap_or(other) = other
|
|
45
51
|
|
|
46
|
-
def
|
|
52
|
+
def unwrap_or_else(&block)
|
|
53
|
+
raise RequiredBlockError if block.nil?
|
|
54
|
+
block.call
|
|
55
|
+
end
|
|
47
56
|
|
|
48
|
-
def
|
|
57
|
+
def map(&block)
|
|
58
|
+
raise RequiredBlockError if block.nil?
|
|
59
|
+
self
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def and_then(&block)
|
|
63
|
+
raise RequiredBlockError if block.nil?
|
|
64
|
+
self
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def filter(&block)
|
|
68
|
+
raise RequiredBlockError if block.nil?
|
|
69
|
+
self
|
|
70
|
+
end
|
|
49
71
|
end
|
|
50
72
|
|
|
51
|
-
def from_nillable(value)
|
|
73
|
+
def self.from_nillable(value)
|
|
52
74
|
case value
|
|
53
75
|
in nil
|
|
54
76
|
None[]
|
|
@@ -56,15 +78,20 @@ module Linguadata
|
|
|
56
78
|
Some[value]
|
|
57
79
|
end
|
|
58
80
|
end
|
|
81
|
+
|
|
82
|
+
class NoValueError < StandardError
|
|
83
|
+
def initialize(_msg = "Attempted to access a value from 'None', which does not hold any value.")
|
|
84
|
+
super
|
|
85
|
+
end
|
|
86
|
+
end
|
|
59
87
|
end
|
|
60
88
|
|
|
61
89
|
module Result
|
|
62
90
|
class Success < Data.define(:value)
|
|
63
|
-
def error = raise
|
|
91
|
+
def error = raise NoErrorInSuccessError
|
|
64
92
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def unwrap_failure = error
|
|
93
|
+
alias_method :unwrap, :value
|
|
94
|
+
alias_method :unwrap_failure, :error
|
|
68
95
|
|
|
69
96
|
def success? = true
|
|
70
97
|
|
|
@@ -74,21 +101,32 @@ module Linguadata
|
|
|
74
101
|
|
|
75
102
|
def failure = Option::None[]
|
|
76
103
|
|
|
77
|
-
def map(&block)
|
|
104
|
+
def map(&block)
|
|
105
|
+
raise RequiredBlockError if block.nil?
|
|
106
|
+
Success[block.call(value)]
|
|
107
|
+
end
|
|
78
108
|
|
|
79
|
-
def map_failure(&
|
|
109
|
+
def map_failure(&block)
|
|
110
|
+
raise RequiredBlockError if block.nil?
|
|
111
|
+
self
|
|
112
|
+
end
|
|
80
113
|
|
|
81
|
-
def
|
|
114
|
+
def and_then(&block)
|
|
115
|
+
raise RequiredBlockError if block.nil?
|
|
116
|
+
block.call(value)
|
|
117
|
+
end
|
|
82
118
|
|
|
83
|
-
def
|
|
119
|
+
def or_else(&block)
|
|
120
|
+
raise RequiredBlockError if block.nil?
|
|
121
|
+
self
|
|
122
|
+
end
|
|
84
123
|
end
|
|
85
124
|
|
|
86
125
|
class Failure < Data.define(:error)
|
|
87
|
-
def value = raise
|
|
126
|
+
def value = raise NoValueInFailureError
|
|
88
127
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def unwrap_failure = error
|
|
128
|
+
alias_method :unwrap, :value
|
|
129
|
+
alias_method :unwrap_failure, :error
|
|
92
130
|
|
|
93
131
|
def success? = false
|
|
94
132
|
|
|
@@ -98,13 +136,43 @@ module Linguadata
|
|
|
98
136
|
|
|
99
137
|
def failure = Option::Some[error]
|
|
100
138
|
|
|
101
|
-
def map(&
|
|
139
|
+
def map(&block)
|
|
140
|
+
raise RequiredBlockError if block.nil?
|
|
141
|
+
self
|
|
142
|
+
end
|
|
102
143
|
|
|
103
|
-
def map_failure(&block)
|
|
144
|
+
def map_failure(&block)
|
|
145
|
+
raise RequiredBlockError if block.nil?
|
|
146
|
+
Failure[block.call(error)]
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def and_then(&block)
|
|
150
|
+
raise RequiredBlockError if block.nil?
|
|
151
|
+
self
|
|
152
|
+
end
|
|
104
153
|
|
|
105
|
-
def or_else(&block)
|
|
154
|
+
def or_else(&block)
|
|
155
|
+
raise RequiredBlockError if block.nil?
|
|
156
|
+
block.call(error)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
class NoErrorInSuccessError < StandardError
|
|
161
|
+
def initialize(_msg = "Attempted to access an error from 'Success', which represents a successful outcome without errors.")
|
|
162
|
+
super
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
class NoValueInFailureError < StandardError
|
|
167
|
+
def initialize(_msg = "Attempted to access a value from 'Failure', which only contains an error.")
|
|
168
|
+
super
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
106
172
|
|
|
107
|
-
|
|
173
|
+
class RequiredBlockError < ArgumentError
|
|
174
|
+
def initialize(_msg = "A block was required but not passed")
|
|
175
|
+
super
|
|
108
176
|
end
|
|
109
177
|
end
|
|
110
178
|
end
|
data/sig/linguadata.rbs
CHANGED
|
@@ -37,24 +37,27 @@ module Linguadata
|
|
|
37
37
|
interface _Option[out T]
|
|
38
38
|
def value: () -> T
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
alias unwrap value
|
|
41
41
|
|
|
42
42
|
def some?: () -> bool
|
|
43
43
|
|
|
44
44
|
def none?: () -> bool
|
|
45
45
|
|
|
46
|
-
def map: [U] { (T) -> U } -> option[U]
|
|
47
|
-
|
|
48
46
|
def unwrap_or: [U] (U) -> (T | U)
|
|
49
47
|
|
|
50
48
|
def unwrap_or_else: [U] { () -> U } -> (T | U)
|
|
51
49
|
|
|
50
|
+
def map: [U] { (T) -> U } -> option[U]
|
|
51
|
+
|
|
52
52
|
def and_then: [U] { (T) -> option[U] } -> option[U]
|
|
53
53
|
|
|
54
54
|
def filter: { (T) -> bool } -> option[T]
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
def from_nillable: [T] (T? value) -> option[T]
|
|
57
|
+
def self.from_nillable: [T] (T? value) -> option[T]
|
|
58
|
+
|
|
59
|
+
class NoValueError < StandardError
|
|
60
|
+
end
|
|
58
61
|
end
|
|
59
62
|
|
|
60
63
|
module Result
|
|
@@ -81,9 +84,8 @@ module Linguadata
|
|
|
81
84
|
|
|
82
85
|
def error: () -> E
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def unwrap_failure: () -> E
|
|
87
|
+
alias unwrap value
|
|
88
|
+
alias unwrap_failure error
|
|
87
89
|
|
|
88
90
|
def success?: () -> bool
|
|
89
91
|
|
|
@@ -97,9 +99,18 @@ module Linguadata
|
|
|
97
99
|
|
|
98
100
|
def map_failure: [F] { (E) -> F } -> result[T, F]
|
|
99
101
|
|
|
102
|
+
def and_then: [U, F] { (T) -> result[U, F] } -> result[U, E | F]
|
|
103
|
+
|
|
100
104
|
def or_else: [U, F] { (E) -> result[U, F] } -> result[T | U, F]
|
|
105
|
+
end
|
|
101
106
|
|
|
102
|
-
|
|
107
|
+
class NoErrorInSuccessError < StandardError
|
|
103
108
|
end
|
|
109
|
+
|
|
110
|
+
class NoValueInFailureError < StandardError
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class RequiredBlockError < StandardError
|
|
104
115
|
end
|
|
105
116
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: linguadata
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Pechersky
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Bringing Rust's Result and Option types to Ruby, using the Data class
|
|
14
14
|
introduced in Ruby 3.2
|
|
@@ -22,6 +22,7 @@ files:
|
|
|
22
22
|
- ".idea/copyright/profiles_settings.xml"
|
|
23
23
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
|
24
24
|
- ".idea/linguadata.iml"
|
|
25
|
+
- ".idea/misc.xml"
|
|
25
26
|
- ".idea/modules.xml"
|
|
26
27
|
- ".idea/vcs.xml"
|
|
27
28
|
- ".rspec"
|