sorbet_operation 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 512a04aba19ff48f6dd0a9dea9dd424f44afc008f1f3d2105a9777a1c4aac003
4
- data.tar.gz: 843ec9ec4160271da77074446fa4dd8addb40ae0cca39a49d26447e8612b03cb
3
+ metadata.gz: 017a1b8b0b9b579c8de8e0bebc9360bf28dff6af01daeaf7ff63ecf9eb0eb161
4
+ data.tar.gz: b53ae934c47c223ef2fff9233a84753ed93cf9b24ca8f888e7f4b42c3b096aa4
5
5
  SHA512:
6
- metadata.gz: a57964ba9985ed63f37ab45dbf82f79f633d36b98987b7f2c6efd584e92bbcb167b01e75869c92ab087d46b35d1cdeb487815a864a9591fbdc297d5baacbe542
7
- data.tar.gz: f1d3bec83764cc914f44b32f2495bcf9d3fa9637ce5e41357bab6f271a69d81aaf8b8ecf29cbdc92c6a5255d671cd2de73f1ff3d3e30106ae8f05a19291ff59e
6
+ metadata.gz: 4febd628a8a8515be2fb12c720300220fea5680016c16bb1b749a1c8fe086a387ee463984d4d1b688c909b2c519bfe5e0d8357348545193a4e6662c0fcb2bebf
7
+ data.tar.gz: 97e203ebb436e7b8282a00f2bbcf7ac05a56e3857596b229f1ea81ba54e72798b55350617630aca95fe61f9461c731d0b56b09e4d6d523e6339659df86cc49bf
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.6
1
+ 3.3.1
data/Gemfile CHANGED
@@ -7,6 +7,8 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
+ gem "bigdecimal" # for Ruby >= 3.4
11
+
10
12
  group :development, :test do
11
13
  gem "irb"
12
14
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sorbet_operation (0.1.1)
4
+ sorbet_operation (0.1.2)
5
5
  sorbet-runtime (~> 0.5.10741)
6
6
 
7
7
  GEM
@@ -9,67 +9,71 @@ GEM
9
9
  specs:
10
10
  ansi (1.5.0)
11
11
  ast (2.4.2)
12
- base64 (0.1.1)
12
+ bigdecimal (3.0.0)
13
13
  builder (3.2.4)
14
14
  bundler-audit (0.9.1)
15
15
  bundler (>= 1.2.0, < 3)
16
16
  thor (~> 1.0)
17
- diff-lcs (1.5.0)
18
17
  docile (1.4.0)
19
18
  erubi (1.12.0)
20
- io-console (0.6.0)
21
- irb (1.7.4)
22
- reline (>= 0.3.6)
23
- json (2.6.3)
19
+ io-console (0.7.2)
20
+ irb (1.11.2)
21
+ rdoc
22
+ reline (>= 0.4.2)
23
+ json (2.7.1)
24
24
  language_server-protocol (3.17.0.3)
25
- minitest (5.19.0)
25
+ minitest (5.22.2)
26
26
  minitest-reporters (1.6.1)
27
27
  ansi
28
28
  builder
29
29
  minitest (>= 5.0)
30
30
  ruby-progressbar
31
31
  netrc (0.11.0)
32
- parallel (1.23.0)
33
- parser (3.2.2.3)
32
+ parallel (1.24.0)
33
+ parser (3.3.0.5)
34
34
  ast (~> 2.4.1)
35
35
  racc
36
36
  prettier_print (1.2.1)
37
- racc (1.7.1)
37
+ prism (0.24.0)
38
+ psych (5.1.2)
39
+ stringio
40
+ racc (1.7.3)
38
41
  rainbow (3.1.1)
39
- rake (13.0.6)
40
- rbi (0.0.17)
41
- ast
42
- parser (>= 3.0.0)
42
+ rake (13.1.0)
43
+ rbi (0.1.9)
44
+ prism (>= 0.18.0, < 0.25)
43
45
  sorbet-runtime (>= 0.5.9204)
44
- unparser (>= 0.5.6)
45
- regexp_parser (2.8.1)
46
- reline (0.3.8)
46
+ rdoc (6.6.2)
47
+ psych (>= 4.0.0)
48
+ regexp_parser (2.9.0)
49
+ reline (0.4.2)
47
50
  io-console (~> 0.5)
48
- rexml (3.2.6)
49
- rubocop (1.56.1)
50
- base64 (~> 0.1.1)
51
+ rexml (3.2.8)
52
+ strscan (>= 3.0.9)
53
+ rubocop (1.60.2)
51
54
  json (~> 2.3)
52
55
  language_server-protocol (>= 3.17.0)
53
56
  parallel (~> 1.10)
54
- parser (>= 3.2.2.3)
57
+ parser (>= 3.3.0.2)
55
58
  rainbow (>= 2.2.2, < 4.0)
56
59
  regexp_parser (>= 1.8, < 3.0)
57
60
  rexml (>= 3.2.5, < 4.0)
58
- rubocop-ast (>= 1.28.1, < 2.0)
61
+ rubocop-ast (>= 1.30.0, < 2.0)
59
62
  ruby-progressbar (~> 1.7)
60
63
  unicode-display_width (>= 2.4.0, < 3.0)
61
- rubocop-ast (1.29.0)
64
+ rubocop-ast (1.30.0)
62
65
  parser (>= 3.2.1.0)
63
- rubocop-minitest (0.31.0)
66
+ rubocop-minitest (0.34.5)
64
67
  rubocop (>= 1.39, < 2.0)
65
- rubocop-performance (1.19.0)
66
- rubocop (>= 1.7.0, < 2.0)
67
- rubocop-ast (>= 0.4.0)
68
+ rubocop-ast (>= 1.30.0, < 2.0)
69
+ rubocop-performance (1.20.2)
70
+ rubocop (>= 1.48.1, < 2.0)
71
+ rubocop-ast (>= 1.30.0, < 2.0)
68
72
  rubocop-rake (0.6.0)
69
73
  rubocop (~> 1.0)
70
- rubocop-shopify (2.14.0)
74
+ rubocop-shopify (2.15.1)
71
75
  rubocop (~> 1.51)
72
- rubocop-sorbet (0.7.3)
76
+ rubocop-sorbet (0.7.7)
73
77
  rubocop (>= 0.90.0)
74
78
  ruby-progressbar (1.13.0)
75
79
  simplecov (0.22.0)
@@ -78,45 +82,46 @@ GEM
78
82
  simplecov_json_formatter (~> 0.1)
79
83
  simplecov-html (0.12.3)
80
84
  simplecov_json_formatter (0.1.4)
81
- sorbet (0.5.10983)
82
- sorbet-static (= 0.5.10983)
83
- sorbet-runtime (0.5.10983)
84
- sorbet-static (0.5.10983-universal-darwin-22)
85
- sorbet-static (0.5.10983-x86_64-linux)
86
- sorbet-static-and-runtime (0.5.10983)
87
- sorbet (= 0.5.10983)
88
- sorbet-runtime (= 0.5.10983)
89
- spoom (1.2.3)
85
+ sorbet (0.5.11267)
86
+ sorbet-static (= 0.5.11267)
87
+ sorbet-runtime (0.5.11267)
88
+ sorbet-static (0.5.11267-universal-darwin)
89
+ sorbet-static (0.5.11267-x86_64-linux)
90
+ sorbet-static-and-runtime (0.5.11267)
91
+ sorbet (= 0.5.11267)
92
+ sorbet-runtime (= 0.5.11267)
93
+ spoom (1.2.4)
90
94
  erubi (>= 1.10.0)
91
95
  sorbet-static-and-runtime (>= 0.5.10187)
92
96
  syntax_tree (>= 6.1.1)
93
97
  thor (>= 0.19.2)
94
- syntax_tree (6.1.1)
98
+ stringio (3.1.0)
99
+ strscan (3.1.0)
100
+ syntax_tree (6.2.0)
95
101
  prettier_print (>= 1.2.0)
96
- tapioca (0.11.8)
102
+ tapioca (0.12.0)
97
103
  bundler (>= 2.2.25)
98
104
  netrc (>= 0.11.0)
99
105
  parallel (>= 1.21.0)
100
- rbi (~> 0.0.0, >= 0.0.16)
101
- sorbet-static-and-runtime (>= 0.5.10187)
106
+ rbi (>= 0.1.4, < 0.2)
107
+ sorbet-static-and-runtime (>= 0.5.10820)
102
108
  spoom (~> 1.2.0, >= 1.2.0)
103
109
  thor (>= 1.2.0)
104
110
  yard-sorbet
105
- thor (1.2.2)
106
- unicode-display_width (2.4.2)
107
- unparser (0.6.8)
108
- diff-lcs (~> 1.3)
109
- parser (>= 3.2.0)
110
- yard (0.9.34)
111
+ thor (1.3.0)
112
+ unicode-display_width (2.5.0)
113
+ yard (0.9.36)
111
114
  yard-sorbet (0.8.1)
112
115
  sorbet-runtime (>= 0.5)
113
116
  yard (>= 0.9)
114
117
 
115
118
  PLATFORMS
116
119
  arm64-darwin-22
120
+ arm64-darwin-23
117
121
  x86_64-linux
118
122
 
119
123
  DEPENDENCIES
124
+ bigdecimal
120
125
  bundler-audit
121
126
  irb
122
127
  minitest (~> 5.0)
@@ -136,4 +141,4 @@ DEPENDENCIES
136
141
  yard-sorbet
137
142
 
138
143
  BUNDLED WITH
139
- 2.4.3
144
+ 2.5.9
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # sorbet_operation
2
2
 
