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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.standard.yml +6 -0
  4. data/.tool-versions +1 -1
  5. data/CHANGELOG.md +21 -0
  6. data/Gemfile +3 -5
  7. data/Gemfile.lock +79 -64
  8. data/README.md +25 -2
  9. data/Rakefile +3 -5
  10. data/lib/minitest/result_assertions.rb +48 -0
  11. data/lib/sorbet-result.rb +1 -5
  12. data/lib/typed/result.rb +199 -7
  13. data/sorbet/rbi/gems/.gitattributes +1 -0
  14. data/sorbet/rbi/gems/ast@2.4.2.rbi +1 -0
  15. data/sorbet/rbi/gems/erubi@1.13.0.rbi +150 -0
  16. data/sorbet/rbi/gems/{io-console@0.6.0.rbi → io-console@0.7.2.rbi} +1 -0
  17. data/sorbet/rbi/gems/{json@2.6.3.rbi → json@2.7.5.rbi} +168 -72
  18. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
  19. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +240 -0
  20. data/sorbet/rbi/gems/{minitest@5.18.1.rbi → minitest@5.25.1.rbi} +337 -282
  21. data/sorbet/rbi/gems/netrc@0.11.0.rbi +1 -0
  22. data/sorbet/rbi/gems/{parallel@1.23.0.rbi → parallel@1.26.3.rbi} +38 -20
  23. data/sorbet/rbi/gems/{parser@3.2.2.3.rbi → parser@3.3.5.1.rbi} +663 -2397
  24. data/sorbet/rbi/gems/prism@1.2.0.rbi +39085 -0
  25. data/sorbet/rbi/gems/psych@5.1.2.rbi +1732 -0
  26. data/sorbet/rbi/gems/{racc@1.7.1.rbi → racc@1.8.1.rbi} +37 -36
  27. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +1 -0
  28. data/sorbet/rbi/gems/{rake@13.0.6.rbi → rake@13.2.1.rbi} +79 -75
  29. data/sorbet/rbi/gems/rbi@0.2.1.rbi +4535 -0
  30. data/sorbet/rbi/gems/{regexp_parser@2.8.1.rbi → regexp_parser@2.9.2.rbi} +190 -167
  31. data/sorbet/rbi/gems/{reline@0.3.5.rbi → reline@0.5.10.rbi} +1 -0
  32. data/sorbet/rbi/gems/{rubocop-ast@1.29.0.rbi → rubocop-ast@1.33.1.rbi} +1220 -748
  33. data/sorbet/rbi/gems/rubocop-performance@1.22.1.rbi +9 -0
  34. data/sorbet/rbi/gems/rubocop-sorbet@0.7.8.rbi +9 -0
  35. data/sorbet/rbi/gems/{rubocop@1.52.1.rbi → rubocop@1.66.1.rbi} +6236 -3446
  36. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1 -0
  37. data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
  38. data/sorbet/rbi/gems/standard-custom@1.0.2.rbi +9 -0
  39. data/sorbet/rbi/gems/standard-performance@1.5.0.rbi +9 -0
  40. data/sorbet/rbi/gems/standard-sorbet@0.0.2.rbi +53 -0
  41. data/sorbet/rbi/gems/standard@1.41.1.rbi +926 -0
  42. data/sorbet/rbi/gems/stringio@3.1.1.rbi +9 -0
  43. data/sorbet/rbi/gems/{tapioca@0.11.6.rbi → tapioca@0.16.3.rbi} +937 -635
  44. data/sorbet/rbi/gems/{thor@1.2.2.rbi → thor@1.3.2.rbi} +832 -419
  45. data/sorbet/rbi/gems/{unicode-display_width@2.4.2.rbi → unicode-display_width@2.6.0.rbi} +1 -0
  46. data/sorbet/rbi/gems/{yard-sorbet@0.8.1.rbi → yard-sorbet@0.9.0.rbi} +36 -29
  47. data/sorbet/rbi/gems/{yard@0.9.34.rbi → yard@0.9.37.rbi} +431 -271
  48. data/sorbet/tapioca/config.yml +3 -12
  49. data/sorbet/tapioca/require.rb +0 -1
  50. metadata +37 -47
  51. data/.rubocop.yml +0 -33
  52. data/lib/typed/failure.rb +0 -81
  53. data/lib/typed/success.rb +0 -80
  54. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +0 -1083
  55. data/sorbet/rbi/gems/irb@1.7.0.rbi +0 -342
  56. data/sorbet/rbi/gems/rbi@0.0.16.rbi +0 -3008
  57. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -4717
  58. data/sorbet/rbi/gems/rubocop-minitest@0.31.0.rbi +0 -2528
  59. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +0 -328
  60. data/sorbet/rbi/gems/rubocop-sorbet@0.7.0.rbi +0 -1043
  61. data/sorbet/rbi/gems/spoom@1.2.1.rbi +0 -2503
  62. data/sorbet/rbi/gems/unparser@0.6.8.rbi +0 -4525
  63. data/sorbet/rbi/gems/zeitwerk@2.6.8.rbi +0 -986
@@ -1,13 +1,4 @@
1
1
  gem:
2
- # Add your `gem` command parameters here:
3
- #
4
- # exclude:
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
@@ -4,4 +4,3 @@
4
4
  require "debug"
5
5
  require "minitest/autorun"
6
6
  require "sorbet-runtime"
7
- require "zeitwerk"
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.0.0
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: 2023-06-20 00:00:00.000000000 Z
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/diff-lcs@1.5.0.rbi
68
- - sorbet/rbi/gems/io-console@0.6.0.rbi
69
- - sorbet/rbi/gems/irb@1.7.0.rbi
70
- - sorbet/rbi/gems/json@2.6.3.rbi
71
- - sorbet/rbi/gems/minitest@5.18.1.rbi
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.23.0.rbi
74
- - sorbet/rbi/gems/parser@3.2.2.3.rbi
75
- - sorbet/rbi/gems/racc@1.7.1.rbi
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.0.6.rbi
78
- - sorbet/rbi/gems/rbi@0.0.16.rbi
79
- - sorbet/rbi/gems/regexp_parser@2.8.1.rbi
80
- - sorbet/rbi/gems/reline@0.3.5.rbi
81
- - sorbet/rbi/gems/rexml@3.2.5.rbi
82
- - sorbet/rbi/gems/rubocop-ast@1.29.0.rbi
83
- - sorbet/rbi/gems/rubocop-minitest@0.31.0.rbi
84
- - sorbet/rbi/gems/rubocop-rake@0.6.0.rbi
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.2.1.rbi
89
- - sorbet/rbi/gems/tapioca@0.11.6.rbi
90
- - sorbet/rbi/gems/thor@1.2.2.rbi
91
- - sorbet/rbi/gems/unicode-display_width@2.4.2.rbi
92
- - sorbet/rbi/gems/unparser@0.6.8.rbi
93
- - sorbet/rbi/gems/yard-sorbet@0.8.1.rbi
94
- - sorbet/rbi/gems/yard@0.9.34.rbi
95
- - sorbet/rbi/gems/zeitwerk@2.6.8.rbi
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.0'
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.4.10
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