adamsalter-ken 0.1.2 → 0.1.3
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/ken.gemspec +2 -1
- data/lib/ken/resource.rb +10 -1
- data/lib/ken/view.rb +1 -1
- data/test/unit/view_test.rb +1 -1
- metadata +1 -1
data/ken.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{ken}
|
|
5
|
-
s.version = "0.1.
|
|
5
|
+
s.version = "0.1.3"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["michael"]
|
|
@@ -86,3 +86,4 @@ Gem::Specification.new do |s|
|
|
|
86
86
|
s.add_dependency(%q<addressable>, [">= 0"])
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
|
+
|
data/lib/ken/resource.rb
CHANGED
|
@@ -2,6 +2,8 @@ module Ken
|
|
|
2
2
|
class Resource
|
|
3
3
|
include Extlib::Assertions
|
|
4
4
|
|
|
5
|
+
attr_reader :data
|
|
6
|
+
|
|
5
7
|
# initializes a resource using a json result
|
|
6
8
|
def initialize(data)
|
|
7
9
|
assert_kind_of 'data', data, Hash
|
|
@@ -54,7 +56,7 @@ module Ken
|
|
|
54
56
|
# @api public
|
|
55
57
|
def view(type)
|
|
56
58
|
types.each { |t| return Ken::View.new(self, t) if t.id =~ /^#{Regexp.escape(type)}$/ }
|
|
57
|
-
|
|
59
|
+
nil
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
# returns all the properties from all assigned types
|
|
@@ -74,6 +76,13 @@ module Ken
|
|
|
74
76
|
@attributes.values
|
|
75
77
|
end
|
|
76
78
|
|
|
79
|
+
# search for an attribute by name and return it
|
|
80
|
+
# @api public
|
|
81
|
+
def attribute(name)
|
|
82
|
+
attributes.each { |a| return a if a.property.id == name }
|
|
83
|
+
nil
|
|
84
|
+
end
|
|
85
|
+
|
|
77
86
|
# returns true if type information is already loaded
|
|
78
87
|
# @api public
|
|
79
88
|
def schema_loaded?
|
data/lib/ken/view.rb
CHANGED
data/test/unit/view_test.rb
CHANGED
|
@@ -41,7 +41,7 @@ class ViewTest < Test::Unit::TestCase
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
should "raise AttributeNotFound when invalid propertyname is supplied" do
|
|
44
|
-
|
|
44
|
+
@view.not_existing_attribute.should be_nil
|
|
45
45
|
end
|
|
46
46
|
end # context
|
|
47
47
|
end # context
|