strong_json 1.0.0 → 1.0.1
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/CHANGELOG.md +4 -0
- data/lib/strong_json/error_reporter.rb +25 -9
- data/lib/strong_json/version.rb +1 -1
- data/sig/strong_json.rbi +1 -0
- data/spec/json_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0035c9edc36454dc79ce83f91e948c91c7a10935cc4c7dc1ab3c50113c209100
|
4
|
+
data.tar.gz: b77289a1d16f20e2f29875e5156917f984587ad70f6d9bddd4aa4d7a62f40cb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d230d14df235f9831ea73287abd9aa6018053ead823a7816bb73516adfc3599e29d727295055ab2439c6342592ebe1331e91a74df775adff8f550524b5be2d41
|
7
|
+
data.tar.gz: ac439273a3b6ef148f2f135b3f3c9820caf25831f8bfaae554971830b1c009d42242a6a614b7786eb2669c551e356eb66823375f2bbecf9f2a372bb9b3154228
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,16 @@ class StrongJSON
|
|
17
17
|
|
18
18
|
format_trace(path: path)
|
19
19
|
where = format_aliases(path: path, where: [])
|
20
|
+
|
21
|
+
# @type var ty: Type::Enum<any>
|
22
|
+
if (ty = _ = path.type).is_a?(Type::Enum)
|
23
|
+
ty.types.each do |t|
|
24
|
+
if (a = t.alias)
|
25
|
+
where.push format_single_alias(a, t)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
20
30
|
unless where.empty?
|
21
31
|
@string << "\nWhere:\n"
|
22
32
|
@string << where.map {|x| x.gsub(/^/, " ") }.join("\n")
|
@@ -45,15 +55,8 @@ class StrongJSON
|
|
45
55
|
def format_aliases(path:, where:)
|
46
56
|
ty = path.type
|
47
57
|
|
48
|
-
if ty.alias
|
49
|
-
|
50
|
-
where << PrettyPrint.format do |pp|
|
51
|
-
pp.text(ty.alias.to_s)
|
52
|
-
pp.text(" = ")
|
53
|
-
pp.group do
|
54
|
-
pretty(ty, pp, expand_alias: true)
|
55
|
-
end
|
56
|
-
end
|
58
|
+
if (a = ty.alias)
|
59
|
+
where << format_single_alias(a, ty)
|
57
60
|
end
|
58
61
|
|
59
62
|
if parent = path.parent
|
@@ -63,6 +66,17 @@ class StrongJSON
|
|
63
66
|
where
|
64
67
|
end
|
65
68
|
|
69
|
+
def format_single_alias(name, type)
|
70
|
+
# @type const PrettyPrint: any
|
71
|
+
PrettyPrint.format do |pp|
|
72
|
+
pp.text(name.to_s)
|
73
|
+
pp.text(" = ")
|
74
|
+
pp.group do
|
75
|
+
pretty(type, pp, expand_alias: true)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
66
80
|
def pretty_str(type, expand_alias: false)
|
67
81
|
# @type const PrettyPrint: any
|
68
82
|
PrettyPrint.singleline_format do |pp|
|
@@ -121,6 +135,8 @@ class StrongJSON
|
|
121
135
|
end
|
122
136
|
pp.breakable ""
|
123
137
|
end
|
138
|
+
when Type::Base
|
139
|
+
pp.text type.type.to_s
|
124
140
|
else
|
125
141
|
pp.text type.to_s
|
126
142
|
end
|
data/lib/strong_json/version.rb
CHANGED
data/sig/strong_json.rbi
CHANGED
@@ -58,6 +58,7 @@ class StrongJSON::ErrorReporter
|
|
58
58
|
def format: -> void
|
59
59
|
def (private) format_trace: (path: Type::ErrorPath, ?index: Integer) -> void
|
60
60
|
def (private) format_aliases: (path: Type::ErrorPath, where: ::Array<String>) -> ::Array<String>
|
61
|
+
def (private) format_single_alias: (Symbol, ty) -> String
|
61
62
|
def (private) pretty: (ty, any, ?expand_alias: bool) -> void
|
62
63
|
def pretty_str: (ty, ?expand_alias: bool) -> ::String
|
63
64
|
end
|
data/spec/json_spec.rb
CHANGED
@@ -145,6 +145,14 @@ Where:
|
|
145
145
|
optional(string)
|
146
146
|
)
|
147
147
|
rule = { "pattern": pattern, "glob": optional(enum(string, array(string))) }
|
148
|
+
regexp_pattern = {
|
149
|
+
"pattern": string,
|
150
|
+
"multiline": optional(boolean),
|
151
|
+
"case_sensitive": optional(boolean)
|
152
|
+
}
|
153
|
+
token_pattern = { "token": string, "case_sensitive": optional(boolean) }
|
154
|
+
literal_pattern = { "literal": string }
|
155
|
+
string_pattern = string
|
148
156
|
MSG
|
149
157
|
}
|
150
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strong_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|