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 CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -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 resource_schema
13
- @resource_schema
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
- Validator.schema["resources"].find do |r|
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
- type = find_resource(resource)["type"]
28
- raise Exception.new("Can't find resource '#{resource}'") unless type
29
- pp type
30
- Validator.new type
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.for_resource_collection resource
41
- type = find_resource(resource)["type"]
42
- raise Exception.new("Can't find resource '#{resource}'") unless type
43
- collection_type = {
44
- "type" => "seq",
45
- "sequence" => [ type ]
46
- }
47
-
48
- Validator.new collection_type
49
- end
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rest_kat}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Brad Phelan}]
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.6
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: 453860479478973850
113
+ hash: 2938506668854447310
114
114
  segments:
115
115
  - 0
116
116
  version: "0"