adamsalter-ken 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ken}
5
- s.version = "0.1.2"
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
+
@@ -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
- raise ViewNotFound
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?
@@ -38,7 +38,7 @@ module Ken
38
38
  # @api public
39
39
  def attribute(name)
40
40
  attributes.each { |a| return a if a.property.id =~ /\/#{name}$/ }
41
- raise AttributeNotFound
41
+ nil
42
42
  end
43
43
 
44
44
  # returns properties which are member of the view's type
@@ -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
- lambda { @view.not_existing_attribute }.should raise_error(Ken::AttributeNotFound)
44
+ @view.not_existing_attribute.should be_nil
45
45
  end
46
46
  end # context
47
47
  end # context
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adamsalter-ken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - michael