json_schemer 0.2.3 → 0.2.4

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: ad4883bcdfb3cac627d3b20c3ab74c0ebf4a3b3ce9f95b59cc653b60f2771580
4
- data.tar.gz: bbb0a784d78974b3a812becdb354222e145a642ef9162c6e8bd6d74578994024
3
+ metadata.gz: a8a183671565c8bc3443ea0cb0b729858c4c34208c45da986bc2994504d1dfa3
4
+ data.tar.gz: dc7005acad88d864d4c7a5781fb0fd9d3e5ec7f78cd152db0cad9591ce650eb5
5
5
  SHA512:
6
- metadata.gz: cf54450f55764c1c50751173db9008babda7befde4012b1e434ed7087134e2e5f053cbc35977cf58b96a8a4b7176302ed03731bddeb192e8aca3f29e79622eff
7
- data.tar.gz: 464a4611a5261cba8e5a4c1acac299eb51342b1c06da90950e9f6aa826dabf4256feed1959247262310b66c061776a4f1f262bdc0028e29205097efec328b3c9
6
+ metadata.gz: b5c165cb49f7fb1e0d2253542a0b5d14bf6c624d474fea09ec3e1727ae0f443f74242b423c4f4478b61cb648654e87e7e52dca458792ae4bc771705a2efb999b
7
+ data.tar.gz: 6e507392188f78799924393b992eb646933fa9ce046b527d89bd368d7e24691d98e2fb4c6286e57e66ff25f6cfc775c5f09a76184433cdfe479ae1681f522ee3
@@ -4,6 +4,10 @@ rvm:
4
4
  - 2.6
5
5
  - 2.5
6
6
  - 2.4
7
+ - 2.3
8
+ - 2.2
9
+ - 2.1
10
+ - 2.0
7
11
  before_install: gem install bundler -v 1.16.1
8
12
  before_script:
9
13
  - pip install --user Flask
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_schemer (0.2.3)
4
+ json_schemer (0.2.4)
5
5
  ecma-re-validator (~> 0.2)
6
6
  hana (~> 1.3)
7
7
  regexp_parser (~> 1.5)
@@ -22,10 +22,10 @@ PLATFORMS
22
22
  ruby
23
23
 
24
24
  DEPENDENCIES
25
- bundler (~> 2.0)
25
+ bundler (~> 1.16)
26
26
  json_schemer!
27
27
  minitest (~> 5.0)
28
28
  rake (~> 10.0)
29
29
 
30
30
  BUNDLED WITH
31
- 2.0.2
31
+ 1.17.3
@@ -20,7 +20,9 @@ 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.add_development_dependency "bundler", "~> 2.0"
23
+ spec.required_ruby_version = '~> 2.0'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
24
26
  spec.add_development_dependency "rake", "~> 10.0"
25
27
  spec.add_development_dependency "minitest", "~> 5.0"
26
28
 
@@ -108,18 +108,18 @@ module JSONSchemer
108
108
 
109
109
  def valid_date_time?(data)
110
110
  DateTime.rfc3339(data)
111
- DATE_TIME_OFFSET_REGEX.match?(data)
111
+ !!(DATE_TIME_OFFSET_REGEX =~ data)
112
112
  rescue ArgumentError => e
113
113
  raise e unless e.message == 'invalid date'
114
114
  false
115
115
  end
116
116
 
117
117
  def valid_email?(data)
118
- EMAIL_REGEX.match?(data)
118
+ !!(EMAIL_REGEX =~ data)
119
119
  end
120
120
 
121
121
  def valid_hostname?(data)
122
- HOSTNAME_REGEX.match?(data) && data.split('.').all? { |label| label.size <= 63 }
122
+ !!(HOSTNAME_REGEX =~ data && data.split('.').all? { |label| label.size <= 63 })
123
123
  end
124
124
 
125
125
  def valid_ip?(data, type)
@@ -130,11 +130,11 @@ module JSONSchemer
130
130
  end
131
131
 
132
132
  def valid_iri?(data)
133
- IRI.match?(data)
133
+ !!(IRI =~ data)
134
134
  end
135
135
 
136
136
  def valid_iri_reference?(data)
137
- IRELATIVE_REF.match?(data)
137
+ !!(IRELATIVE_REF =~ data)
138
138
  end
139
139
 
140
140
  def valid_uri_template?(data)
@@ -145,11 +145,11 @@ module JSONSchemer
145
145
  end
146
146
 
147
147
  def valid_json_pointer?(data)
148
- JSON_POINTER_REGEX.match?(data)
148
+ !!(JSON_POINTER_REGEX =~ data)
149
149
  end
150
150
 
151
151
  def valid_relative_json_pointer?(data)
152
- RELATIVE_JSON_POINTER_REGEX.match?(data)
152
+ !!(RELATIVE_JSON_POINTER_REGEX =~ data)
153
153
  end
154
154
  end
155
155
  end
@@ -470,7 +470,13 @@ module JSONSchemer
470
470
  if insert_property_defaults?
471
471
  properties.each do |property, property_schema|
472
472
  if !data.key?(property) && property_schema.key?('default')
473
- data[property] = property_schema.fetch('default').clone
473
+ default = property_schema.fetch('default')
474
+ data[property] = case default
475
+ when Numeric, Symbol, true, false, nil
476
+ default
477
+ else
478
+ default.clone
479
+ end
474
480
  end
475
481
  end
476
482
  end
@@ -520,7 +526,7 @@ module JSONSchemer
520
526
  [pattern, ecma_262_regex(pattern), property_schema]
521
527
  end
522
528
  regex_pattern_properties.each do |pattern, regex, property_schema|
523
- if regex.match?(key)
529
+ if regex =~ key
524
530
  subinstance = instance.merge(
525
531
  data: value,
526
532
  data_pointer: "#{instance.data_pointer}/#{key}",
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module JSONSchemer
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schemer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Harsha
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '1.16'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -144,9 +144,9 @@ require_paths:
144
144
  - lib
145
145
  required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - ">="
147
+ - - "~>"
148
148
  - !ruby/object:Gem::Version
149
- version: '0'
149
+ version: '2.0'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="