strong_json 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdd0f07ab15fb780a80f1f1aa00ca73cf253d3fd1dc606548c17c3044d53aba8
4
- data.tar.gz: 9b6928be45c28fd0f25cefdeccbcdcadd60d9f5cf4dd08641ec1d913928f61a8
3
+ metadata.gz: 0035c9edc36454dc79ce83f91e948c91c7a10935cc4c7dc1ab3c50113c209100
4
+ data.tar.gz: b77289a1d16f20e2f29875e5156917f984587ad70f6d9bddd4aa4d7a62f40cb9
5
5
  SHA512:
6
- metadata.gz: 0e0d57e0a35ade9741f5f2b4b53d86dc56f8175a06da3c12c2d09751c23c0f2696e97f1e9439949ecdf924208eb1d779bc6fc0f8d83b71e19e4799d3fd8b8124
7
- data.tar.gz: eecb31e269885a382c90be9ec8988b5b2cfef7c39f5669e1f0d1be90507742259359a4f74cbcadebc4db5817ef2901a375efe2792e58fac00a9d332638690832
6
+ metadata.gz: d230d14df235f9831ea73287abd9aa6018053ead823a7816bb73516adfc3599e29d727295055ab2439c6342592ebe1331e91a74df775adff8f550524b5be2d41
7
+ data.tar.gz: ac439273a3b6ef148f2f135b3f3c9820caf25831f8bfaae554971830b1c009d42242a6a614b7786eb2669c551e356eb66823375f2bbecf9f2a372bb9b3154228
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.0.1 (2019-05-29)
6
+
7
+ * Improve enum error reporting
8
+
5
9
  ## 1.0.0 (2019-05-26)
6
10
 
7
11
  * [#14](https://github.com/soutaro/strong_json/pull/14): Revise error reporting
@@ -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
- # @type const PrettyPrint: any
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
@@ -1,5 +1,5 @@
1
1
  class StrongJSON
2
2
  # @dynamic initialize, let
3
3
 
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
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.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-26 00:00:00.000000000 Z
11
+ date: 2019-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler