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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1118cf0a2239601909e8d3af33e2b7d2809c8baccae8a0a77b2f2c6fdc814a1
4
- data.tar.gz: 39a6fe29b3383722be668af971c9a78b8719dee1bb8b7e2fe1eb06ce8fe1f5f4
3
+ metadata.gz: 3024051238c907ceb915ad211936b82d0c4422f6980f2abeff76a667017f6a0a
4
+ data.tar.gz: 9f9d1efa03cb0d35155837928577062ae696066841d50a6495c33f40f7fee6ec
5
5
  SHA512:
6
- metadata.gz: bc54d705a3b26803caed812795525e64c2a08260be22c1d14e48f9e47e897b3b60acf4f256eb3ce846fb1c9afda0ed3f019d0a2932827bbfa2ec0fb65931eecb
7
- data.tar.gz: 40bc0d295723533e3ed0e86f77af4b70f26e7fce0fd12498ef14cb906ea28b549b50825021a6421d702a3cd956ef1cec7d9353073124b7859380c1906793a830
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
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.6.6
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.5.3"
4
- - "2.6.3"
3
+ - "2.5.8"
4
+ - "2.6.6"
5
+ - "2.7.1"
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 2.1.2
6
+
7
+ * Update Steep
8
+
5
9
  ## 2.1.1 (2020-05-16)
6
10
 
