blumquist 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/blumquist.rb +9 -8
- data/lib/blumquist/errors.rb +1 -0
- data/lib/blumquist/errors/invalid_pointer.rb +9 -0
- data/lib/blumquist/errors/missing_array_items_type.rb +9 -0
- data/lib/blumquist/errors/unsupported_type.rb +9 -0
- data/lib/blumquist/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc1879163c3a69fbfd3790e9be1e3a702429efa0
|
4
|
+
data.tar.gz: 9ba85c4383afcc83343cfe46d3cc6489605ba9fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a612a42a7947923848e9b78e06131e02c59b70bfa9021926a12c1b14a3d417a0b65d04a4ae2062f7a7509fd8881a0e3b9e71c47e8b94e98eb850ccd1a5f9cee5
|
7
|
+
data.tar.gz: d403bda45208090896a0c5d489b3c4b9567aaea22ac67edc4761226e0c3174a696b7eac29b1cf951cea73f2a37372f3147d970d73969ecb82ef5a382144eb11b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Blumquist [![Circle CI](https://circleci.com/gh/moviepilot/blumquist/tree/master.svg?style=
|
1
|
+
# Blumquist [![Circle CI](https://circleci.com/gh/moviepilot/blumquist/tree/master.svg?style=shield)](https://circleci.com/gh/moviepilot/blumquist/tree/master) [![Coverage Status](https://coveralls.io/repos/moviepilot/blumquist/badge.svg?branch=master&service=github)](https://coveralls.io/github/moviepilot/blumquist?branch=master) [![Gem Version](https://badge.fury.io/rb/blumquist.svg)](https://badge.fury.io/rb/blumquist)
|
2
2
|
|
3
3
|
![](https://dl.dropboxusercontent.com/u/1953503/blumquist.jpg)
|
4
4
|
|
data/lib/blumquist.rb
CHANGED
@@ -2,6 +2,7 @@ require "blumquist/version"
|
|
2
2
|
require 'active_support/core_ext/hash/indifferent_access'
|
3
3
|
require 'json'
|
4
4
|
require 'json-schema'
|
5
|
+
require 'blumquist/errors'
|
5
6
|
|
6
7
|
class Blumquist
|
7
8
|
def initialize(options)
|
@@ -17,7 +18,7 @@ class Blumquist
|
|
17
18
|
define_getters
|
18
19
|
end
|
19
20
|
|
20
|
-
private
|
21
|
+
private
|
21
22
|
|
22
23
|
def validate_data
|
23
24
|
return unless @validate
|
@@ -25,15 +26,14 @@ class Blumquist
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def validate_schema
|
28
|
-
if @schema[:type]
|
29
|
-
|
30
|
-
end
|
29
|
+
return if @schema[:type] == 'object'
|
30
|
+
raise(Errors::UnsupportedType, @schema[:type])
|
31
31
|
end
|
32
32
|
|
33
33
|
def resolve_json_pointers
|
34
34
|
@schema[:properties].each do |property, type_def|
|
35
35
|
next unless type_def[:$ref]
|
36
|
-
resolve_json_pointer!(type_def)
|
36
|
+
resolve_json_pointer!(type_def)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -43,7 +43,7 @@ class Blumquist
|
|
43
43
|
key = pointer.split('/').last
|
44
44
|
definition = @schema[:definitions][key]
|
45
45
|
|
46
|
-
raise
|
46
|
+
raise(Errors::InvalidPointer, pointer) unless definition
|
47
47
|
|
48
48
|
type_def.merge! definition
|
49
49
|
end
|
@@ -68,7 +68,7 @@ class Blumquist
|
|
68
68
|
|
69
69
|
# We don't know what to do, so let's panic
|
70
70
|
else
|
71
|
-
raise
|
71
|
+
raise(Errors::UnsupportedType, type_def[:type])
|
72
72
|
end
|
73
73
|
|
74
74
|
# And define the getter
|
@@ -77,7 +77,7 @@ class Blumquist
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def define_getter(property)
|
80
|
-
self.class.class_eval do
|
80
|
+
self.class.class_eval do
|
81
81
|
define_method(property) do
|
82
82
|
@data[property]
|
83
83
|
end
|
@@ -93,6 +93,7 @@ class Blumquist
|
|
93
93
|
|
94
94
|
def blumquistify_array(property)
|
95
95
|
item_schema = resolve_json_pointer!(@schema[:properties][property][:items])
|
96
|
+
raise(Errors::MissingArrayItemsType, @schema[:properties][property]) unless item_schema
|
96
97
|
sub_schema = item_schema.merge(
|
97
98
|
definitions: @schema[:definitions]
|
98
99
|
)
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'blumquist/errors/unsupported_type'
|
data/lib/blumquist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blumquist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jannis Hermanns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -168,6 +168,10 @@ files:
|
|
168
168
|
- Rakefile
|
169
169
|
- blumquist.gemspec
|
170
170
|
- lib/blumquist.rb
|
171
|
+
- lib/blumquist/errors.rb
|
172
|
+
- lib/blumquist/errors/invalid_pointer.rb
|
173
|
+
- lib/blumquist/errors/missing_array_items_type.rb
|
174
|
+
- lib/blumquist/errors/unsupported_type.rb
|
171
175
|
- lib/blumquist/version.rb
|
172
176
|
homepage: https://github.com/moviepilot/blumquist
|
173
177
|
licenses:
|