sorbet-result 1.1.0 → 1.2.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.standard.yml +1 -1
  4. data/.tool-versions +1 -1
  5. data/CHANGELOG.md +11 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +52 -57
  8. data/README.md +3 -3
  9. data/lib/typed/result.rb +32 -2
  10. data/sorbet/rbi/gems/ast@2.4.2.rbi +1 -0
  11. data/sorbet/rbi/gems/{erubi@1.12.0.rbi → erubi@1.13.0.rbi} +20 -15
  12. data/sorbet/rbi/gems/io-console@0.7.2.rbi +1 -0
  13. data/sorbet/rbi/gems/{json@2.7.1.rbi → json@2.7.5.rbi} +148 -72
  14. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +1 -0
  15. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +1 -0
  16. data/sorbet/rbi/gems/{minitest@5.22.2.rbi → minitest@5.25.1.rbi} +252 -241
  17. data/sorbet/rbi/gems/netrc@0.11.0.rbi +1 -0
  18. data/sorbet/rbi/gems/{parallel@1.24.0.rbi → parallel@1.26.3.rbi} +32 -21
  19. data/sorbet/rbi/gems/{parser@3.3.0.5.rbi → parser@3.3.5.1.rbi} +233 -186
  20. data/sorbet/rbi/gems/prism@1.2.0.rbi +39085 -0
  21. data/sorbet/rbi/gems/psych@5.1.2.rbi +1 -0
  22. data/sorbet/rbi/gems/{racc@1.7.3.rbi → racc@1.8.1.rbi} +38 -33
  23. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +1 -0
  24. data/sorbet/rbi/gems/{rake@13.1.0.rbi → rake@13.2.1.rbi} +56 -55
  25. data/sorbet/rbi/gems/rbi@0.2.1.rbi +4535 -0
  26. data/sorbet/rbi/gems/{regexp_parser@2.9.0.rbi → regexp_parser@2.9.2.rbi} +3 -2
  27. data/sorbet/rbi/gems/{reline@0.4.2.rbi → reline@0.5.10.rbi} +1 -0
  28. data/sorbet/rbi/gems/{rubocop-ast@1.30.0.rbi → rubocop-ast@1.33.1.rbi} +1143 -671
  29. data/sorbet/rbi/gems/{rubocop-performance@1.20.2.rbi → rubocop-performance@1.22.1.rbi} +1 -0
  30. data/sorbet/rbi/gems/{rubocop-sorbet@0.7.7.rbi → rubocop-sorbet@0.7.8.rbi} +1 -0
  31. data/sorbet/rbi/gems/{rubocop@1.60.2.rbi → rubocop@1.66.1.rbi} +3312 -2415
  32. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1 -0
  33. data/sorbet/rbi/gems/{spoom@1.2.4.rbi → spoom@1.5.0.rbi} +2009 -854
  34. data/sorbet/rbi/gems/standard-custom@1.0.2.rbi +1 -0
  35. data/sorbet/rbi/gems/{standard-performance@1.3.1.rbi → standard-performance@1.5.0.rbi} +1 -0
  36. data/sorbet/rbi/gems/standard-sorbet@0.0.2.rbi +1 -0
  37. data/sorbet/rbi/gems/{standard@1.34.0.rbi → standard@1.41.1.rbi} +171 -95
  38. data/sorbet/rbi/gems/{stringio@3.1.0.rbi → stringio@3.1.1.rbi} +1 -0
  39. data/sorbet/rbi/gems/{tapioca@0.12.0.rbi → tapioca@0.16.3.rbi} +357 -257
  40. data/sorbet/rbi/gems/{thor@1.3.0.rbi → thor@1.3.2.rbi} +114 -81
  41. data/sorbet/rbi/gems/{unicode-display_width@2.5.0.rbi → unicode-display_width@2.6.0.rbi} +1 -0
  42. data/sorbet/rbi/gems/{yard-sorbet@0.8.1.rbi → yard-sorbet@0.9.0.rbi} +36 -29
  43. data/sorbet/rbi/gems/{yard@0.9.34.rbi → yard@0.9.37.rbi} +430 -270
  44. metadata +28 -45
  45. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +0 -951
  46. data/sorbet/rbi/gems/prism@0.24.0.rbi +0 -31040
  47. data/sorbet/rbi/gems/rbi@0.1.9.rbi +0 -3006
  48. data/sorbet/rbi/gems/rexml@3.2.6.rbi +0 -4781
  49. data/sorbet/rbi/gems/syntax_tree@6.2.0.rbi +0 -23133
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94d11199cfc745364d1c1163b60f8a1602699f136f5c6522dfa7a81f64d6f8b1
4
- data.tar.gz: b867a4439f5a0e5f8335848c42599563149b950a42e54495cbbe1c38b8d4c60d
3
+ metadata.gz: 62795733b699fe9adec850e9584a6c45c47e6fa00daa93cb93221a43ca16b131
4
+ data.tar.gz: 3b0f4ef2e5fc20e61e88724dc6e6637f254f41ec6394b802896f30861c9a40cb
5
5
  SHA512:
