adamsalter-ken 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/ken.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ken}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["michael"]
9
- s.date = %q{2009-08-12}
9
+ s.date = %q{2009-07-24}
10
10
  s.email = %q{ma[at]zive[dot]at}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
data/lib/ken/resource.rb CHANGED
@@ -2,8 +2,6 @@ module Ken
2
2
  class Resource
3
3
  include Extlib::Assertions
4
4
 
5
- attr_reader :data
6
-
7
5
  # initializes a resource using a json result
8
6
  def initialize(data)
9
7
  assert_kind_of 'data', data, Hash
@@ -56,7 +54,7 @@ module Ken
56
54
  # @api public
57
55
  def view(type)
58
56
  types.each { |t| return Ken::View.new(self, t) if t.id =~ /^#{Regexp.escape(type)}$/ }
59
- nil
57
+ raise ViewNotFound
60
58
  end
61
59
 
62
60
  # returns all the properties from all assigned types
@@ -76,13 +74,6 @@ module Ken
76
74
  @attributes.values
77
75
  end
78
76
 
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
-
86
77
  # returns true if type information is already loaded
87
78
  # @api public
88
79
  def schema_loaded?
data/lib/ken/view.rb CHANGED
@@ -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
- nil
41
+ raise AttributeNotFound
42
42
  end
43
43
 
44
44
  # returns properties which are member of the view's type
@@ -47,7 +47,7 @@ module Ken
47
47
  @resource.properties.select { |p| p.type == @type}
48
48
  end
49
49
 
50
- # delegate to attribute
50
+ # delegate to attribute_get
51
51
  def method_missing sym
52
52
  attribute(sym.to_s)
53
53
  end
@@ -18,11 +18,6 @@ class ResourceTest < Test::Unit::TestCase
18
18
  @the_police.views.first.type.should be_kind_of(Ken::Type)
19
19
  end
20
20
 
21
- should "return individual view based requested type" do
22
- @the_police.view('/music/artist').should be_kind_of(Ken::View)
23
- @the_police.view('/location/location').should be_nil # not existent view
24
- end
25
-
26
21
  should 'have a full set of attributes' do
27
22
  @the_police.attributes.should_not be_nil
28
23
  end
@@ -26,7 +26,7 @@ class ViewTest < Test::Unit::TestCase
26
26
 
27
27
  context "when accessing a direct attribute" do
28
28
  setup do
29
- @genre = @view.attribute('genre')
29
+ @genre = @view.genre
30
30
  @album = @view.album
31
31
  end
32
32
 
@@ -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
- @view.not_existing_attribute.should be_nil
44
+ lambda { @view.not_existing_attribute }.should raise_error(Ken::AttributeNotFound)
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - michael
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 -07:00
12
+ date: 2009-07-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency