schai 0.1.1 → 0.2.0
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 +4 -4
- data/lib/schai.rb +14 -7
- data/lib/schai/json_schema/js_object.rb +4 -0
- data/lib/schai/json_schema/js_root.rb +12 -10
- data/lib/schai/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: e440f870638d3ccde9bf0c8e8a8161aefb6bc533
|
4
|
+
data.tar.gz: 118a6e81d6fcd1d87daa32d8926fa27362357691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f65464c07a36e7543dd865a58e1f7411c2e418e33e0265469e9fd95ac0b8129c063a838dcf965e246a3735fb9ccd83c82bef6a793a23214f7e31766fc2082abc
|
7
|
+
data.tar.gz: 2300fb30fcbc81a4869050d65e5fe9dc96501fe93314cd4ba0943c0be9435b7d622a7b38486ea77c13a865c92d9d85ea61076bce578ed7e1739da8f82a4e51e2
|
data/lib/schai.rb
CHANGED
@@ -11,17 +11,24 @@ module Schai
|
|
11
11
|
JsRoot.parse params
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.
|
14
|
+
def self.path
|
15
15
|
@@path ||=[]
|
16
|
-
|
17
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.current_parsing_file? path
|
19
|
+
File.expand_path("../#{path}", Schai.path.last) == Schai.path.last
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.parse_file path
|
23
|
+
if Schai.path.empty?
|
24
|
+
Schai.path << path
|
18
25
|
ret = parse YAML.load_file(path)
|
19
|
-
|
26
|
+
Schai.path.pop
|
20
27
|
else
|
21
|
-
expand_path = File.expand_path("../#{path}",
|
22
|
-
|
28
|
+
expand_path = File.expand_path("../#{path}", Schai.path.last)
|
29
|
+
Schai.path << expand_path
|
23
30
|
ret = parse YAML.load_file(expand_path)
|
24
|
-
|
31
|
+
Schai.path.pop
|
25
32
|
end
|
26
33
|
ret
|
27
34
|
end
|
@@ -7,6 +7,10 @@ module Schai
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize params
|
10
|
+
params["properties"].select! do |k, e|
|
11
|
+
!(Schai.current_parsing_file?(e['include']) and e['optional'])
|
12
|
+
end
|
13
|
+
|
10
14
|
@all = Hash[params["properties"].map {|k, v|
|
11
15
|
[k || 'null', JsRoot.parse_components(v)]
|
12
16
|
}]
|
@@ -3,26 +3,28 @@ module Schai
|
|
3
3
|
attr_accessor :schema
|
4
4
|
|
5
5
|
def self.parse params
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
self.new.tap do |js_root|
|
7
|
+
js_root.schema = parse_components params
|
8
|
+
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.parse_components params
|
12
|
-
|
13
|
-
|
12
|
+
# include other .yaml file
|
13
|
+
if params.has_key?('include')
|
14
14
|
included_schema = Schai.parse_file(params.delete('include')).schema
|
15
15
|
params.each do |k, v|
|
16
16
|
setter = "#{k}=".to_sym
|
17
17
|
included_schema.send(setter, v)
|
18
18
|
end
|
19
|
-
included_schema
|
20
|
-
|
19
|
+
return included_schema
|
20
|
+
end
|
21
|
+
|
22
|
+
raise "typeは必須(#{params})" unless params.has_key?('type')
|
23
|
+
case params['type']
|
24
|
+
when 'object'
|
21
25
|
JsObject.parse params
|
22
|
-
when
|
26
|
+
when 'array'
|
23
27
|
JsArray.parse params
|
24
|
-
when !params.has_key?('type')
|
25
|
-
raise "typeは必須(#{params})"
|
26
28
|
else
|
27
29
|
JsProperty.parse params
|
28
30
|
end
|
data/lib/schai/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gin0606
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|