sorbet-result 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.standard.yml +6 -0
- data/.tool-versions +1 -1
- data/CHANGELOG.md +21 -0
- data/Gemfile +3 -5
- data/Gemfile.lock +79 -64
- data/README.md +25 -2
- data/Rakefile +3 -5
- data/lib/minitest/result_assertions.rb +48 -0
- data/lib/sorbet-result.rb +1 -5
- data/lib/typed/result.rb +199 -7
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +1 -0
- data/sorbet/rbi/gems/erubi@1.13.0.rbi +150 -0
- data/sorbet/rbi/gems/{io-console@0.6.0.rbi → io-console@0.7.2.rbi} +1 -0
- data/sorbet/rbi/gems/{json@2.6.3.rbi → json@2.7.5.rbi} +168 -72
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +240 -0
- data/sorbet/rbi/gems/{minitest@5.18.1.rbi → minitest@5.25.1.rbi} +337 -282
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +1 -0
- data/sorbet/rbi/gems/{parallel@1.23.0.rbi → parallel@1.26.3.rbi} +38 -20
- data/sorbet/rbi/gems/{parser@3.2.2.3.rbi → parser@3.3.5.1.rbi} +663 -2397
- data/sorbet/rbi/gems/prism@1.2.0.rbi +39085 -0
- data/sorbet/rbi/gems/psych@5.1.2.rbi +1732 -0
- data/sorbet/rbi/gems/{racc@1.7.1.rbi → racc@1.8.1.rbi} +37 -36
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +1 -0
- data/sorbet/rbi/gems/{rake@13.0.6.rbi → rake@13.2.1.rbi} +79 -75
- data/sorbet/rbi/gems/rbi@0.2.1.rbi +4535 -0
- data/sorbet/rbi/gems/{regexp_parser@2.8.1.rbi → regexp_parser@2.9.2.rbi} +190 -167
- data/sorbet/rbi/gems/{reline@0.3.5.rbi → reline@0.5.10.rbi} +1 -0
- data/sorbet/rbi/gems/{rubocop-ast@1.29.0.rbi → rubocop-ast@1.33.1.rbi} +1220 -748
- data/sorbet/rbi/gems/rubocop-performance@1.22.1.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.7.8.rbi +9 -0
- data/sorbet/rbi/gems/{rubocop@1.52.1.rbi → rubocop@1.66.1.rbi} +6236 -3446
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1 -0
- data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
- data/sorbet/rbi/gems/standard-custom@1.0.2.rbi +9 -0
- data/sorbet/rbi/gems/standard-performance@1.5.0.rbi +9 -0
- data/sorbet/rbi/gems/standard-sorbet@0.0.2.rbi +53 -0
- data/sorbet/rbi/gems/standard@1.41.1.rbi +926 -0
- data/sorbet/rbi/gems/stringio@3.1.1.rbi +9 -0
- data/sorbet/rbi/gems/{tapioca@0.11.6.rbi → tapioca@0.16.3.rbi} +937 -635
- data/sorbet/rbi/gems/{thor@1.2.2.rbi → thor@1.3.2.rbi} +832 -419
- data/sorbet/rbi/gems/{unicode-display_width@2.4.2.rbi → unicode-display_width@2.6.0.rbi} +1 -0
- data/sorbet/rbi/gems/{yard-sorbet@0.8.1.rbi → yard-sorbet@0.9.0.rbi} +36 -29
- data/sorbet/rbi/gems/{yard@0.9.34.rbi → yard@0.9.37.rbi} +431 -271
- data/sorbet/tapioca/config.yml +3 -12
- data/sorbet/tapioca/require.rb +0 -1
- metadata +37 -47
- data/.rubocop.yml +0 -33
- data/lib/typed/failure.rb +0 -81
- data/lib/typed/success.rb +0 -80
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +0 -1083
- data/sorbet/rbi/gems/irb@1.7.0.rbi +0 -342
- data/sorbet/rbi/gems/rbi@0.0.16.rbi +0 -3008
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -4717
- data/sorbet/rbi/gems/rubocop-minitest@0.31.0.rbi +0 -2528
- data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +0 -328
- data/sorbet/rbi/gems/rubocop-sorbet@0.7.0.rbi +0 -1043
- data/sorbet/rbi/gems/spoom@1.2.1.rbi +0 -2503
- data/sorbet/rbi/gems/unparser@0.6.8.rbi +0 -4525
- data/sorbet/rbi/gems/zeitwerk@2.6.8.rbi +0 -986
data/sorbet/tapioca/config.yml
CHANGED
@@ -1,13 +1,4 @@
|
|
1
1
|
gem:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# - gem_name
|
6
|
-
# doc: true
|
7
|
-
# workers: 5
|
8
|
-
dsl:
|
9
|
-
# Add your `dsl` command parameters here:
|
10
|
-
#
|
11
|
-
# exclude:
|
12
|
-
# - SomeGeneratorName
|
13
|
-
# workers: 5
|
2
|
+
exclude:
|
3
|
+
- rdoc
|
4
|
+
workers: 5
|
data/sorbet/tapioca/require.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-result
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max VelDink
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.5'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: zeitwerk
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.6'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.6'
|
41
27
|
description:
|
42
28
|
email:
|
43
29
|
- maxveldink@gmail.com
|
@@ -45,8 +31,8 @@ executables: []
|
|
45
31
|
extensions: []
|
46
32
|
extra_rdoc_files: []
|
47
33
|
files:
|
48
|
-
- ".rubocop.yml"
|
49
34
|
- ".ruby-version"
|
35
|
+
- ".standard.yml"
|
50
36
|
- ".tool-versions"
|
51
37
|
- CHANGELOG.md
|
52
38
|
- CODE_OF_CONDUCT.md
|
@@ -55,44 +41,48 @@ files:
|
|
55
41
|
- LICENSE.txt
|
56
42
|
- README.md
|
57
43
|
- Rakefile
|
44
|
+
- lib/minitest/result_assertions.rb
|
58
45
|
- lib/sorbet-result.rb
|
59
|
-
- lib/typed/failure.rb
|
60
46
|
- lib/typed/no_error_on_success_error.rb
|
61
47
|
- lib/typed/no_payload_on_failure_error.rb
|
62
48
|
- lib/typed/result.rb
|
63
|
-
- lib/typed/success.rb
|
64
49
|
- sorbet/config
|
65
50
|
- sorbet/rbi/annotations/rainbow.rbi
|
51
|
+
- sorbet/rbi/gems/.gitattributes
|
66
52
|
- sorbet/rbi/gems/ast@2.4.2.rbi
|
67
|
-
- sorbet/rbi/gems/
|
68
|
-
- sorbet/rbi/gems/io-console@0.
|
69
|
-
- sorbet/rbi/gems/
|
70
|
-
- sorbet/rbi/gems/
|
71
|
-
- sorbet/rbi/gems/
|
53
|
+
- sorbet/rbi/gems/erubi@1.13.0.rbi
|
54
|
+
- sorbet/rbi/gems/io-console@0.7.2.rbi
|
55
|
+
- sorbet/rbi/gems/json@2.7.5.rbi
|
56
|
+
- sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi
|
57
|
+
- sorbet/rbi/gems/lint_roller@1.1.0.rbi
|
58
|
+
- sorbet/rbi/gems/minitest@5.25.1.rbi
|
72
59
|
- sorbet/rbi/gems/netrc@0.11.0.rbi
|
73
|
-
- sorbet/rbi/gems/parallel@1.
|
74
|
-
- sorbet/rbi/gems/parser@3.
|
75
|
-
- sorbet/rbi/gems/
|
60
|
+
- sorbet/rbi/gems/parallel@1.26.3.rbi
|
61
|
+
- sorbet/rbi/gems/parser@3.3.5.1.rbi
|
62
|
+
- sorbet/rbi/gems/prism@1.2.0.rbi
|
63
|
+
- sorbet/rbi/gems/psych@5.1.2.rbi
|
64
|
+
- sorbet/rbi/gems/racc@1.8.1.rbi
|
76
65
|
- sorbet/rbi/gems/rainbow@3.1.1.rbi
|
77
|
-
- sorbet/rbi/gems/rake@13.
|
78
|
-
- sorbet/rbi/gems/rbi@0.
|
79
|
-
- sorbet/rbi/gems/regexp_parser@2.
|
80
|
-
- sorbet/rbi/gems/reline@0.
|
81
|
-
- sorbet/rbi/gems/
|
82
|
-
- sorbet/rbi/gems/rubocop-
|
83
|
-
- sorbet/rbi/gems/rubocop-
|
84
|
-
- sorbet/rbi/gems/rubocop
|
85
|
-
- sorbet/rbi/gems/rubocop-sorbet@0.7.0.rbi
|
86
|
-
- sorbet/rbi/gems/rubocop@1.52.1.rbi
|
66
|
+
- sorbet/rbi/gems/rake@13.2.1.rbi
|
67
|
+
- sorbet/rbi/gems/rbi@0.2.1.rbi
|
68
|
+
- sorbet/rbi/gems/regexp_parser@2.9.2.rbi
|
69
|
+
- sorbet/rbi/gems/reline@0.5.10.rbi
|
70
|
+
- sorbet/rbi/gems/rubocop-ast@1.33.1.rbi
|
71
|
+
- sorbet/rbi/gems/rubocop-performance@1.22.1.rbi
|
72
|
+
- sorbet/rbi/gems/rubocop-sorbet@0.7.8.rbi
|
73
|
+
- sorbet/rbi/gems/rubocop@1.66.1.rbi
|
87
74
|
- sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi
|
88
|
-
- sorbet/rbi/gems/spoom@1.
|
89
|
-
- sorbet/rbi/gems/
|
90
|
-
- sorbet/rbi/gems/
|
91
|
-
- sorbet/rbi/gems/
|
92
|
-
- sorbet/rbi/gems/
|
93
|
-
- sorbet/rbi/gems/
|
94
|
-
- sorbet/rbi/gems/
|
95
|
-
- sorbet/rbi/gems/
|
75
|
+
- sorbet/rbi/gems/spoom@1.5.0.rbi
|
76
|
+
- sorbet/rbi/gems/standard-custom@1.0.2.rbi
|
77
|
+
- sorbet/rbi/gems/standard-performance@1.5.0.rbi
|
78
|
+
- sorbet/rbi/gems/standard-sorbet@0.0.2.rbi
|
79
|
+
- sorbet/rbi/gems/standard@1.41.1.rbi
|
80
|
+
- sorbet/rbi/gems/stringio@3.1.1.rbi
|
81
|
+
- sorbet/rbi/gems/tapioca@0.16.3.rbi
|
82
|
+
- sorbet/rbi/gems/thor@1.3.2.rbi
|
83
|
+
- sorbet/rbi/gems/unicode-display_width@2.6.0.rbi
|
84
|
+
- sorbet/rbi/gems/yard-sorbet@0.9.0.rbi
|
85
|
+
- sorbet/rbi/gems/yard@0.9.37.rbi
|
96
86
|
- sorbet/tapioca/config.yml
|
97
87
|
- sorbet/tapioca/require.rb
|
98
88
|
homepage: https://github.com/maxveldink/sorbet-result
|
@@ -112,14 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
102
|
requirements:
|
113
103
|
- - ">="
|
114
104
|
- !ruby/object:Gem::Version
|
115
|
-
version: '3.
|
105
|
+
version: '3.1'
|
116
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
107
|
requirements:
|
118
108
|
- - ">="
|
119
109
|
- !ruby/object:Gem::Version
|
120
110
|
version: '0'
|
121
111
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
112
|
+
rubygems_version: 3.5.16
|
123
113
|
signing_key:
|
124
114
|
specification_version: 4
|
125
115
|
summary: Adds T::Result to sorbet-runtime, which is a basic, strongly-typed monad
|
data/.rubocop.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
inherit_mode:
|
2
|
-
merge:
|
3
|
-
- Exclude
|
4
|
-
|
5
|
-
require:
|
6
|
-
- rubocop-minitest
|
7
|
-
- rubocop-rake
|
8
|
-
- rubocop-sorbet
|
9
|
-
|
10
|
-
AllCops:
|
11
|
-
NewCops: enable
|
12
|
-
TargetRubyVersion: 3.0
|
13
|
-
Exclude:
|
14
|
-
- sorbet/**/*.rbi
|
15
|
-
|
16
|
-
Style/AccessorGrouping:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Style/StringLiterals:
|
20
|
-
Enabled: true
|
21
|
-
EnforcedStyle: double_quotes
|
22
|
-
|
23
|
-
Style/StringLiteralsInInterpolation:
|
24
|
-
Enabled: true
|
25
|
-
EnforcedStyle: double_quotes
|
26
|
-
|
27
|
-
Layout/LineLength:
|
28
|
-
Max: 120
|
29
|
-
|
30
|
-
Lint/UselessMethodDefinition:
|
31
|
-
Exclude:
|
32
|
-
- lib/typed/failure.rb
|
33
|
-
- lib/typed/success.rb
|
data/lib/typed/failure.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Typed
|
5
|
-
# Represents a failed result. Contains error information but no payload.
|
6
|
-
class Failure < Result
|
7
|
-
extend T::Sig
|
8
|
-
extend T::Generic
|
9
|
-
|
10
|
-
Payload = type_member { { fixed: T.noreturn } }
|
11
|
-
Error = type_member
|
12
|
-
|
13
|
-
sig { override.returns(Error) }
|
14
|
-
attr_reader :error
|
15
|
-
|
16
|
-
sig do
|
17
|
-
type_parameters(:T)
|
18
|
-
.params(error: T.type_parameter(:T))
|
19
|
-
.returns(Typed::Failure[T.type_parameter(:T)])
|
20
|
-
end
|
21
|
-
def self.new(error)
|
22
|
-
super(error)
|
23
|
-
end
|
24
|
-
|
25
|
-
sig { returns(Typed::Failure[NilClass]) }
|
26
|
-
def self.blank
|
27
|
-
new(nil)
|
28
|
-
end
|
29
|
-
|
30
|
-
sig { params(error: Error).void }
|
31
|
-
def initialize(error)
|
32
|
-
@error = error
|
33
|
-
super()
|
34
|
-
end
|
35
|
-
|
36
|
-
sig { override.returns(T::Boolean) }
|
37
|
-
def success?
|
38
|
-
false
|
39
|
-
end
|
40
|
-
|
41
|
-
sig { override.returns(T::Boolean) }
|
42
|
-
def failure?
|
43
|
-
true
|
44
|
-
end
|
45
|
-
|
46
|
-
sig { override.returns(T.noreturn) }
|
47
|
-
def payload
|
48
|
-
raise NoPayloadOnFailureError
|
49
|
-
end
|
50
|
-
|
51
|
-
sig do
|
52
|
-
override
|
53
|
-
.type_parameters(:U, :T)
|
54
|
-
.params(_block: T.proc.params(arg0: Payload).returns(Result[T.type_parameter(:U), T.type_parameter(:T)]))
|
55
|
-
.returns(Result[T.type_parameter(:U), Error])
|
56
|
-
end
|
57
|
-
def and_then(&_block)
|
58
|
-
self
|
59
|
-
end
|
60
|
-
|
61
|
-
sig do
|
62
|
-
override
|
63
|
-
.params(block: T.proc.params(arg0: Error).void)
|
64
|
-
.returns(T.self_type)
|
65
|
-
end
|
66
|
-
def on_error(&block)
|
67
|
-
block.call(error)
|
68
|
-
self
|
69
|
-
end
|
70
|
-
|
71
|
-
sig do
|
72
|
-
override
|
73
|
-
.type_parameters(:Fallback)
|
74
|
-
.params(value: T.type_parameter(:Fallback))
|
75
|
-
.returns(T.any(Payload, T.type_parameter(:Fallback)))
|
76
|
-
end
|
77
|
-
def payload_or(value)
|
78
|
-
value
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
data/lib/typed/success.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Typed
|
5
|
-
# Represents a successful result. Contains a payload and no error information.
|
6
|
-
class Success < Result
|
7
|
-
extend T::Sig
|
8
|
-
extend T::Generic
|
9
|
-
|
10
|
-
Payload = type_member
|
11
|
-
Error = type_member { { fixed: T.noreturn } }
|
12
|
-
|
13
|
-
sig { override.returns(Payload) }
|
14
|
-
attr_reader :payload
|
15
|
-
|
16
|
-
sig do
|
17
|
-
type_parameters(:T)
|
18
|
-
.params(payload: T.type_parameter(:T))
|
19
|
-
.returns(Typed::Success[T.type_parameter(:T)])
|
20
|
-
end
|
21
|
-
def self.new(payload)
|
22
|
-
super(payload)
|
23
|
-
end
|
24
|
-
|
25
|
-
sig { returns(Typed::Success[NilClass]) }
|
26
|
-
def self.blank
|
27
|
-
new(nil)
|
28
|
-
end
|
29
|
-
|
30
|
-
sig { params(payload: Payload).void }
|
31
|
-
def initialize(payload)
|
32
|
-
@payload = payload
|
33
|
-
super()
|
34
|
-
end
|
35
|
-
|
36
|
-
sig { override.returns(T::Boolean) }
|
37
|
-
def success?
|
38
|
-
true
|
39
|
-
end
|
40
|
-
|
41
|
-
sig { override.returns(T::Boolean) }
|
42
|
-
def failure?
|
43
|
-
false
|
44
|
-
end
|
45
|
-
|
46
|
-
sig { override.returns(T.noreturn) }
|
47
|
-
def error
|
48
|
-
raise NoErrorOnSuccessError
|
49
|
-
end
|
50
|
-
|
51
|
-
sig do
|
52
|
-
override
|
53
|
-
.type_parameters(:U, :T)
|
54
|
-
.params(block: T.proc.params(arg0: Payload).returns(Result[T.type_parameter(:U), T.type_parameter(:T)]))
|
55
|
-
.returns(Result[T.type_parameter(:U), T.type_parameter(:T)])
|
56
|
-
end
|
57
|
-
def and_then(&block)
|
58
|
-
block.call(payload)
|
59
|
-
end
|
60
|
-
|
61
|
-
sig do
|
62
|
-
override
|
63
|
-
.params(_block: T.proc.params(arg0: Error).void)
|
64
|
-
.returns(T.self_type)
|
65
|
-
end
|
66
|
-
def on_error(&_block)
|
67
|
-
self
|
68
|
-
end
|
69
|
-
|
70
|
-
sig do
|
71
|
-
override
|
72
|
-
.type_parameters(:Fallback)
|
73
|
-
.params(_value: T.type_parameter(:Fallback))
|
74
|
-
.returns(T.any(Payload, T.type_parameter(:Fallback)))
|
75
|
-
end
|
76
|
-
def payload_or(_value)
|
77
|
-
payload
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|