rest_kat 0.0.6 → 0.0.7
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.
- data/VERSION +1 -1
- data/lib/rest_kat/validator.rb +30 -31
- data/rest_kat.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/rest_kat/validator.rb
CHANGED
@@ -3,50 +3,49 @@ require 'kwalify'
|
|
3
3
|
module RestKat
|
4
4
|
## validator class for answers
|
5
5
|
class Validator < Kwalify::Validator
|
6
|
-
## load schema definition
|
7
|
-
@@schema = Kwalify::Yaml.load_file( File.join Rails.root, "lib/rest_kit/api_schema.yml" )
|
8
|
-
def self.schema
|
9
|
-
@@schema
|
10
|
-
end
|
11
6
|
|
12
|
-
def
|
13
|
-
@
|
7
|
+
def schema
|
8
|
+
@schema
|
14
9
|
end
|
15
10
|
|
11
|
+
def self.load_schema file
|
12
|
+
Kwalify::Yaml.load_file file
|
13
|
+
end
|
14
|
+
|
16
15
|
def initialize type
|
17
16
|
super (@resource_schema=type)
|
18
17
|
end
|
19
18
|
|
20
|
-
def self.find_resource resource
|
21
|
-
|
19
|
+
def self.find_resource resource, schema
|
20
|
+
schema["resources"].find do |r|
|
22
21
|
r["name"].to_s == resource.to_s
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
|
-
def self.for_resource resource
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.for_type type
|
34
|
-
type = Validator.schema[type.to_s]
|
35
|
-
raise Exception.new("Can't find resource '#{resource}'") unless type
|
36
|
-
pp type
|
37
|
-
Validator.new type
|
25
|
+
def self.for_resource resource, file
|
26
|
+
schema = load_schema file
|
27
|
+
type = find_resource(resource, schema)["type"]
|
28
|
+
raise Exception.new("Can't find resource '#{resource}'") unless type
|
29
|
+
Validator.new type
|
38
30
|
end
|
39
31
|
|
40
|
-
def self.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
32
|
+
def self.for_type type, file
|
33
|
+
schema = load_schema file
|
34
|
+
type = schema[type.to_s]
|
35
|
+
raise Exception.new("Can't find resource '#{resource}'") unless type
|
36
|
+
Validator.new type
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.for_resource_collection resource, file
|
40
|
+
schema = load_schema file
|
41
|
+
type = find_resource(resource, schema)["type"]
|
42
|
+
|
43
|
+
collection_type = {
|
44
|
+
"type" => "seq",
|
45
|
+
"sequence" => [ type ]
|
46
|
+
}
|
47
|
+
Validator.new collection_type
|
48
|
+
end
|
50
49
|
|
51
50
|
end
|
52
51
|
|
data/rest_kat.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rest_kat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brad Phelan
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
requirements:
|
111
111
|
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
hash:
|
113
|
+
hash: 2938506668854447310
|
114
114
|
segments:
|
115
115
|
- 0
|
116
116
|
version: "0"
|