6
- metadata.gz: 73a6915ad1ca43e1bc729f4be2d0b7bec3c5dcacce072e96074b0d8ce98b9033ffcbdc254b743e10e5156bac08d418d912f45ea50f83c571774c3419f449f6e9
7
- data.tar.gz: 18d8c8f3921cb4d60fde19d8270281f67de8d39aecb57830b8eb6c79e96fdfe5ac18b3ca056e7c265ede393ba91e180d078b9b0aa9396ff4a92f917b26d8819f
6
+ metadata.gz: 59395f384a03d978f128695fc2cf9c1b79a34b91e0c0aeae0e995b9a3ecc440901ff599112d14d06cab99a92cd0dd82ff8831d7d852255ae9ed5f872a14cc17f
7
+ data.tar.gz: d536a970dc7c60490c6a106178c1e32ef61cfb816d46405fb389dd62d43e0f5d8ac1e7b6a7097aa73b225d4752ab702bc75bafe25b3f365ba08f7d67c1137e75
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.3.5
data/.standard.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  parallel: true
2
- ruby_version: 3.0
2
+ ruby_version: 3.1
3
3
  ignore:
4
4
  - 'vendor/**/*'
5
5
  plugins:
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.3.0
1
+ ruby 3.3.5
data/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.0] - 2024-11-03
10
+
11
+ ### Added
12
+
13
+ - Add `Typed::Success(payload)` and `Typed::Failure(error)` convenience method (no more `.new`-ing!)
14
+ - Add `Typed::Success#==` and `Typed::Failure#==` implementations
15
+
16
+ ### Removed
17
+
18
+ - **POTENTIALLY BREAKING** Remove support for Ruby < 3.1.
19
+
9
20
  ## [1.1.0] - 2024-02-21
10
21
 
11
22
  ### Added
data/Gemfile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in activerecord-ejection_seat.gemspec
5
+ # Specify your gem's dependencies in sorbet-result.gemspec
6
6
  gemspec
7
7
 
8
8
  group :development do
data/Gemfile.lock CHANGED
@@ -1,111 +1,106 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sorbet-result (1.1.0)
4
+ sorbet-result (1.2.0)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- debug (1.9.1)
11
+ debug (1.9.2)
12
12
  irb (~> 1.10)
13
13
  reline (>= 0.3.8)
14
- erubi (1.12.0)
14
+ erubi (1.13.0)
15
15
  io-console (0.7.2)
16
- irb (1.11.2)
17
- rdoc
16
+ irb (1.14.1)
17
+ rdoc (>= 4.0.0)
18
18
  reline (>= 0.4.2)
19
- json (2.7.1)
19
+ json (2.7.5)
20
20
  language_server-protocol (3.17.0.3)
21
21
  lint_roller (1.1.0)