7
11
  * [24](https://github.com/soutaro/strong_json/pull/24): Ship with RBS
data/Gemfile CHANGED
@@ -3,4 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in strong_json.gemspec
4
4
  gemspec
5
5
 
6
- gem "steep", path: "../steep"
6
+ gem "rake"
7
+ gem "rspec"
8
+ gem "steep"
@@ -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
@@ -1,5 +1,5 @@
1
1
  class StrongJSON
2
2
  # @dynamic initialize, let
3
3
 
4
- VERSION = "2.1.1"
4
+ VERSION = "2.1.2"
5
5
  end
@@ -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
@@ -1,67 +1,67 @@
1
1
  class StrongJSON
2
2
  def initialize: { (StrongJSON) -> void } -> untyped
3
3
  def let: (Symbol, ty) -> void
4
- include StrongJSON::Types
5
- end
4
+ include Types
6
5
 
7
- StrongJSON::VERSION: String
6
+ VERSION: String
8
7
 
9
- interface StrongJSON::_Schema[T]
10
- def coerce: (untyped, ?path: Type::ErrorPath) -> T
11
- def =~: (untyped) -> bool
12
- def to_s: -> String
13
- def is_a?: (untyped) -> bool
14
- def `alias`: -> Symbol?
15
- def with_alias: (Symbol) -> self
16
- def ==: (untyped) -> bool
17
- def yield_self: [X] () { (self) -> X } -> X
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 StrongJSON::ty = _Schema[untyped]
19
+ type ty = _Schema[untyped]
21
20
 
22
- module StrongJSON::Types
23
- def object: [X] (Hash[Symbol, ty]) -> Type::Object[X]
24
- | () -> Type::Object[bot]
25
- def object?: [X] (Hash[Symbol, ty]) -> Type::Optional[X]
26
- | () -> Type::Optional[bot]
27
- def any: () -> Type::Base[untyped]
28
- def any?: () -> Type::Optional[untyped]
29
- def optional: [X] (_Schema[X]) -> Type::Optional[X]
30
- | () -> Type::Optional[untyped]
31
- def string: () -> Type::Base[String]
32
- def string?: () -> Type::Optional[String]
33
- def number: () -> Type::Base[Numeric]
34
- def number?: () -> Type::Optional[Numeric]
35
- def numeric: () -> Type::Base[Numeric]
36
- def numeric?: () -> Type::Optional[Numeric]
37
- def integer: () -> Type::Base[Integer]
38
- def integer?: () -> Type::Optional[Integer]
39
- def boolean: () -> Type::Base[bool]
40
- def boolean?: () -> Type::Optional[bool]
41
- def symbol: () -> Type::Base[Symbol]
42
- def symbol?: () -> Type::Optional[Symbol]
43
- def array: [X] (_Schema[X]) -> Type::Array[X]
44
- | () -> Type::Array[untyped]
45
- def array?: [X] (_Schema[X]) -> Type::Optional[::Array[X]]
46
- def literal: [X] (X) -> Type::Literal[X]
47
- def literal?: [X] (X) -> Type::Optional[X]
48
- def enum: [X] (*_Schema[untyped], ?detector: Type::detector?) -> Type::Enum[X]
49
- def enum?: [X] (*_Schema[untyped], ?detector: Type::detector?) -> Type::Optional[X]
50
- incompatible def hash: [X] (_Schema[X]) -> Type::Hash[X]
51
- def hash?: [X] (_Schema[X]) -> Type::Optional[Hash[Symbol, X]]
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 StrongJSON::ErrorReporter
55
- attr_reader path: Type::ErrorPath
56
- @string: String
53
+ class ErrorReporter
54
+ attr_reader path: Type::ErrorPath
55
+ @string: String
57
56
 
58
- def initialize: (path: Type::ErrorPath) -> untyped
59
- def format: -> void
60
- def pretty_str: (ty, ?expand_alias: bool) -> ::String
57
+ def initialize: (path: Type::ErrorPath) -> untyped
58
+ def format: -> void
59
+ def pretty_str: (ty, ?expand_alias: bool) -> ::String
61
60
 
62
- private
63
- def format_trace: (path: Type::ErrorPath, ?index: Integer) -> void
64
- def format_aliases: (path: Type::ErrorPath, where: ::Array[String]) -> ::Array[String]
65
- def format_single_alias: (Symbol, ty) -> String
66
- def pretty: (ty, untyped, ?expand_alias: bool) -> void
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
@@ -1,131 +1,132 @@
1
- module StrongJSON::Type
2
- end
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 StrongJSON::Type::Match : _Schema[untyped]
5
- def =~: (untyped) -> bool
6
- def ===: (untyped) -> bool
7
- end
8
+ module WithAlias : ::Object
9
+ @alias: Symbol?
10
+ def `alias`: -> Symbol?
11
+ def with_alias: (Symbol) -> self
12
+ end
8
13
 
9
- module StrongJSON::Type::WithAlias : ::Object
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
- type StrongJSON::base_type_name = :any | :number | :string | :boolean | :numeric | :symbol | :integer
16
+ class Base[A]
17
+ include Match
18
+ include WithAlias
16
19
 
17
- class StrongJSON::Type::Base[A]
18
- include Match
19
- include WithAlias
20
+ attr_reader type: base_type_name
20
21
 
21
- attr_reader type: base_type_name
22
+ def initialize: (base_type_name) -> untyped
23
+ def test: (untyped) -> bool
24
+ def coerce: (untyped, ?path: ErrorPath) -> A
25
+ end
22
26
 
23
- def initialize: (base_type_name) -> untyped
24
- def test: (untyped) -> bool
25
- def coerce: (untyped, ?path: ErrorPath) -> A
26
- end
27
+ class Optional[T]
28
+ include Match
29
+ include WithAlias
27
30
 
28
- class StrongJSON::Type::Optional[T]
29
- include Match
30
- include WithAlias
31
+ attr_reader type: _Schema[T]
31
32
 
32
- attr_reader type: _Schema[T]
33
+ def initialize: (_Schema[T]) -> untyped
34
+ def coerce: (untyped, ?path: ErrorPath) -> (T | nil)
35
+ end
33
36
 
34
- def initialize: (_Schema[T]) -> untyped
35
- def coerce: (untyped, ?path: ErrorPath) -> (T | nil)
36
- end
37
+ class Literal[T]
38
+ include Match
39
+ include WithAlias
37
40
 
38
- class StrongJSON::Type::Literal[T]
39
- include Match
40
- include WithAlias
41
+ attr_reader value: T
41
42
 
42
- attr_reader value: T
43
+ def initialize: (T) -> untyped
44
+ def coerce: (untyped, ?path: ErrorPath) -> T
45
+ end
43
46
 
44
- def initialize: (T) -> untyped
45
- def coerce: (untyped, ?path: ErrorPath) -> T
46
- end
47
+ class Array[T]
48
+ include Match
49
+ include WithAlias
47
50
 
48
- class StrongJSON::Type::Array[T]
49
- include Match
50
- include WithAlias
51
+ attr_reader type: _Schema[T]
51
52
 
52
- attr_reader type: _Schema[T]
53
+ def initialize: (_Schema[T]) -> untyped
54
+ def coerce: (untyped, ?path: ErrorPath) -> ::Array[T]
55
+ end
53
56
 
54
- def initialize: (_Schema[T]) -> untyped
55
- def coerce: (untyped, ?path: ErrorPath) -> ::Array[T]
56
- end
57
+ class Object[T]
58
+ include Match
59
+ include WithAlias
57
60
 
58
- class StrongJSON::Type::Object[T]
59
- include Match
60
- include WithAlias
61
+ attr_reader fields: ::Hash[Symbol, _Schema[untyped]]
62
+ attr_reader on_unknown: :ignore | :reject
63
+ attr_reader exceptions: Set[Symbol]
61
64
 
62
- attr_reader fields: ::Hash[Symbol, _Schema[untyped]]
63
- attr_reader on_unknown: :ignore | :reject
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
- def initialize: (::Hash[Symbol, _Schema[T]], on_unknown: :ignore | :reject, exceptions: Set[Symbol]) -> untyped
67
- def coerce: (untyped, ?path: ErrorPath) -> T
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
- # If no argument is given, it ignores all unknown attributes.
70
- # If `Symbol`s are given, it ignores the listed attributes, but rejects if other unknown attributes are detected.
71
- # If `except:` is specified, it rejects attributes listed in `except` are detected, but ignores other unknown attributes.
72
- def ignore: (*Symbol ignores, ?except: Set[Symbol]?) -> Object[T]
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
- # If no argument is given, it rejects on untyped unknown attribute.
75
- # If `Symbol`s are given, it rejects the listed attributes are detected, but ignores other unknown attributes.
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
- def update_fields: [X] { (::Hash[Symbol, _Schema[untyped]]) -> void } -> Object[X]
80
- end
81
-
82
- type StrongJSON::Type::detector = ^(untyped) -> _Schema[untyped]?
81
+ type detector = ^(untyped) -> _Schema[untyped]?
83
82
 
84
- class StrongJSON::Type::Enum[T]
85
- include Match
86
- include WithAlias
83
+ class Enum[T]
84
+ include Match
85
+ include WithAlias
87
86
 
88
- attr_reader types: ::Array[_Schema[untyped]]
89
- attr_reader detector: detector?
87
+ attr_reader types: ::Array[_Schema[untyped]]
88
+ attr_reader detector: detector?
90
89
 
91
- def initialize: (::Array[_Schema[untyped]], ?detector?) -> untyped
92
- def coerce: (untyped, ?path: ErrorPath) -> T
93
- end
90
+ def initialize: (::Array[_Schema[untyped]], ?detector?) -> untyped
91
+ def coerce: (untyped, ?path: ErrorPath) -> T
92
+ end
94
93
 
95
- class StrongJSON::Type::ErrorPath
96
- attr_reader type: _Schema[untyped]
97
- attr_reader parent: [Symbol | Integer | nil, ErrorPath]?
94
+ class ErrorPath
95
+ attr_reader type: _Schema[untyped]
96
+ attr_reader parent: [Symbol | Integer | nil, ErrorPath]?
98
97
 
99
- def initialize: (type: _Schema[untyped], parent: [Symbol | Integer | nil, ErrorPath]?) -> untyped
100
- def dig: (key: Symbol | Integer, type: _Schema[untyped]) -> ErrorPath
101
- def expand: (type: _Schema[untyped]) -> ErrorPath
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
- def self.root: (_Schema[untyped]) -> ErrorPath
104
- def root?: -> bool
105
- end
102
+ def self.root: (_Schema[untyped]) -> ErrorPath
103
+ def root?: -> bool
104
+ end
106
105
 
107
- class StrongJSON::Type::TypeError < StandardError
108
- attr_reader path: ErrorPath
109
- attr_reader value: untyped
106
+ class TypeError < StandardError
107
+ attr_reader path: ErrorPath
108
+ attr_reader value: untyped
110
109
 
111
- def initialize: (path: ErrorPath, value: untyped) -> untyped
112
- def type: -> _Schema[untyped]
113
- end
110
+ def initialize: (path: ErrorPath, value: untyped) -> untyped
111
+ def type: -> _Schema[untyped]
112
+ end
114
113
 
115
- class StrongJSON::Type::UnexpectedAttributeError < StandardError
116
- attr_reader path: ErrorPath
117
- attr_reader attribute: Symbol
114
+ class UnexpectedAttributeError < StandardError
115
+ attr_reader path: ErrorPath
116
+ attr_reader attribute: Symbol
118
117
 
119
- def initialize: (path: ErrorPath, attribute: Symbol) -> untyped
120
- def type: -> _Schema[untyped]
121
- end
118
+ def initialize: (path: ErrorPath, attribute: Symbol) -> untyped
119
+ def type: -> _Schema[untyped]
120
+ end
122
121
 
123
- class StrongJSON::Type::Hash[T]
124
- include Match
125
- include WithAlias
122
+ class Hash[T]
123
+ include Match
124
+ include WithAlias
126
125
 
127
- attr_reader type: _Schema[T]
126
+ attr_reader type: _Schema[T]
128
127
 
129
- def initialize: (_Schema[T]) -> untyped
130
- def coerce: (untyped, ?path: ErrorPath) -> ::Hash[Symbol, T]
128
+ def initialize: (_Schema[T]) -> untyped
129
+ def coerce: (untyped, ?path: ErrorPath) -> ::Hash[Symbol, T]
130
+ end
131
+ end
131
132
  end
@@ -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
@@ -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
@@ -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.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-05-16 00:00:00.000000000 Z
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.3
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: