activerdf 1.5 → 1.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,6 @@
1
- == activerdf (1.6)
2
- * TODO: remove ObjectManager.construct_classes (classes exist automagically after Namespace.register)
1
+ == activerdf (1.6) Thu, 12 Apr 2007 23:12:40 +0100
2
+ * no need for ObjectManager.construct_classes anymore (classes exist automagically after Namespace.register)
3
+ * added resource.localname (alias for Namespace.localname(resource))
3
4
 
4
5
  == activerdf (1.5) Thu, 12 Apr 2007 22:42:28 +0100
5
6
  * allows directly using classes in query: where(:s, RDF::type, SIOC::Post)
@@ -31,6 +31,10 @@ class Namespace
31
31
  Namespace.lookup(self.to_s.downcase.to_sym, method)
32
32
  end
33
33
 
34
+ def const_missing(klass)
35
+ Namespace.lookup(self.to_s.downcase.to_sym, klass)
36
+ end
37
+
34
38
  # make some builtin methods private because lookup doesn't work otherwise
35
39
  # on e.g. RDF::type and FOAF::name
36
40
  [:type, :name, :id].each {|m| private(m) }
@@ -145,6 +145,10 @@ module RDFS
145
145
  end
146
146
  end
147
147
 
148
+ def localname
149
+ Namespace.localname(self)
150
+ end
151
+
148
152
  # manages invocations such as eyal.age
149
153
  def method_missing(method, *args)
150
154
  # possibilities:
@@ -9,9 +9,9 @@ require "#{File.dirname(__FILE__)}/../common"
9
9
 
10
10
  class TestNamespace < Test::Unit::TestCase
11
11
  Rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
12
- RdfType = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
13
- RdfsResource = 'http://www.w3.org/2000/01/rdf-schema#Resource'
14
12
  Rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
13
+ RdfType = RDFS::Resource.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
14
+ RdfsResource = RDFS::Resource.new('http://www.w3.org/2000/01/rdf-schema#Resource')
15
15
 
16
16
  def setup
17
17
  end
@@ -23,23 +23,25 @@ class TestNamespace < Test::Unit::TestCase
23
23
  rdftype = RdfType
24
24
  rdfsresource = RdfsResource
25
25
 
26
- assert_equal rdftype, Namespace.expand(:rdf, :type)
27
- assert_equal rdftype, Namespace.expand(:rdf, 'type')
28
- assert_equal rdftype, Namespace.expand('rdf', :type)
29
- assert_equal rdftype, Namespace.expand('rdf', 'type')
26
+ assert_equal rdftype, RDF::type
27
+ assert_equal rdftype, Namespace.lookup(:rdf, :type)
28
+ assert_equal rdftype, Namespace.lookup(:rdf, 'type')
29
+ assert_equal rdftype, Namespace.lookup('rdf', :type)
30
+ assert_equal rdftype, Namespace.lookup('rdf', 'type')
30
31
 
31
- assert_equal rdfsresource, Namespace.expand(:rdfs, :Resource)
32
- assert_equal rdfsresource, Namespace.expand(:rdfs, 'Resource')
33
- assert_equal rdfsresource, Namespace.expand('rdfs', :Resource)
34
- assert_equal rdfsresource, Namespace.expand('rdfs', 'Resource')
32
+ assert_equal rdfsresource, RDFS::Resource
33
+ assert_equal rdfsresource, Namespace.lookup(:rdfs, :Resource)
34
+ assert_equal rdfsresource, Namespace.lookup(:rdfs, 'Resource')
35
+ assert_equal rdfsresource, Namespace.lookup('rdfs', :Resource)
36
+ assert_equal rdfsresource, Namespace.lookup('rdfs', 'Resource')
35
37
  end
36
38
 
37
- def test_default_ns_lookup
39
+ def test_registration_of_rdf_and_rdfs
38
40
  rdftype = RDFS::Resource.new RdfType
39
41
  rdfsresource = RDFS::Resource.new RdfsResource
40
42
 
41
- assert_equal rdftype, Namespace.lookup(:rdf, :type)
42
- assert_equal rdfsresource, Namespace.lookup(:rdfs, :Resource)
43
+ assert_equal rdftype, RDF::type
44
+ assert_equal rdfsresource, RDFS::Resource
43
45
  end
44
46
 
45
47
  def test_find_prefix
@@ -52,15 +54,19 @@ class TestNamespace < Test::Unit::TestCase
52
54
 
53
55
  def test_class_localname
54
56
  assert_equal 'type', Namespace.localname(Namespace.lookup(:rdf, :type))
57
+ assert_equal 'type', RDF::type.localname
58
+
55
59
  assert_equal 'Class', Namespace.localname(Namespace.lookup(:rdfs, :Class))
60
+ assert_equal 'Class', RDFS::Class.localname
56
61
  end
57
62
 
58
63
  def test_class_register
59
64
  test = 'http://test.org/'
60
- abc = "#{test}abc"
65
+ abc = RDFS::Resource.new("#{test}abc")
61
66
  Namespace.register :test, test
62
67
 
63
- assert_equal abc, Namespace.expand(:test, :abc)
68
+ assert_equal abc, Namespace.lookup(:test, :abc)
69
+ assert_equal abc, TEST::abc
64
70
  end
65
71
 
66
72
  def test_attributes
@@ -54,7 +54,6 @@ class TestObjectManager < Test::Unit::TestCase
54
54
  adapter = get_write_adapter
55
55
  adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
56
56
  Namespace.register(:test, 'http://activerdf.org/test/')
57
- ObjectManager.construct_classes
58
57
 
59
58
  assert_equal RDFS::Resource.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), RDF::type
60
59
  assert_equal RDF::type, RDFS::Resource.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
@@ -13,7 +13,6 @@ class TestResourceReading < Test::Unit::TestCase
13
13
  @adapter = get_adapter
14
14
  @adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
15
15
  Namespace.register(:test, 'http://activerdf.org/test/')
16
- ObjectManager.construct_classes
17
16
 
18
17
  @eyal = RDFS::Resource.new 'http://activerdf.org/test/eyal'
19
18
  end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: activerdf
5
5
  version: !ruby/object:Gem::Version
6
- version: "1.5"
6
+ version: "1.6"
7
7
  date: 2007-04-12 00:00:00 +01:00
8
8
  summary: Offers object-oriented access to RDF (with adapters to several datastores).
9
9
  require_paths: