strong_json 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/example/example.rb +1 -1
- data/example/example.rbi +4 -4
- data/lib/strong_json/types.rb +3 -3
- data/lib/strong_json/version.rb +1 -1
- data/sig/strong_json.rbi +23 -23
- data/strong_json.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34cb280b80e097153297adf6032193ce6479c3facb6aabf8f8bf0794a83030e0
|
4
|
+
data.tar.gz: 12e64c35a8376a275d6cf0e4819c2820d5f5db4fa94b1b294ecba2ccd133fd42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3258f86f9fe623a016658fc19a8f333a60fb99a9af4a9d55c23087e4bcf3edb137723083921d4f55ed5764dd659e964a0b4afbbf36cf4e9294247bf5a377fdbb
|
7
|
+
data.tar.gz: f52cfe275312e777495d5d5d7d2822aeec61fb5cedcc01573c630ce34c204861072e996bd4ee9c621121cb97a83aed27642ec2bc035df4e4c87d551d35acc449
|
data/CHANGELOG.md
CHANGED
data/example/example.rb
CHANGED
@@ -3,7 +3,7 @@ Schema = _ = StrongJSON.new do
|
|
3
3
|
|
4
4
|
let :address, object(address: string, country: symbol?)
|
5
5
|
let :email, object(email: string)
|
6
|
-
let :contact, enum(address, email)
|
6
|
+
let :contact, enum?(address, email)
|
7
7
|
let :person, object(name: string, contacts: array(contact))
|
8
8
|
end
|
9
9
|
|
data/example/example.rbi
CHANGED
@@ -2,10 +2,10 @@ type address = { address: String, country: Symbol? }
|
|
2
2
|
type email = { email: String }
|
3
3
|
|
4
4
|
class AddressSchema < StrongJSON
|
5
|
-
def address: -> StrongJSON::
|
6
|
-
def email: -> StrongJSON::
|
7
|
-
def contact: -> StrongJSON::
|
8
|
-
def person: -> StrongJSON::
|
5
|
+
def address: -> StrongJSON::Type::Object<address>
|
6
|
+
def email: -> StrongJSON::Type::Object<email>
|
7
|
+
def contact: -> StrongJSON::Type::Object<email | address>
|
8
|
+
def person: -> StrongJSON::Type::Object<{ name: String, contacts: Array<email | address> }>
|
9
9
|
end
|
10
10
|
|
11
11
|
Schema: AddressSchema
|
data/lib/strong_json/types.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
class StrongJSON
|
2
2
|
module Types
|
3
|
-
# @type method object: (?Hash<Symbol, ty>) ->
|
3
|
+
# @type method object: (?Hash<Symbol, ty>) -> Type::Object<any>
|
4
4
|
def object(fields = {})
|
5
5
|
Type::Object.new(fields)
|
6
6
|
end
|
7
7
|
|
8
|
-
# @type method array: (?ty) ->
|
8
|
+
# @type method array: (?ty) -> Type::Array<any>
|
9
9
|
def array(type = any)
|
10
10
|
Type::Array.new(type)
|
11
11
|
end
|
12
12
|
|
13
|
-
# @type method optional: (?ty) ->
|
13
|
+
# @type method optional: (?ty) -> Type::Optional<any>
|
14
14
|
def optional(type = any)
|
15
15
|
Type::Optional.new(type)
|
16
16
|
end
|
data/lib/strong_json/version.rb
CHANGED
data/sig/strong_json.rbi
CHANGED
@@ -16,29 +16,29 @@ end
|
|
16
16
|
type StrongJSON::ty = _Schema<any>
|
17
17
|
|
18
18
|
module StrongJSON::Types
|
19
|
-
def object: <'x> (Hash<Symbol, ty>) ->
|
20
|
-
| () ->
|
21
|
-
def object?: <'x> (Hash<Symbol, ty>) ->
|
22
|
-
def any: () ->
|
23
|
-
def optional: <'x> (
|
24
|
-
| () ->
|
25
|
-
def string: () ->
|
26
|
-
def string?: () ->
|
27
|
-
def number: () ->
|
28
|
-
def number?: () ->
|
29
|
-
def numeric: () ->
|
30
|
-
def numeric?: () ->
|
31
|
-
def boolean: () ->
|
32
|
-
def boolean?: () ->
|
33
|
-
def symbol: () ->
|
34
|
-
def symbol?: () ->
|
35
|
-
def array: <'x> (_Schema<'x>) ->
|
36
|
-
| () ->
|
37
|
-
def array?: <'x> (_Schema<'x>) ->
|
38
|
-
def literal: <'x> ('x) ->
|
39
|
-
def literal?: <'x> ('x) ->
|
40
|
-
def enum: <'x> (*_Schema<any>) ->
|
41
|
-
def enum?: <'x> (*_Schema<any>) ->
|
19
|
+
def object: <'x> (Hash<Symbol, ty>) -> Type::Object<'x>
|
20
|
+
| () -> Type::Object<Hash<Symbol, any>>
|
21
|
+
def object?: <'x> (Hash<Symbol, ty>) -> Type::Optional<'x>
|
22
|
+
def any: () -> Type::Base<any>
|
23
|
+
def optional: <'x> (_Schema<'x>) -> Type::Optional<'x>
|
24
|
+
| () -> Type::Optional<any>
|
25
|
+
def string: () -> Type::Base<String>
|
26
|
+
def string?: () -> Type::Optional<String>
|
27
|
+
def number: () -> Type::Base<Numeric>
|
28
|
+
def number?: () -> Type::Optional<Numeric>
|
29
|
+
def numeric: () -> Type::Base<Numeric>
|
30
|
+
def numeric?: () -> Type::Optional<Numeric>
|
31
|
+
def boolean: () -> Type::Base<bool>
|
32
|
+
def boolean?: () -> Type::Optional<bool>
|
33
|
+
def symbol: () -> Type::Base<Symbol>
|
34
|
+
def symbol?: () -> Type::Optional<Symbol>
|
35
|
+
def array: <'x> (_Schema<'x>) -> Type::Array<'x>
|
36
|
+
| () -> Type::Array<any>
|
37
|
+
def array?: <'x> (_Schema<'x>) -> Type::Optional<::Array<'x>>
|
38
|
+
def literal: <'x> ('x) -> Type::Literal<'x>
|
39
|
+
def literal?: <'x> ('x) -> Type::Optional<'x>
|
40
|
+
def enum: <'x> (*_Schema<any>) -> Type::Enum<'x>
|
41
|
+
def enum?: <'x> (*_Schema<any>) -> Type::Optional<'x>
|
42
42
|
def ignored: () -> _Schema<nil>
|
43
43
|
def prohibited: () -> _Schema<nil>
|
44
44
|
end
|
data/strong_json.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
spec.metadata = { "steep_types" => "sig" }
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler", "
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.6"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
-
spec.add_development_dependency "steep", "~> 0.
|
25
|
+
spec.add_development_dependency "steep", "~> 0.10"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strong_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.10'
|
69
69
|
description: Type check JSON objects
|
70
70
|
email:
|
71
71
|
- matsumoto@soutaro.com
|