jimmy 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jimmy/reference.rb +10 -6
- data/lib/jimmy/schema_creation.rb +3 -3
- data/lib/jimmy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34798f1a348146e90f429b56679534c18b4abd0b
|
4
|
+
data.tar.gz: 573d2b3df49c893a637e59add2c6072d8594abb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e84ef0ceaa4662559bfac862e456430e3b70cc6eb3fec016d4952b8fb99177795bd0eefa9f349cba509231d828ca50ff4a73523c678fa7467792be3f9180ff90
|
7
|
+
data.tar.gz: 9990a5a746d8ad34114832f4d5d83aa7fb42996eb3842a26cba58f789b2e0747b77ed5c8325c659c1452742eb12796d31705b39760b16c92f591a84abbafd50e
|
data/lib/jimmy/reference.rb
CHANGED
@@ -1,23 +1,27 @@
|
|
1
1
|
module Jimmy
|
2
2
|
class Reference
|
3
|
-
|
3
|
+
include SchemaCreation::MetadataMethods
|
4
|
+
attr_reader :uri, :data
|
4
5
|
|
5
|
-
def initialize(uri, nullable = false)
|
6
|
+
def initialize(uri, nullable = false, *args, **opts, &block)
|
6
7
|
@uri = uri
|
7
8
|
@nullable = nullable
|
9
|
+
@data = {}
|
10
|
+
args.each { |arg| __send__ arg }
|
11
|
+
opts.each { |arg| __send__ *arg }
|
12
|
+
instance_exec &block if block
|
8
13
|
end
|
9
14
|
|
10
15
|
def compile
|
11
|
-
|
16
|
+
data.merge(nullable? ?
|
12
17
|
{
|
13
18
|
'anyOf' => [
|
14
19
|
{'type' => 'null'},
|
15
20
|
ref_hash
|
16
21
|
]
|
17
|
-
}
|
18
|
-
else
|
22
|
+
} :
|
19
23
|
ref_hash
|
20
|
-
|
24
|
+
)
|
21
25
|
end
|
22
26
|
|
23
27
|
def nullable?
|
@@ -32,7 +32,7 @@ module Jimmy
|
|
32
32
|
module Referencing
|
33
33
|
def method_missing(name, *args, &block)
|
34
34
|
if schema.definitions[name]
|
35
|
-
ref *args, definition(name)
|
35
|
+
ref *args, definition(name), &block
|
36
36
|
else
|
37
37
|
super
|
38
38
|
end
|
@@ -46,9 +46,9 @@ module Jimmy
|
|
46
46
|
"/#{schema.name}#/definitions/#{id}"
|
47
47
|
end
|
48
48
|
|
49
|
-
def ref(*args, uri)
|
49
|
+
def ref(*args, uri, &block)
|
50
50
|
handler = SchemaCreation.handlers[self.class]
|
51
|
-
instance_exec(Reference.new(uri), *args, &handler) if handler
|
51
|
+
instance_exec(Reference.new(uri, &block), *args, &handler) if handler
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
data/lib/jimmy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jimmy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil E. Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|