json_schemer 0.2.17 → 0.2.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '048e6a2fadd3b4717233464de16b5777ebf94bacd20a44005de1b309d93110db'
4
- data.tar.gz: 599aa58b678b2d52b559281b5760fff0f0668e0bf8c771635bbf41db814ffe8b
3
+ metadata.gz: 79ed6f849e3328efd2414b4015f6e1d2d4d897d5aa97400fabf99f0dd5c2dbc5
4
+ data.tar.gz: e33eb4f20852cf54fd14d591d2a2cee7892ada8516477e78f605107eebc7a6c8
5
5
  SHA512:
6
- metadata.gz: c806dea39ba83179cda20f09af807314a3b1c1bf82ff79e496f10c45cea28a9597afebe88f7ed57d8d7c28542a68d53beaff1dd3521386c1fc981f38ff09b27f
7
- data.tar.gz: 271d8b4d761d60c29ee598298aefc91543f5edeb3e9b7369f6a0cfee67c07b16eb1a8c5874dfab712cd27fc779e4b4218a1511515ea5a2bf295bc85ab316072b
6
+ metadata.gz: 611e3e327169b79b74adb979b00fd0e8124ac224c3971bb7f02dfc8040c17024720f4bd0308428eaa79c138c5ab461cb06ae9ea12b122ca4ed75ad0e396804bd
7
+ data.tar.gz: ee237ca11f77f20aa4d1dd7a1c192744019abfddcaeebaf5e1c0e63ebdf53eb15fc1a3c52a3f34af9bee41f868b28f0f2ae1e131476880d46177ad10be5c4ea8
@@ -1,16 +1,26 @@
1
1
  name: ci
2
2
  on: [push, pull_request]
3
3
  jobs:
4
- ruby:
4
+ test:
5
5
  strategy:
6
+ fail-fast: false
6
7
  matrix:
7
- ruby: [2.4, 2.5, 2.6, 2.7, head, truffleruby-head]
8
- runs-on: ubuntu-latest
8
+ os: [ubuntu-latest, windows-latest, macos-latest]
9
+ ruby: [2.4, 2.5, 2.6, 2.7, 3.0, 3.1, head, jruby, jruby-head, truffleruby, truffleruby-head]
10
+ exclude:
11
+ - os: windows-latest
12
+ ruby: jruby
13
+ - os: windows-latest
14
+ ruby: jruby-head
15
+ - os: windows-latest
16
+ ruby: truffleruby
17
+ - os: windows-latest
18
+ ruby: truffleruby-head
19
+ runs-on: ${{ matrix.os }}
9
20
  steps:
10
21
  - uses: actions/checkout@v2
11
22
  - uses: ruby/setup-ruby@v1
12
23
  with:
13
24
  ruby-version: ${{ matrix.ruby }}
14
- - run: |
15
- bundle install
16
- bundle exec rake test
25
+ bundler-cache: true
26
+ - run: bundle exec rake test
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_schemer (0.2.17)
4
+ json_schemer (0.2.20)
5
5
  ecma-re-validator (~> 0.3)
6
6
  hana (~> 1.3)
7
7
  regexp_parser (~> 2.0)
@@ -13,9 +13,9 @@ GEM
13
13
  ecma-re-validator (0.3.0)
14
14
  regexp_parser (~> 2.0)
15
15
  hana (1.3.7)
16
- minitest (5.14.2)
16
+ minitest (5.14.3)
17
17
  rake (13.0.1)
18
- regexp_parser (2.0.0)
18
+ regexp_parser (2.1.1)
19
19
  uri_template (0.7.0)
20
20
 
21
21
  PLATFORMS
@@ -28,4 +28,4 @@ DEPENDENCIES
28
28
  rake (~> 13.0)
29
29
 
30
30
  BUNDLED WITH
31
- 2.1.4
31
+ 2.2.11
@@ -61,7 +61,6 @@ module JSONSchemer
61
61
  DateTime.rfc3339(data)
62
62
  DATE_TIME_OFFSET_REGEX.match?(data)
63
63
  rescue ArgumentError => e
64
- raise e unless e.message == 'invalid date'
65
64
  false
66
65
  end
67
66
 
@@ -355,8 +355,7 @@ module JSONSchemer
355
355
  validate_exclusive_minimum(instance, exclusive_minimum, minimum, &block) if exclusive_minimum
356
356
 
357
357
  if multiple_of
358
- quotient = data / multiple_of.to_f
359
- yield error(instance, 'multipleOf') unless quotient.floor == quotient
358
+ yield error(instance, 'multipleOf') unless BigDecimal(data.to_s).modulo(multiple_of).zero?
360
359
  end
361
360
  end
362
361
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module JSONSchemer
3
- VERSION = '0.2.17'
3
+ VERSION = '0.2.20'
4
4
  end
data/lib/json_schemer.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
  require 'base64'
3
+ require 'bigdecimal'
3
4
  require 'ipaddr'
4
5
  require 'json'
5
6
  require 'net/http'
6
7
  require 'pathname'
8
+ require 'set'
7
9
  require 'time'
8
10
  require 'uri'
9
11
 
@@ -37,10 +39,14 @@ module JSONSchemer
37
39
 
38
40
  DEFAULT_META_SCHEMA = 'http://json-schema.org/draft-07/schema#'
39
41
 
42
+ WINDOWS_URI_PATH_REGEX = /\A\/[a-z]:/i
43
+
40
44
  FILE_URI_REF_RESOLVER = proc do |uri|
41
45
  raise InvalidFileURI, 'must use `file` scheme' unless uri.scheme == 'file'
42
46
  raise InvalidFileURI, 'cannot have a host (use `file:///`)' if uri.host && !uri.host.empty?
43
- JSON.parse(File.read(uri.path))
47
+ path = uri.path
48
+ path = path[1..-1] if path.match?(WINDOWS_URI_PATH_REGEX)
49
+ JSON.parse(File.read(path))
44
50
  end
45
51
 
46
52
  class << self
@@ -49,7 +55,7 @@ module JSONSchemer
49
55
  when String
50
56
  schema = JSON.parse(schema)
51
57
  when Pathname
52
- uri = URI.parse("file://#{schema.realpath}")
58
+ uri = URI.parse(File.join('file:', schema.realpath))
53
59
  if options.key?(:ref_resolver)
54
60
  schema = FILE_URI_REF_RESOLVER.call(uri)
55
61
  else
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.17
4
+ version: 0.2.20
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-12-12 00:00:00.000000000 Z
11
+ date: 2022-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.1.2
156
+ rubygems_version: 3.1.4
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: JSON Schema validator. Supports drafts 4, 6, and 7.