3
3
  [![Build Status](https://github.com/thatch-health/sorbet_operation/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/thatch-health/sorbet_operation/actions?query=branch%3Amain)
4
+ [![Gem Version ](https://img.shields.io/gem/v/sorbet_operation.svg?style=flat)](https://rubygems.org/gems/sorbet_operation)
5
+ [![YARD Docs](https://img.shields.io/badge/yard-docs-blue?logo=readthedocs)](https://thatch-health.github.io/sorbet_operation/)
4
6
 
5
7
  sorbet_operation is a minimal operation framework that leverages Sorbet's type system to ensure that operations are well-typed and that their inputs and outputs are well-defined.
6
8
 
@@ -16,7 +18,7 @@ class CreateUser < SorbetOperation::Base
16
18
  @user_params = user_params
17
19
  end
18
20
 
19
- protected
21
+ private
20
22
 
21
23
  sig { returns(ValueType) }
22
24
  def execute
@@ -38,7 +40,7 @@ class UsersController < ApplicationController
38
40
  redirect_to user
39
41
  else
40
42
  error = result.unwrap_error!
41
- T.reveal_type(error) # `SorbetOperation::Error`
43
+ T.reveal_type(error) # `SorbetOperation::Failure`
42
44
  render :new, alert: error.message
43
45
  end
44
46
  end
@@ -51,24 +53,17 @@ class UsersController < ApplicationController
51
53
  end
52
54
  ```
53
55
 
54
- Operations return a result object which indicates whether the operation was successful or not. The result object wraps the return value of the operation if it was successful, or an instance of `SorbetOperation::Error` if it failed.
56
+ Operations return a result object which indicates whether the operation was successful or not. The result object wraps the return value of the operation if it was successful, or an instance of `SorbetOperation::Failure` if it failed.
55
57
 
56
58
  ## Installation
57
59
 
58
- This gem is not yet published to RubyGems.org. For now, you can install it by adding the following to your `Gemfile`:
59
- ```ruby
60
- gem "sorbet_operation", github: "thatch-health/sorbet_operation", branch: "main"
61
- ```
62
-
63
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
64
-
65
60
  Install the gem and add to the application's Gemfile by executing:
66
61
 
67
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
62
+ $ bundle add sorbet_operation
68
63
 
69
64
  If bundler is not being used to manage dependencies, install the gem by executing:
70
65
 
71
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
66
+ $ gem install sorbet_operation
72
67
 
73
68
  ## Usage
74
69
 
@@ -76,15 +71,15 @@ An operation is a Ruby class that derives from `SorbetOperation::Base`. `SorbetO
76
71
  1. define the return type using the `ValueType` generic type member
77
72
  2. define an `#execute` method that returns a `ValueType`
78
73
 
79
- The `#execute` method should be `protected` or `private`, since it is not meant to be invoked directly; rather, operation callers should use the `#perform` public method to actually perform the operation. (Unfortunately, at this time there is no mechanism to enforce that `#execute` is not a public method on child classes, so it's up to the programmer to be vigilant.)
74
+ The `#execute` method should be `private`, since it is not meant to be invoked directly; rather, operation callers should use the `#perform` public method to actually perform the operation. (Unfortunately, at this time there is no mechanism to enforce that `#execute` is not a public method on child classes, so it's up to the programmer to be vigilant.)
80
75
 
81
76
  The `#execute` method does not take any arguments. Most operations require one or more input values. Input values should be passed to the `#initialize` constructor method and stored as instance variables, which can then be accessed from the `#execute` body.
82
77
 
83
78
  There are two possible outcomes for an operation:
84
79
  1. if `#execute` returns an instance of `ValueType`, then the operation result is a success
85
- 2. if `#execute` raises a `SorbetOperation::Error`, then the operation result is a failure
80
+ 2. if `#execute` raises a `SorbetOperation::Failure`, then the operation result is a failure
86
81
 
87
- Exceptions that are not an instance of `SorbetOperation::Error` will not be caught by the framework and will be propagated to the operation callsite.
82
+ Exceptions that are not an instance of `SorbetOperation::Failure` will not be caught by the framework and will be propagated to the operation callsite.
88
83
 
89
84
  ### Using results
90
85
 
@@ -57,7 +57,7 @@ module SorbetOperation
57
57
  sig { params(logger: ::Logger).void }
58
58
  attr_writer :logger
59
59
 
60
- protected
60
+ private
61
61
 
62
62
  # Implement this method in subclasses to perform the operation.
63
63
  #
@@ -70,7 +70,7 @@ module SorbetOperation
70
70
  # exception. The exception will not be caught and will be propagated to
71
71
  # the caller.
72
72
  #
73
- # This method should be declared as `protected` in subclasses to prevent
73
+ # This method should be declared as `private` in subclasses to prevent
74
74
  # callers from calling it directly. Callers should instead call {#perform}
75
75
  # to perform the operation and get the result.
76
76
  sig { abstract.returns(ValueType) }
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module SorbetOperation
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["sorbet-operation@thatch.ai"]
10
10
 
11
11
  spec.summary = "Sorbet-powered operation framework."
12
- spec.description = "sorbet_operation is a minimal operation framework that leverages Sorbet's type system to "\
12
+ spec.description = "sorbet_operation is a minimal operation framework that leverages Sorbet's type system to " \
13
13
  "ensure that operations are well-typed and that their inputs and outputs are well-defined."
14
14
  spec.homepage = "https://github.com/thatch-health/sorbet_operation"
15
15
  spec.license = "MIT"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thatch Health, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-23 00:00:00.000000000 Z
11
+ date: 2024-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.4.10
73
+ rubygems_version: 3.5.9
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: Sorbet-powered operation framework.