strong_json 2.1.1 → 2.1.2
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +29 -0
- data/.ruby-version +1 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile +3 -1
- data/lib/strong_json/error_reporter.rb +0 -2
- data/lib/strong_json/version.rb +1 -1
- data/sig/polyfill.rbs +13 -0
- data/sig/strong_json.rbs +56 -56
- data/sig/type.rbs +97 -96
- data/spec/json_spec.rb +9 -9
- data/spec/object_spec.rb +6 -6
- data/strong_json.gemspec +0 -5
- metadata +9 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3024051238c907ceb915ad211936b82d0c4422f6980f2abeff76a667017f6a0a
|
4
|
+
data.tar.gz: 9f9d1efa03cb0d35155837928577062ae696066841d50a6495c33f40f7fee6ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99a431a8d8f686604b8b0a44a1827e0440c61144d9d1b5f1253fbf79b6707dfb10f60a54de337b4dc87b7d27f31b6bd5f3c20f0a6a8a2dff2f48c2a144020827
|
7
|
+
data.tar.gz: 38953830ba84e56e13ee9ab8ff91b97f305bdea2cc81ca12655f2d474932f1ea36bc4c9b1971dd17b123af18ff1036df317ea69bdc93c60002d4fe73cc1654f3
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request: {}
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: "ubuntu-latest"
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
container_tag:
|
15
|
+
- master-nightly-bionic
|
16
|
+
- 2.6.5-bionic
|
17
|
+
- 2.7.0-bionic
|
18
|
+
container:
|
19
|
+
image: rubylang/ruby:${{ matrix.container_tag }}
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v1
|
22
|
+
- name: Install
|
23
|
+
run: |
|
24
|
+
ruby -v
|
25
|
+
gem install bundler
|
26
|
+
bundle install
|
27
|
+
- name: Run test
|
28
|
+
run: |
|
29
|
+
bundle exec rake
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.6
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -67,7 +67,6 @@ class StrongJSON
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def format_single_alias(name, type)
|
70
|
-
# @type const PrettyPrint: untyped
|
71
70
|
PrettyPrint.format do |pp|
|
72
71
|
pp.text(name.to_s)
|
73
72
|
pp.text(" = ")
|
@@ -78,7 +77,6 @@ class StrongJSON
|
|
78
77
|
end
|
79
78
|
|
80
79
|
def pretty_str(type, expand_alias: false)
|
81
|
-
# @type const PrettyPrint: untyped
|
82
80
|
PrettyPrint.singleline_format do |pp|
|
83
81
|
pretty(type, pp, expand_alias: expand_alias)
|
84
82
|
end
|
data/lib/strong_json/version.rb
CHANGED
data/sig/polyfill.rbs
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class PrettyPrint
|
2
|
+
def text: (String) -> void
|
3
|
+
|
4
|
+
def group: (?Integer, ?String, ?String) { () -> void } -> void
|
5
|
+
|
6
|
+
def nest: (Integer) { () -> void } -> void
|
7
|
+
|
8
|
+
def breakable: (String) -> void
|
9
|
+
|
10
|
+
def self.format: { (instance) -> void } -> String
|
11
|
+
|
12
|
+
def self.singleline_format: { (instance) -> void } -> String
|
13
|
+
end
|
data/sig/strong_json.rbs
CHANGED
@@ -1,67 +1,67 @@
|
|
1
1
|
class StrongJSON
|
2
2
|
def initialize: { (StrongJSON) -> void } -> untyped
|
3
3
|
def let: (Symbol, ty) -> void
|
4
|
-
include
|
5
|
-
end
|
4
|
+
include Types
|
6
5
|
|
7
|
-
|
6
|
+
VERSION: String
|
8
7
|
|
9
|
-
interface
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
8
|
+
interface _Schema[T]
|
9
|
+
def coerce: (untyped, ?path: Type::ErrorPath) -> T
|
10
|
+
def =~: (untyped) -> bool
|
11
|
+
def to_s: -> String
|
12
|
+
def is_a?: (untyped) -> bool
|
13
|
+
def `alias`: -> Symbol?
|
14
|
+
def with_alias: (Symbol) -> self
|
15
|
+
def ==: (untyped) -> bool
|
16
|
+
def yield_self: [X] () { (self) -> X } -> X
|
17
|
+
end
|
19
18
|
|
20
|
-
type
|
19
|
+
type ty = _Schema[untyped]
|
21
20
|
|
22
|
-
module
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
21
|
+
module Types
|
22
|
+
def object: [X] (Hash[Symbol, ty]) -> Type::Object[X]
|
23
|
+
| () -> Type::Object[bot]
|
24
|
+
def object?: [X] (Hash[Symbol, ty]) -> Type::Optional[X]
|
25
|
+
| () -> Type::Optional[bot]
|
26
|
+
def any: () -> Type::Base[untyped]
|
27
|
+
def any?: () -> Type::Optional[untyped]
|
28
|
+
def optional: [X] (_Schema[X]) -> Type::Optional[X]
|
29
|
+
| () -> Type::Optional[untyped]
|
30
|
+
def string: () -> Type::Base[String]
|
31
|
+
def string?: () -> Type::Optional[String]
|
32
|
+
def number: () -> Type::Base[Numeric]
|
33
|
+
def number?: () -> Type::Optional[Numeric]
|
34
|
+
def numeric: () -> Type::Base[Numeric]
|
35
|
+
def numeric?: () -> Type::Optional[Numeric]
|
36
|
+
def integer: () -> Type::Base[Integer]
|
37
|
+
def integer?: () -> Type::Optional[Integer]
|
38
|
+
def boolean: () -> Type::Base[bool]
|
39
|
+
def boolean?: () -> Type::Optional[bool]
|
40
|
+
def symbol: () -> Type::Base[Symbol]
|
41
|
+
def symbol?: () -> Type::Optional[Symbol]
|
42
|
+
def array: [X] (_Schema[X]) -> Type::Array[X]
|
43
|
+
| () -> Type::Array[untyped]
|
44
|
+
def array?: [X] (_Schema[X]) -> Type::Optional[::Array[X]]
|
45
|
+
def literal: [X] (X) -> Type::Literal[X]
|
46
|
+
def literal?: [X] (X) -> Type::Optional[X]
|
47
|
+
def enum: [X] (*_Schema[untyped], ?detector: Type::detector?) -> Type::Enum[X]
|
48
|
+
def enum?: [X] (*_Schema[untyped], ?detector: Type::detector?) -> Type::Optional[X]
|
49
|
+
def hash: [X] (_Schema[X]) -> Type::Hash[X]
|
50
|
+
def hash?: [X] (_Schema[X]) -> Type::Optional[Hash[Symbol, X]]
|
51
|
+
end
|
53
52
|
|
54
|
-
class
|
55
|
-
|
56
|
-
|
53
|
+
class ErrorReporter
|
54
|
+
attr_reader path: Type::ErrorPath
|
55
|
+
@string: String
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
def initialize: (path: Type::ErrorPath) -> untyped
|
58
|
+
def format: -> void
|
59
|
+
def pretty_str: (ty, ?expand_alias: bool) -> ::String
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
private
|
62
|
+
def format_trace: (path: Type::ErrorPath, ?index: Integer) -> void
|
63
|
+
def format_aliases: (path: Type::ErrorPath, where: ::Array[String]) -> ::Array[String]
|
64
|
+
def format_single_alias: (Symbol, ty) -> String
|
65
|
+
def pretty: (ty, PrettyPrint, ?expand_alias: bool) -> void
|
66
|
+
end
|
67
67
|
end
|
data/sig/type.rbs
CHANGED
@@ -1,131 +1,132 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
class StrongJSON
|
2
|
+
module Type
|
3
|
+
module Match : _Schema[untyped]
|
4
|
+
def =~: (untyped) -> bool
|
5
|
+
def ===: (untyped) -> bool
|
6
|
+
end
|
3
7
|
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
module WithAlias : ::Object
|
9
|
+
@alias: Symbol?
|
10
|
+
def `alias`: -> Symbol?
|
11
|
+
def with_alias: (Symbol) -> self
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
@alias: Symbol?
|
11
|
-
def `alias`: -> Symbol?
|
12
|
-
def with_alias: (Symbol) -> self
|
13
|
-
end
|
14
|
+
type base_type_name = :any | :number | :string | :boolean | :numeric | :symbol | :integer
|
14
15
|
|
15
|
-
|
16
|
+
class Base[A]
|
17
|
+
include Match
|
18
|
+
include WithAlias
|
16
19
|
|
17
|
-
|
18
|
-
include Match
|
19
|
-
include WithAlias
|
20
|
+
attr_reader type: base_type_name
|
20
21
|
|
21
|
-
|
22
|
+
def initialize: (base_type_name) -> untyped
|
23
|
+
def test: (untyped) -> bool
|
24
|
+
def coerce: (untyped, ?path: ErrorPath) -> A
|
25
|
+
end
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
+
class Optional[T]
|
28
|
+
include Match
|
29
|
+
include WithAlias
|
27
30
|
|
28
|
-
|
29
|
-
include Match
|
30
|
-
include WithAlias
|
31
|
+
attr_reader type: _Schema[T]
|
31
32
|
|
32
|
-
|
33
|
+
def initialize: (_Schema[T]) -> untyped
|
34
|
+
def coerce: (untyped, ?path: ErrorPath) -> (T | nil)
|
35
|
+
end
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
class Literal[T]
|
38
|
+
include Match
|
39
|
+
include WithAlias
|
37
40
|
|
38
|
-
|
39
|
-
include Match
|
40
|
-
include WithAlias
|
41
|
+
attr_reader value: T
|
41
42
|
|
42
|
-
|
43
|
+
def initialize: (T) -> untyped
|
44
|
+
def coerce: (untyped, ?path: ErrorPath) -> T
|
45
|
+
end
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
class Array[T]
|
48
|
+
include Match
|
49
|
+
include WithAlias
|
47
50
|
|
48
|
-
|
49
|
-
include Match
|
50
|
-
include WithAlias
|
51
|
+
attr_reader type: _Schema[T]
|
51
52
|
|
52
|
-
|
53
|
+
def initialize: (_Schema[T]) -> untyped
|
54
|
+
def coerce: (untyped, ?path: ErrorPath) -> ::Array[T]
|
55
|
+
end
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
class Object[T]
|
58
|
+
include Match
|
59
|
+
include WithAlias
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
+
attr_reader fields: ::Hash[Symbol, _Schema[untyped]]
|
62
|
+
attr_reader on_unknown: :ignore | :reject
|
63
|
+
attr_reader exceptions: Set[Symbol]
|
61
64
|
|
62
|
-
|
63
|
-
|
64
|
-
attr_reader exceptions: Set[Symbol]
|
65
|
+
def initialize: (::Hash[Symbol, _Schema[T]], on_unknown: :ignore | :reject, exceptions: Set[Symbol]) -> untyped
|
66
|
+
def coerce: (untyped, ?path: ErrorPath) -> T
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
+
# If no argument is given, it ignores all unknown attributes.
|
69
|
+
# If `Symbol`s are given, it ignores the listed attributes, but rejects if other unknown attributes are detected.
|
70
|
+
# If `except:` is specified, it rejects attributes listed in `except` are detected, but ignores other unknown attributes.
|
71
|
+
def ignore: (*Symbol ignores, ?except: Set[Symbol]?) -> Object[T]
|
68
72
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
# If no argument is given, it rejects on untyped unknown attribute.
|
74
|
+
# If `Symbol`s are given, it rejects the listed attributes are detected, but ignores other unknown attributes.
|
75
|
+
# If `except:` is specified, it ignores given attributes, but rejects if other unknown attributes are detected.
|
76
|
+
def reject: (*Symbol rejecteds, ?except: Set[Symbol]?) -> Object[T]
|
73
77
|
|
74
|
-
|
75
|
-
|
76
|
-
# If `except:` is specified, it ignores given attributes, but rejects if other unknown attributes are detected.
|
77
|
-
def reject: (*Symbol rejecteds, ?except: Set[Symbol]?) -> Object[T]
|
78
|
+
def update_fields: [X] { (::Hash[Symbol, _Schema[untyped]]) -> void } -> Object[X]
|
79
|
+
end
|
78
80
|
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
type StrongJSON::Type::detector = ^(untyped) -> _Schema[untyped]?
|
81
|
+
type detector = ^(untyped) -> _Schema[untyped]?
|
83
82
|
|
84
|
-
class
|
85
|
-
|
86
|
-
|
83
|
+
class Enum[T]
|
84
|
+
include Match
|
85
|
+
include WithAlias
|
87
86
|
|
88
|
-
|
89
|
-
|
87
|
+
attr_reader types: ::Array[_Schema[untyped]]
|
88
|
+
attr_reader detector: detector?
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
end
|
90
|
+
def initialize: (::Array[_Schema[untyped]], ?detector?) -> untyped
|
91
|
+
def coerce: (untyped, ?path: ErrorPath) -> T
|
92
|
+
end
|
94
93
|
|
95
|
-
class
|
96
|
-
|
97
|
-
|
94
|
+
class ErrorPath
|
95
|
+
attr_reader type: _Schema[untyped]
|
96
|
+
attr_reader parent: [Symbol | Integer | nil, ErrorPath]?
|
98
97
|
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
def initialize: (type: _Schema[untyped], parent: [Symbol | Integer | nil, ErrorPath]?) -> untyped
|
99
|
+
def dig: (key: Symbol | Integer, type: _Schema[untyped]) -> ErrorPath
|
100
|
+
def expand: (type: _Schema[untyped]) -> ErrorPath
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
end
|
102
|
+
def self.root: (_Schema[untyped]) -> ErrorPath
|
103
|
+
def root?: -> bool
|
104
|
+
end
|
106
105
|
|
107
|
-
class
|
108
|
-
|
109
|
-
|
106
|
+
class TypeError < StandardError
|
107
|
+
attr_reader path: ErrorPath
|
108
|
+
attr_reader value: untyped
|
110
109
|
|
111
|
-
|
112
|
-
|
113
|
-
end
|
110
|
+
def initialize: (path: ErrorPath, value: untyped) -> untyped
|
111
|
+
def type: -> _Schema[untyped]
|
112
|
+
end
|
114
113
|
|
115
|
-
class
|
116
|
-
|
117
|
-
|
114
|
+
class UnexpectedAttributeError < StandardError
|
115
|
+
attr_reader path: ErrorPath
|
116
|
+
attr_reader attribute: Symbol
|
118
117
|
|
119
|
-
|
120
|
-
|
121
|
-
end
|
118
|
+
def initialize: (path: ErrorPath, attribute: Symbol) -> untyped
|
119
|
+
def type: -> _Schema[untyped]
|
120
|
+
end
|
122
121
|
|
123
|
-
class
|
124
|
-
|
125
|
-
|
122
|
+
class Hash[T]
|
123
|
+
include Match
|
124
|
+
include WithAlias
|
126
125
|
|
127
|
-
|
126
|
+
attr_reader type: _Schema[T]
|
128
127
|
|
129
|
-
|
130
|
-
|
128
|
+
def initialize: (_Schema[T]) -> untyped
|
129
|
+
def coerce: (untyped, ?path: ErrorPath) -> ::Hash[Symbol, T]
|
130
|
+
end
|
131
|
+
end
|
131
132
|
end
|
data/spec/json_spec.rb
CHANGED
@@ -20,11 +20,11 @@ describe "StrongJSON.new" do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
expect(
|
23
|
-
s.checkout.coerce(items: [{ name: "test", count: 1, price: "2.33", comment: "dummy" }], type: 1)
|
23
|
+
s.checkout.coerce({ items: [{ name: "test", count: 1, price: "2.33", comment: "dummy" }], type: 1 })
|
24
24
|
).to eq(items: [ { name: "test", count: 1, price: "2.33" }], type: 1, change: nil, customer: nil)
|
25
25
|
|
26
26
|
expect {
|
27
|
-
s.checkout.coerce(items: [{ name: "test", count: 1, price: [], comment: "dummy" }], type: 1)
|
27
|
+
s.checkout.coerce({ items: [{ name: "test", count: 1, price: [], comment: "dummy" }], type: 1 })
|
28
28
|
}.to raise_error(StrongJSON::Type::TypeError) {|e|
|
29
29
|
expect(e.path.to_s).to eq("$.items[0].price")
|
30
30
|
expect(e.type).to be_a(StrongJSON::Type::Base)
|
@@ -58,7 +58,7 @@ MSG
|
|
58
58
|
}
|
59
59
|
|
60
60
|
expect {
|
61
|
-
s.checkout.coerce(items: [], change: "", type: 1)
|
61
|
+
s.checkout.coerce({ items: [], change: "", type: 1 })
|
62
62
|
}.to raise_error(StrongJSON::Type::TypeError) {|e|
|
63
63
|
expect(e.path.to_s).to eq("$.change")
|
64
64
|
expect(e.type).to be_a(StrongJSON::Type::Base)
|
@@ -94,14 +94,14 @@ MSG
|
|
94
94
|
let :enum, object(e1: enum(boolean, number), e2: enum?(literal(1), literal(2)))
|
95
95
|
end
|
96
96
|
|
97
|
-
expect(s.enum.coerce(e1: false)).to eq(e1: false, e2: nil)
|
98
|
-
expect(s.enum.coerce(e1: 0)).to eq(e1: 0, e2: nil)
|
99
|
-
expect(s.enum.coerce(e1: 0, e2: 1)).to eq(e1: 0, e2: 1)
|
100
|
-
expect(s.enum.coerce(e1: 0, e2: 2)).to eq(e1: 0, e2: 2)
|
101
|
-
expect{ s.enum.coerce(e1: "", e2: 3) }.to raise_error(StrongJSON::Type::TypeError) {|e|
|
97
|
+
expect(s.enum.coerce({ e1: false })).to eq(e1: false, e2: nil)
|
98
|
+
expect(s.enum.coerce({ e1: 0 })).to eq(e1: 0, e2: nil)
|
99
|
+
expect(s.enum.coerce({ e1: 0, e2: 1 })).to eq(e1: 0, e2: 1)
|
100
|
+
expect(s.enum.coerce({ e1: 0, e2: 2 })).to eq(e1: 0, e2: 2)
|
101
|
+
expect{ s.enum.coerce({ e1: "", e2: 3 }) }.to raise_error(StrongJSON::Type::TypeError) {|e|
|
102
102
|
expect(e.path.to_s).to eq("$.e1")
|
103
103
|
}
|
104
|
-
expect{ s.enum.coerce(e1: false, e2: "") }.to raise_error(StrongJSON::Type::TypeError) {|e|
|
104
|
+
expect{ s.enum.coerce({ e1: false, e2: ""} ) }.to raise_error(StrongJSON::Type::TypeError) {|e|
|
105
105
|
expect(e.path.to_s).to eq("$.e2")
|
106
106
|
}
|
107
107
|
end
|
data/spec/object_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe StrongJSON::Type::Object do
|
|
12
12
|
exceptions: Set.new
|
13
13
|
)
|
14
14
|
|
15
|
-
expect(type.coerce(a: 123, b: "test")).to eq(a: 123, b: "test")
|
15
|
+
expect(type.coerce({ a: 123, b: "test" })).to eq(a: 123, b: "test")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "rejects objects with missing fields" do
|
@@ -24,7 +24,7 @@ describe StrongJSON::Type::Object do
|
|
24
24
|
exceptions: Set.new
|
25
25
|
)
|
26
26
|
|
27
|
-
expect{ type.coerce(a: 123, b: "test") }.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|e|
|
27
|
+
expect{ type.coerce({ a: 123, b: "test" }) }.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|e|
|
28
28
|
expect(e.path.to_s).to eq("$")
|
29
29
|
expect(e.attribute).to eq(:b)
|
30
30
|
}
|
@@ -42,12 +42,12 @@ describe StrongJSON::Type::Object do
|
|
42
42
|
}
|
43
43
|
|
44
44
|
it "ignores field with any value" do
|
45
|
-
expect(type.coerce(a: 123, b: true)).to eq(a: 123)
|
45
|
+
expect(type.coerce({ a: 123, b: true })).to eq(a: 123)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "raises error on attributes listed in exceptions" do
|
49
49
|
expect {
|
50
|
-
type.coerce(a: 123, x: false)
|
50
|
+
type.coerce({ a: 123, x: false })
|
51
51
|
}.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|error|
|
52
52
|
expect(error.attribute).to eq(:x)
|
53
53
|
}
|
@@ -67,14 +67,14 @@ describe StrongJSON::Type::Object do
|
|
67
67
|
|
68
68
|
it "raises with unknown attribute" do
|
69
69
|
expect {
|
70
|
-
type.coerce(a: 123, b: true)
|
70
|
+
type.coerce({ a: 123, b: true })
|
71
71
|
}.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|error|
|
72
72
|
expect(error.attribute).to eq(:b)
|
73
73
|
}
|
74
74
|
end
|
75
75
|
|
76
76
|
it "ignores attributes listed in exceptions" do
|
77
|
-
expect(type.coerce(a: 123, c: false)).to eq(a:123)
|
77
|
+
expect(type.coerce({ a: 123, c: false })).to eq(a:123)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/strong_json.gemspec
CHANGED
@@ -18,9 +18,4 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
spec.metadata = { "steep_types" => "sig" }
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler", ">= 1.6"
|
23
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
-
spec.add_development_dependency "steep", "~> 0.15"
|
26
21
|
end
|
metadata
CHANGED
@@ -1,71 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strong_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.6'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.6'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: steep
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.15'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.15'
|
11
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
69
13
|
description: Type check JSON objects
|
70
14
|
email:
|
71
15
|
- matsumoto@soutaro.com
|
@@ -73,6 +17,7 @@ executables: []
|
|
73
17
|
extensions: []
|
74
18
|
extra_rdoc_files: []
|
75
19
|
files:
|
20
|
+
- ".github/workflows/ruby.yml"
|
76
21
|
- ".gitignore"
|
77
22
|
- ".ruby-version"
|
78
23
|
- ".travis.yml"
|
@@ -91,6 +36,7 @@ files:
|
|
91
36
|
- lib/strong_json/types.rb
|
92
37
|
- lib/strong_json/version.rb
|
93
38
|
- pp.rb
|
39
|
+
- sig/polyfill.rbs
|
94
40
|
- sig/strong_json.rbs
|
95
41
|
- sig/type.rbs
|
96
42
|
- spec/array_spec.rb
|
@@ -109,7 +55,7 @@ licenses:
|
|
109
55
|
- MIT
|
110
56
|
metadata:
|
111
57
|
steep_types: sig
|
112
|
-
post_install_message:
|
58
|
+
post_install_message:
|
113
59
|
rdoc_options: []
|
114
60
|
require_paths:
|
115
61
|
- lib
|
@@ -124,8 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
70
|
- !ruby/object:Gem::Version
|
125
71
|
version: '0'
|
126
72
|
requirements: []
|
127
|
-
rubygems_version: 3.0.
|
128
|
-
signing_key:
|
73
|
+
rubygems_version: 3.0.8
|
74
|
+
signing_key:
|
129
75
|
specification_version: 4
|
130
76
|
summary: Type check JSON objects
|
131
77
|
test_files:
|