sorbet-coerce 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/rbi/sorbet-coerce.rbi +2 -2
- data/spec/sorbet_test_cases.rb +22 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f794cd6c92bb1d7e6481a4fb26b9073ac278f8e3bb379f835333128053f251d6
|
4
|
+
data.tar.gz: 5013d33d3021f8da6784c7dfa8ff1014d40791d201a6a2b5c41ca31c64968454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f605e6bc1e70dd0bb913cc12fec39d6b171768ff031ad3e67ad0917404fc0c27058c6dc7d15e75e8e2fac38727f3e68a9d48372e40c4ef4cc4d430e4a617dc91
|
7
|
+
data.tar.gz: a8f8e5d9d3ebdb9b9766e6dbf338e8bb7abf8a5dbf551721904f8e8083a4adad7471164e0a52c0a1cc7c846d19e9b5f1709a6f01916637867374cecd1a190f7a
|
data/rbi/sorbet-coerce.rbi
CHANGED
@@ -6,8 +6,8 @@ module T
|
|
6
6
|
|
7
7
|
Elem = type_member
|
8
8
|
|
9
|
-
sig { params(args: T.untyped,
|
10
|
-
def from(args,
|
9
|
+
sig { params(args: T.untyped, raise_coercion_error: T.nilable(T::Boolean)).returns(Elem) }
|
10
|
+
def from(args, raise_coercion_error: nil); end
|
11
11
|
end
|
12
12
|
|
13
13
|
module Private
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: true
|
2
|
+
require 'sorbet-coerce'
|
3
|
+
|
4
|
+
T.assert_type!(T::Coerce[Integer].new.from('1'), Integer)
|
5
|
+
T.assert_type!(
|
6
|
+
T::Coerce[T.nilable(Integer)].new.from('invalid', raise_coercion_error: false),
|
7
|
+
T.nilable(Integer),
|
8
|
+
)
|
9
|
+
|
10
|
+
T::Coerce::Configuration.raise_coercion_error = true
|
11
|
+
coercion_error = nil
|
12
|
+
begin
|
13
|
+
T::Coerce[T.nilable(Integer)].new.from('invalid')
|
14
|
+
rescue T::Coerce::CoercionError => e
|
15
|
+
coercion_error = e
|
16
|
+
end
|
17
|
+
raise 'no coercion error is raised' unless coercion_error
|
18
|
+
|
19
|
+
T.assert_type!(
|
20
|
+
T::Coerce[T.nilable(Integer)].new.from('invalid', raise_coercion_error: false),
|
21
|
+
T.nilable(Integer),
|
22
|
+
)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-coerce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chan Zuckerberg Initiative
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- spec/coerce_spec.rb
|
126
126
|
- spec/nested_spec.rb
|
127
127
|
- spec/soft_error_spec.rb
|
128
|
+
- spec/sorbet_test_cases.rb
|
128
129
|
- spec/spec_helper.rb
|
129
130
|
homepage: https://github.com/chanzuckerberg/sorbet-coerce
|
130
131
|
licenses:
|