22
- minitest (5.22.2)
22
+ minitest (5.25.1)
23
23
  netrc (0.11.0)
24
- parallel (1.24.0)
25
- parser (3.3.0.5)
24
+ parallel (1.26.3)
25
+ parser (3.3.5.1)
26
26
  ast (~> 2.4.1)
27
27
  racc
28
- prettier_print (1.2.1)
29
- prism (0.24.0)
28
+ prism (1.2.0)
30
29
  psych (5.1.2)
31
30
  stringio
32
- racc (1.7.3)
31
+ racc (1.8.1)
33
32
  rainbow (3.1.1)
34
- rake (13.1.0)
35
- rbi (0.1.9)
36
- prism (>= 0.18.0, < 0.25)
33
+ rake (13.2.1)
34
+ rbi (0.2.1)
35
+ prism (~> 1.0)
37
36
  sorbet-runtime (>= 0.5.9204)
38
- rdoc (6.6.2)
37
+ rdoc (6.7.0)
39
38
  psych (>= 4.0.0)
40
- regexp_parser (2.9.0)
41
- reline (0.4.2)
39
+ regexp_parser (2.9.2)
40
+ reline (0.5.10)
42
41
  io-console (~> 0.5)
43
- rexml (3.2.6)
44
- rubocop (1.60.2)
42
+ rubocop (1.66.1)
45
43
  json (~> 2.3)
46
44
  language_server-protocol (>= 3.17.0)
47
45
  parallel (~> 1.10)
48
46
  parser (>= 3.3.0.2)
49
47
  rainbow (>= 2.2.2, < 4.0)
50
- regexp_parser (>= 1.8, < 3.0)
51
- rexml (>= 3.2.5, < 4.0)
52
- rubocop-ast (>= 1.30.0, < 2.0)
48
+ regexp_parser (>= 2.4, < 3.0)
49
+ rubocop-ast (>= 1.32.2, < 2.0)
53
50
  ruby-progressbar (~> 1.7)
54
51
  unicode-display_width (>= 2.4.0, < 3.0)
55
- rubocop-ast (1.30.0)
56
- parser (>= 3.2.1.0)
57
- rubocop-performance (1.20.2)
52
+ rubocop-ast (1.33.1)
53
+ parser (>= 3.3.1.0)
54
+ rubocop-performance (1.22.1)
58
55
  rubocop (>= 1.48.1, < 2.0)
59
- rubocop-ast (>= 1.30.0, < 2.0)
60
- rubocop-sorbet (0.7.7)
56
+ rubocop-ast (>= 1.31.1, < 2.0)
57
+ rubocop-sorbet (0.7.8)
61
58
  rubocop (>= 0.90.0)
62
59
  ruby-progressbar (1.13.0)
63
- sorbet (0.5.11262)
64
- sorbet-static (= 0.5.11262)
65
- sorbet-runtime (0.5.11262)
66
- sorbet-static (0.5.11262-universal-darwin)
67
- sorbet-static (0.5.11262-x86_64-linux)
68
- sorbet-static-and-runtime (0.5.11262)
69
- sorbet (= 0.5.11262)
70
- sorbet-runtime (= 0.5.11262)
71
- spoom (1.2.4)
60
+ sorbet (0.5.11633)
61
+ sorbet-static (= 0.5.11633)
62
+ sorbet-runtime (0.5.11633)
63
+ sorbet-static (0.5.11633-universal-darwin)
64
+ sorbet-static (0.5.11633-x86_64-linux)
65
+ sorbet-static-and-runtime (0.5.11633)
66
+ sorbet (= 0.5.11633)
67
+ sorbet-runtime (= 0.5.11633)
68
+ spoom (1.5.0)
72
69
  erubi (>= 1.10.0)
70
+ prism (>= 0.28.0)
73
71
  sorbet-static-and-runtime (>= 0.5.10187)
74
- syntax_tree (>= 6.1.1)
75
72
  thor (>= 0.19.2)
