strong_json 1.0.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/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +3 -1
- data/CHANGELOG.md +20 -0
- data/Gemfile +4 -0
- data/README.md +16 -15
- data/Rakefile +2 -2
- data/Steepfile +7 -0
- data/example/Steepfile +8 -0
- data/example/{example.rb → lib/example.rb} +1 -1
- data/example/sig/example.rbs +11 -0
- data/lib/strong_json/error_reporter.rb +2 -4
- data/lib/strong_json/type.rb +82 -52
- data/lib/strong_json/types.rb +18 -6
- data/lib/strong_json/version.rb +2 -2
- data/pp.rb +27 -0
- data/sig/polyfill.rbs +13 -0
- data/sig/strong_json.rbs +67 -0
- data/sig/type.rbs +132 -0
- data/spec/basetype_spec.rb +12 -0
- data/spec/enum_spec.rb +8 -8
- data/spec/hash_spec.rb +32 -0
- data/spec/json_spec.rb +10 -10
- data/spec/object_spec.rb +108 -80
- data/strong_json.gemspec +0 -5
- metadata +18 -68
- data/example/example.rbi +0 -11
- data/sig/strong_json.rbi +0 -64
- data/sig/type.rbi +0 -116
data/sig/type.rbi
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
module StrongJSON::Type
|
2
|
-
end
|
3
|
-
|
4
|
-
module StrongJSON::Type::Match: _Schema<any>
|
5
|
-
def =~: (any) -> bool
|
6
|
-
def ===: (any) -> bool
|
7
|
-
end
|
8
|
-
|
9
|
-
module StrongJSON::Type::WithAlias: ::Object
|
10
|
-
@alias: Symbol?
|
11
|
-
def alias: -> Symbol?
|
12
|
-
def with_alias: (Symbol) -> self
|
13
|
-
end
|
14
|
-
|
15
|
-
type StrongJSON::base_type_name = :any | :number | :string | :boolean | :numeric | :symbol
|
16
|
-
|
17
|
-
class StrongJSON::Type::Base<'a>
|
18
|
-
include Match
|
19
|
-
include WithAlias
|
20
|
-
|
21
|
-
attr_reader type: base_type_name
|
22
|
-
|
23
|
-
def initialize: (base_type_name) -> any
|
24
|
-
def test: (any) -> bool
|
25
|
-
def coerce: (any, ?path: ErrorPath) -> 'a
|
26
|
-
end
|
27
|
-
|
28
|
-
class StrongJSON::Type::Optional<'t>
|
29
|
-
include Match
|
30
|
-
include WithAlias
|
31
|
-
|
32
|
-
attr_reader type: _Schema<'t>
|
33
|
-
|
34
|
-
def initialize: (_Schema<'t>) -> any
|
35
|
-
def coerce: (any, ?path: ErrorPath) -> ('t | nil)
|
36
|
-
end
|
37
|
-
|
38
|
-
class StrongJSON::Type::Literal<'t>
|
39
|
-
include Match
|
40
|
-
include WithAlias
|
41
|
-
|
42
|
-
attr_reader value: 't
|
43
|
-
|
44
|
-
def initialize: ('t) -> any
|
45
|
-
def coerce: (any, ?path: ErrorPath) -> 't
|
46
|
-
end
|
47
|
-
|
48
|
-
class StrongJSON::Type::Array<'t>
|
49
|
-
include Match
|
50
|
-
include WithAlias
|
51
|
-
|
52
|
-
attr_reader type: _Schema<'t>
|
53
|
-
|
54
|
-
def initialize: (_Schema<'t>) -> any
|
55
|
-
def coerce: (any, ?path: ErrorPath) -> ::Array<'t>
|
56
|
-
end
|
57
|
-
|
58
|
-
class StrongJSON::Type::Object<'t>
|
59
|
-
include Match
|
60
|
-
include WithAlias
|
61
|
-
|
62
|
-
attr_reader fields: Hash<Symbol, _Schema<any>>
|
63
|
-
attr_reader ignored_attributes: :any | Set<Symbol> | nil
|
64
|
-
attr_reader prohibited_attributes: Set<Symbol>
|
65
|
-
|
66
|
-
def initialize: (Hash<Symbol, _Schema<'t>>, ignored_attributes: :any | Set<Symbol> | nil, prohibited_attributes: Set<Symbol>) -> any
|
67
|
-
def coerce: (any, ?path: ErrorPath) -> 't
|
68
|
-
|
69
|
-
def ignore: (:any | Set<Symbol> | nil) -> self
|
70
|
-
def ignore!: (:any | Set<Symbol> | nil) -> self
|
71
|
-
def prohibit: (Set<Symbol>) -> self
|
72
|
-
def prohibit!: (Set<Symbol>) -> self
|
73
|
-
def update_fields: <'x> { (Hash<Symbol, _Schema<any>>) -> void } -> Object<'x>
|
74
|
-
end
|
75
|
-
|
76
|
-
type StrongJSON::Type::detector = ^(any) -> _Schema<any>?
|
77
|
-
|
78
|
-
class StrongJSON::Type::Enum<'t>
|
79
|
-
include Match
|
80
|
-
include WithAlias
|
81
|
-
|
82
|
-
attr_reader types: ::Array<_Schema<any>>
|
83
|
-
attr_reader detector: detector?
|
84
|
-
|
85
|
-
def initialize: (::Array<_Schema<any>>, ?detector?) -> any
|
86
|
-
def coerce: (any, ?path: ErrorPath) -> 't
|
87
|
-
end
|
88
|
-
|
89
|
-
class StrongJSON::Type::ErrorPath
|
90
|
-
attr_reader type: _Schema<any>
|
91
|
-
attr_reader parent: [Symbol | Integer | nil, instance]?
|
92
|
-
|
93
|
-
def initialize: (type: _Schema<any>, parent: [Symbol | Integer | nil, instance]?) -> any
|
94
|
-
def (constructor) dig: (key: Symbol | Integer, type: _Schema<any>) -> self
|
95
|
-
def (constructor) expand: (type: _Schema<any>) -> self
|
96
|
-
|
97
|
-
def self.root: (_Schema<any>) -> instance
|
98
|
-
def root?: -> bool
|
99
|
-
end
|
100
|
-
|
101
|
-
class StrongJSON::Type::TypeError < StandardError
|
102
|
-
attr_reader path: ErrorPath
|
103
|
-
attr_reader value: any
|
104
|
-
|
105
|
-
def initialize: (path: ErrorPath, value: any) -> any
|
106
|
-
def type: -> _Schema<any>
|
107
|
-
end
|
108
|
-
|
109
|
-
class StrongJSON::Type::UnexpectedAttributeError < StandardError
|
110
|
-
attr_reader path: ErrorPath
|
111
|
-
attr_reader attribute: Symbol
|
112
|
-
|
113
|
-
def initialize: (path: ErrorPath, attribute: Symbol) -> any
|
114
|
-
def type: -> _Schema<any>
|
115
|
-
end
|
116
|
-
|