json_schema 0.13.0 → 0.13.2

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
  SHA1:
3
- metadata.gz: 509ee330f57ccc1fc0ad812a0be82cceeeab7461
4
- data.tar.gz: 7c284cc6d026a7191df85776b0c6913ea6daf23a
3
+ metadata.gz: b1f24463b2049d196fe0ed73305146600d50c870
4
+ data.tar.gz: c97c5109678c9786a12219b364640dbe22afd25c
5
5
  SHA512:
6
- metadata.gz: 419c0c1045a265e0cea0a32483d14cd15f7d8b7deceba263a4647b7f33450056b599cf87fb886fc24d696dda306c7c873106d92156e45175cff079ddef85bf64
7
- data.tar.gz: 89df42d2dfdfcd8849dd74470634485b19d4554061bb9a4c119d92bc854d0f887ab6e04c6697f0684236eaabe5bceac97aed7d55cc05997ad95f4403ebb8fb96
6
+ metadata.gz: dba523a357a759cedd359bfc7a11ba72ab2ab4344f038363ae809ec20008bbfe377435929f93d68c56865c1407f17f952f7e30532893cca28f132891ad66d072
7
+ data.tar.gz: 60b178db7b14223cb13a37ee7b06879975fd007b6e487261b2ec8e5cbcd6fa97dd0224e326fbfba898e5ae4b8cbbbc0696210df5bba6f2874c2bf5c8ed6ee914
@@ -13,6 +13,9 @@ module JsonReference
13
13
  attr_accessor :uri
14
14
 
15
15
  def initialize(ref)
16
+ # Note that the #to_s of `nil` is an empty string.
17
+ @uri = nil
18
+
16
19
  # given a simple fragment without '#', resolve as a JSON Pointer only as
17
20
  # per spec
18
21
  if ref.include?("#")
@@ -12,6 +12,9 @@ module JsonSchema
12
12
  end
13
13
 
14
14
  def self.attr_reader_default(attr, default)
15
+ # remove the reader already created by attr_accessor
16
+ remove_method(attr)
17
+
15
18
  class_eval("def #{attr} ; !@#{attr}.nil? ? @#{attr} : #{default} ; end")
16
19
  end
17
20
 
@@ -283,11 +286,11 @@ module JsonSchema
283
286
 
284
287
  # schema attributes
285
288
  attr_accessor :description
286
- attr_accessor :enc_type
289
+ attr_writer :enc_type
287
290
  attr_accessor :href
291
+ attr_writer :media_type
288
292
  attr_accessor :method
289
293
  attr_accessor :rel
290
- attr_accessor :media_type
291
294
  attr_accessor :schema
292
295
  attr_accessor :target_schema
293
296
  attr_accessor :title
@@ -52,7 +52,7 @@ describe JsonSchema::Parser do
52
52
 
53
53
  it "parses array validations" do
54
54
  schema = parse.definitions["app"].definitions["flags"]
55
- assert_equal /^[a-z][a-z\-]*[a-z]$/, schema.items.pattern
55
+ assert_equal(/^[a-z][a-z\-]*[a-z]$/, schema.items.pattern)
56
56
  assert_equal 1, schema.min_items
57
57
  assert_equal 10, schema.max_items
58
58
  assert_equal true, schema.unique_items
@@ -140,7 +140,7 @@ describe JsonSchema::Parser do
140
140
  it "parses the patternProperties object validation" do
141
141
  schema = parse.definitions["app"].definitions["config_vars"]
142
142
  property = schema.pattern_properties.first
143
- assert_equal /^\w+$/, property[0]
143
+ assert_equal(/^\w+$/, property[0])
144
144
  assert_equal ["null", "string"], property[1].type
145
145
  end
146
146
 
@@ -171,7 +171,7 @@ describe JsonSchema::Parser do
171
171
  schema = parse.definitions["app"].definitions["name"]
172
172
  assert_equal 30, schema.max_length
173
173
  assert_equal 3, schema.min_length
174
- assert_equal /^[a-z][a-z0-9-]{3,30}$/, schema.pattern
174
+ assert_equal(/^[a-z][a-z0-9-]{3,30}$/, schema.pattern)
175
175
  end
176
176
 
177
177
  it "parses hypermedia links" do
@@ -214,7 +214,6 @@ describe JsonSchema::Parser do
214
214
  "type" => "image/png"
215
215
  )
216
216
  schema = parse.definitions["app"]
217
- media = JsonSchema::Schema::Media.new
218
217
  assert_equal "base64", schema.media.binary_encoding
219
218
  assert_equal "image/png", schema.media.type
220
219
  end
@@ -79,15 +79,15 @@ describe JsonSchema::ReferenceExpander do
79
79
  expand
80
80
  assert_equal [], error_messages
81
81
  schema = @schema.properties["app"].definitions["contrived_plus"]
82
- assert_equal /^(foo|aaa)$/, schema.one_of[0].pattern
83
- assert_equal /^(foo|zzz)$/, schema.one_of[1].pattern
82
+ assert_equal(/^(foo|aaa)$/, schema.one_of[0].pattern)
83
+ assert_equal(/^(foo|zzz)$/, schema.one_of[1].pattern)
84
84
  end
85
85
 
86
86
  it "will expand not" do
87
87
  expand
88
88
  assert_equal [], error_messages
89
89
  schema = @schema.properties["app"].definitions["contrived_plus"]
90
- assert_equal /^$/, schema.not.pattern
90
+ assert_equal(/^$/, schema.not.pattern)
91
91
  end
92
92
 
93
93
  it "will expand additionalProperties" do
@@ -7,6 +7,7 @@ describe JsonSchema do
7
7
  it "succeeds" do
8
8
  schema, errors = JsonSchema.parse(schema_sample)
9
9
  assert schema
10
+ assert_equal nil, errors
10
11
  end
11
12
 
12
13
  it "returns errors on a parsing problem" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-25 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecma-re-validator
@@ -52,6 +52,48 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  description:
56
98
  email:
57
99
  - brandur@mutelight.org