76
- standard (1.34.0)
73
+ standard (1.41.1)
77
74
  language_server-protocol (~> 3.17.0.2)
78
75
  lint_roller (~> 1.0)
79
- rubocop (~> 1.60)
76
+ rubocop (~> 1.66.0)
80
77
  standard-custom (~> 1.0.0)
81
- standard-performance (~> 1.3)
78
+ standard-performance (~> 1.5)
82
79
  standard-custom (1.0.2)
83
80
  lint_roller (~> 1.0)
84
81
  rubocop (~> 1.50)
85
- standard-performance (1.3.1)
82
+ standard-performance (1.5.0)
86
83
  lint_roller (~> 1.1)
87
- rubocop-performance (~> 1.20.2)
84
+ rubocop-performance (~> 1.22.0)
88
85
  standard-sorbet (0.0.2)
89
86
  lint_roller (~> 1.1)
90
87
  rubocop-sorbet (~> 0.7.0)
91
- stringio (3.1.0)
92
- syntax_tree (6.2.0)
93
- prettier_print (>= 1.2.0)
94
- tapioca (0.12.0)
88
+ stringio (3.1.1)
89
+ tapioca (0.16.3)
95
90
  bundler (>= 2.2.25)
96
91
  netrc (>= 0.11.0)
97
92
  parallel (>= 1.21.0)
98
- rbi (>= 0.1.4, < 0.2)
99
- sorbet-static-and-runtime (>= 0.5.10820)
100
- spoom (~> 1.2.0, >= 1.2.0)
93
+ rbi (~> 0.2)
94
+ sorbet-static-and-runtime (>= 0.5.11087)
95
+ spoom (>= 1.2.0)
101
96
  thor (>= 1.2.0)
102
97
  yard-sorbet
103
- thor (1.3.0)
104
- unicode-display_width (2.5.0)
105
- yard (0.9.34)
106
- yard-sorbet (0.8.1)
107
- sorbet-runtime (>= 0.5)
108
- yard (>= 0.9)
98
+ thor (1.3.2)
99
+ unicode-display_width (2.6.0)
100
+ yard (0.9.37)
101
+ yard-sorbet (0.9.0)
102
+ sorbet-runtime
103
+ yard
109
104
 
110
105
  PLATFORMS
111
106
  arm64-darwin-22
@@ -125,4 +120,4 @@ DEPENDENCIES
125
120
  tapioca
126
121
 
127
122
  BUNDLED WITH
128
- 2.4.12
123
+ 2.5.18
data/README.md CHANGED
@@ -78,8 +78,8 @@ result = call_api(1)
78
78
 
79
79
  result.success? # => true on success, false on failure
80
80
  result.failure? # => true on failure, false on success
81
- result.payload # => nil on failure, payload type on failure
82
- result.error # => nil on success, error type on failure
81
+ result.payload # => raises error on failure, payload type on success
82
+ result.error # => raises error on success, error type on failure
83
83
  result.payload_or("fallback") # => returns payload on success, given value on failure
84
84
 
85
85
  # You can combine all the above to write flow-sensitive type-checked code
