json_schemer 0.2.11 → 0.2.12

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: 45e4c874bfbfd416a38a47a23cf9b5c561df5da3457b11b7cb6acc0f36a8f5d6
4
- data.tar.gz: a62663e1c3f250af1b57418d666c4bbe9229212c00845dc3b5f6c34d7ab3d57c
3
+ metadata.gz: 6d07c36d5981512e6980d79a12084d309b92db45490d3ea821d02713c71fd5fc
4
+ data.tar.gz: 20dad8f563ba3ca0dcb7586641cf804aea2f727ed4def911fb105fd7bb14965f
5
5
  SHA512:
6
- metadata.gz: ff9d2a99b3f964b71d1a98a9037d5465627b913616a6c0c6160d1fe71aac784891585b92339773e677fdc9637bed0e120935ad7f4c4f283dada6f96a219b2591
7
- data.tar.gz: 78d254d698f87a46a1ba1737775178310d2cb0e9d25f095f2da7dede4bcfee58c62dcbd89899370c158638734041b59fe5f351156a713002ceeeca8552849638
6
+ metadata.gz: 199c651105b1330a6946d7099d9c9c0d4f74d1922e03cf3855870660f32c81fb6f94d3748555d17cde6fb56b5b2029388099f7bf977f5585df8ec7dd5da726b5
7
+ data.tar.gz: e2acf5a285a724dc1c5c99fe35e081ab30f934554aa2f02c691926d75f3ac681594c015ef9224b7d2f70be98dd8d39404f8e4b0c3c87285f23314b523111d20e
@@ -4,19 +4,14 @@ jobs:
4
4
  ruby:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.4.x, 2.5.x, 2.6.x]
7
+ ruby: [2.5.x, 2.6.x, 2.7.x]
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
10
  - uses: actions/checkout@v1
11
11
  - uses: actions/setup-ruby@v1
12
12
  with:
13
13
  ruby-version: ${{ matrix.ruby }}
14
- - uses: actions/setup-python@v1
15
- with:
16
- python-version: 3.x
17
14
  - run: |
18
- pip install --user Flask
19
- ./JSON-Schema-Test-Suite/bin/jsonschema_suite serve &
20
15
  gem install bundler
21
16
  bundle install
22
17
  bundle exec rake test
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_schemer (0.2.11)
4
+ json_schemer (0.2.12)
5
5
  ecma-re-validator (~> 0.2)
6
6
  hana (~> 1.3)
7
7
  regexp_parser (~> 1.5)
@@ -10,12 +10,12 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- ecma-re-validator (0.2.0)
13
+ ecma-re-validator (0.2.1)
14
14
  regexp_parser (~> 1.2)
15
- hana (1.3.5)
15
+ hana (1.3.6)
16
16
  minitest (5.11.3)
17
17
  rake (13.0.1)
18
- regexp_parser (1.7.0)
18
+ regexp_parser (1.7.1)
19
19
  uri_template (0.7.0)
20
20
 
21
21
  PLATFORMS
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.required_ruby_version = '~> 2.4'
23
+ spec.required_ruby_version = '~> 2.5'
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 2.0"
26
26
  spec.add_development_dependency "rake", "~> 13.0"
@@ -14,6 +14,7 @@ require 'uri_template'
14
14
 
15
15
  require 'json_schemer/version'
16
16
  require 'json_schemer/format'
17
+ require 'json_schemer/errors'
17
18
  require 'json_schemer/cached_ref_resolver'
18
19
  require 'json_schemer/schema/base'
19
20
  require 'json_schemer/schema/draft4'
@@ -0,0 +1,31 @@
1
+ # Based on code from @robacarp found in issue 48:
2
+ # https://github.com/davishmcclurg/json_schemer/issues/48
3
+ #
4
+ module JSONSchemer
5
+ module Errors
6
+ class << self
7
+ def pretty(error)
8
+ data_pointer, type, schema = error.values_at('data_pointer', 'type', 'schema')
9
+ location = data_pointer.empty? ? 'root' : "property '#{data_pointer}'"
10
+
11
+ case type
12
+ when 'required'
13
+ keys = error.fetch('details').fetch('missing_keys').join(', ')
14
+ "#{location} is missing required keys: #{keys}"
15
+ when 'null', 'string', 'boolean', 'integer', 'number', 'array', 'object'
16
+ "#{location} is not of type: #{type}"
17
+ when 'pattern'
18
+ "#{location} does not match pattern: #{schema.fetch('pattern')}"
19
+ when 'format'
20
+ "#{location} does not match format: #{schema.fetch('format')}"
21
+ when 'const'
22
+ "#{location} is not: #{schema.fetch('const').inspect}"
23
+ when 'enum'
24
+ "#{location} is not one of: #{schema.fetch('enum')}"
25
+ else
26
+ "#{location} is invalid: error_type=#{type}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module JSONSchemer
3
- VERSION = '0.2.11'
3
+ VERSION = '0.2.12'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schemer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Harsha
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-14 00:00:00.000000000 Z
11
+ date: 2020-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,6 +127,7 @@ files:
127
127
  - json_schemer.gemspec
128
128
  - lib/json_schemer.rb
129
129
  - lib/json_schemer/cached_ref_resolver.rb
130
+ - lib/json_schemer/errors.rb
130
131
  - lib/json_schemer/format.rb
131
132
  - lib/json_schemer/schema/base.rb
132
133
  - lib/json_schemer/schema/draft4.rb
@@ -145,14 +146,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
146
  requirements:
146
147
  - - "~>"
147
148
  - !ruby/object:Gem::Version
148
- version: '2.4'
149
+ version: '2.5'
149
150
  required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
152
  - - ">="
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubygems_version: 3.0.3
156
+ rubyforge_project:
157
+ rubygems_version: 2.7.6
156
158
  signing_key:
157
159
  specification_version: 4
158
160
  summary: JSON Schema validator. Supports drafts 4, 6, and 7.