@@ -134,7 +134,7 @@ We ship with a few Minitest assertions that can be used to easily verify Results
134
134
  ```ruby
135
135
  # test_helper.rb
136
136
 
137
- require "minitest/results_assertions"
137
+ require "minitest/result_assertions"
138
138
  # You also need add this to `sorbet/tapioca/require.rb` and rebuild the Minitest gem RBIs
139
139
 
140
140
  # *_test.rb
data/lib/typed/result.rb CHANGED
@@ -5,6 +5,8 @@ require_relative "no_error_on_success_error"
5
5
  require_relative "no_payload_on_failure_error"
6
6
 
7
7
  module Typed
8
+ extend T::Sig
9
+
8
10
  # A monad representing either a success or a failure. Contains payload and error information as well.
9
11
  class Result
10
12
  extend T::Sig
@@ -76,7 +78,7 @@ module Typed
76
78
  .returns(Typed::Success[T.type_parameter(:T)])
77
79
  end
78
80
  def self.new(payload)
79
- super(payload)
81
+ super
80
82
  end
81
83
 
82
84
  sig { returns(Typed::Success[NilClass]) }
@@ -133,6 +135,29 @@ module Typed
133
135
  def payload_or(_value)
134
136
  payload
135
137
  end
138
+
139
+ sig { params(other: T.untyped).returns(T::Boolean) }
140
+ def ==(other)
141
+ other.is_a?(Success) && other.payload == payload
142
+ end
143
+ end
144
+
145
+ sig do
146
+ type_parameters(:T)
147
+ .params(payload: T.type_parameter(:T))
148
+ .returns(Typed::Success[T.type_parameter(:T)])
149
+ end
150
+ def self.Success(payload)
151
+ Success.new(payload)
152
+ end
153
+
154
+ sig do
155
+ type_parameters(:T)
156
+ .params(error: T.type_parameter(:T))
157
+ .returns(Typed::Failure[T.type_parameter(:T)])
158
+ end
159
+ def self.Failure(error)
160
+ Failure.new(error)
136
161
  end
137
162
 
138
163
  class Failure < Result
@@ -151,7 +176,7 @@ module Typed
151
176
  .returns(Typed::Failure[T.type_parameter(:T)])
152
177
  end
153
178
  def self.new(error)
154
- super(error)
179
+ super
155
180
  end
156
181
 
157
182
  sig { returns(Typed::Failure[NilClass]) }
@@ -209,5 +234,10 @@ module Typed
209
234
  def payload_or(value)
210
235
  value
211
236
  end
237
+
238
+ sig { params(other: T.untyped).returns(T::Boolean) }
239
+ def ==(other)
240
+ other.is_a?(Failure) && other.error == error
241
+ end
212
242
  end
213
243
  end
@@ -4,6 +4,7 @@
4
4
  # This is an autogenerated file for types exported from the `ast` gem.
5
5
  # Please instead update this file by running `bin/tapioca gem ast`.
6
6
 
7
+
7
8
  # {AST} is a library for manipulating abstract syntax trees.
8
9
  #
9
10
  # It embraces immutability; each AST node is inherently frozen at
@@ -4,14 +4,19 @@
4
4
  # This is an autogenerated file for types exported from the `erubi` gem.
5
5
  # Please instead update this file by running `bin/tapioca gem erubi`.
6
6
 
7
+
7
8
  # source://erubi//lib/erubi.rb#3
8
9
  module Erubi
10
+ private
11
+
12
+ def h(_arg0); end
13
+
9
14
  class << self
10
15
  def h(_arg0); end
11
16
  end
12
17
  end
13
18
 
14
- # source://erubi//lib/erubi.rb#54
19
+ # source://erubi//lib/erubi.rb#51
15
20
  class Erubi::Engine
16
21
  # Initialize a new Erubi::Engine. Options:
17
22
  # +:bufval+ :: The value to use for the buffer variable, as a string (default <tt>'::String.new'</tt>).
@@ -42,64 +47,64 @@ class Erubi::Engine
42
47
  #
43
48
  # @return [Engine] a new instance of Engine
44
49
  #
45
- # source://erubi//lib/erubi.rb#94
50
+ # source://erubi//lib/erubi.rb#91
46
51
  def initialize(input, properties = T.unsafe(nil)); end
47
52
 
48
53
  # The variable name used for the buffer variable.
49
54
  #
50
- # source://erubi//lib/erubi.rb#65
55
+ # source://erubi//lib/erubi.rb#62
51
56
  def bufvar; end
52
57
 
53
58
  # The filename of the template, if one was given.
54
59
  #
55
- # source://erubi//lib/erubi.rb#62
60
+ # source://erubi//lib/erubi.rb#59
56
61
  def filename; end
57
62
 
58
63
  # The frozen ruby source code generated from the template, which can be evaled.
59
64
  #
60
- # source://erubi//lib/erubi.rb#59
65
+ # source://erubi//lib/erubi.rb#56
61
66
  def src; end
62
67
 
63
68
  private
64
69
 
65
70
  # Add ruby code to the template
66
71
  #
67
- # source://erubi//lib/erubi.rb#226
72
+ # source://erubi//lib/erubi.rb#223
68
73
  def add_code(code); end
69
74
 
70
75
  # Add the given ruby expression result to the template,
71
76
  # escaping it based on the indicator given and escape flag.
72
77
  #
73
- # source://erubi//lib/erubi.rb#235
78
+ # source://erubi//lib/erubi.rb#232
74
79
  def add_expression(indicator, code); end
75
80
 
76
81
  # Add the result of Ruby expression to the template
77
82
  #
78
- # source://erubi//lib/erubi.rb#244
83
+ # source://erubi//lib/erubi.rb#241
79
84
  def add_expression_result(code); end
80
85
 
81
86
  # Add the escaped result of Ruby expression to the template
82
87
  #
83
- # source://erubi//lib/erubi.rb#249
88
+ # source://erubi//lib/erubi.rb#246
84
89
  def add_expression_result_escaped(code); end
85
90
 
86
91
  # Add the given postamble to the src. Can be overridden in subclasses
87
92
  # to make additional changes to src that depend on the current state.
88
93
  #
89
- # source://erubi//lib/erubi.rb#255
94
+ # source://erubi//lib/erubi.rb#252
90
95
  def add_postamble(postamble); end
91
96
 
92
97
  # Add raw text to the template. Modifies argument if argument is mutable as a memory optimization.
93
98
  # Must be called with a string, cannot be called with nil (Rails's subclass depends on it).
94
99
  #
95
- # source://erubi//lib/erubi.rb#213
100
+ # source://erubi//lib/erubi.rb#210
96
101
  def add_text(text); end
97
102
 
98
103
  # Raise an exception, as the base engine class does not support handling other indicators.
99
104
  #
100
105
  # @raise [ArgumentError]
101
106
  #
102
- # source://erubi//lib/erubi.rb#261
107
+ # source://erubi//lib/erubi.rb#258
103
108
  def handle(indicator, code, tailch, rspace, lspace); end
104
109
 
105
110
  # Make sure that any current expression has been terminated.
@@ -107,7 +112,7 @@ class Erubi::Engine
107
112
  # the chain_appends option is used, expressions may not be
108
113
  # terminated.
109
114
  #
110
- # source://erubi//lib/erubi.rb#289
115
+ # source://erubi//lib/erubi.rb#286
111
116
  def terminate_expression; end
112
117
 
113
118
  # Make sure the buffer variable is the target of the next append
@@ -117,13 +122,13 @@ class Erubi::Engine
117
122
  # This method should only be called if the block will result in
118
123
  # code where << will append to the bufvar.
119
124
  #
120
- # source://erubi//lib/erubi.rb#271
125
+ # source://erubi//lib/erubi.rb#268
121
126
  def with_buffer; end
122
127
  end
123
128
 
124
129
  # The default regular expression used for scanning.
125
130
  #
126
- # source://erubi//lib/erubi.rb#56
131
+ # source://erubi//lib/erubi.rb#53
127
132
  Erubi::Engine::DEFAULT_REGEXP = T.let(T.unsafe(nil), Regexp)
128
133
 
129
134
  # source://erubi//lib/erubi.rb#17
@@ -4,5 +4,6 @@
4
4
  # This is an autogenerated file for types exported from the `io-console` gem.
5
5
  # Please instead update this file by running `bin/tapioca gem io-console`.
6
6
 
7
+
7
8
  # THIS IS AN EMPTY RBI FILE.
8
9
  # see https://github.com/Shopify/tapioca#manually-requiring-parts-of-a-gem