public
Rubygem
Description: Rena is a Ruby RDF library that I'm trying to help extend.
Clone URL: git://github.com/tommorris/rena.git
created method to test N3 and XML namespace prefixability and tests - 
should add a proper exception to erroneous namespaces
tommorris (author)
Mon May 12 03:42:16 -0700 2008
commit  db4669a0431bc9a9bd457a1793fc5c537659797a
tree    5a23f3d5fd4d4fd776a906354a1af004f0a99fb1
parent  4c57a4d5bbb810c32992b60c403fa640862e1e40
...
3
4
5
6
 
 
 
 
 
7
8
9
10
11
 
 
 
 
 
 
 
 
 
12
13
...
3
4
5
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
0
@@ -3,10 +3,23 @@ require 'lib/uriref'
0
 class Namespace
0
   def initialize(uri, short)
0
     @uri = uri
0
- @short = short
0
+ if shortname_valid?(short)
0
+ @short = short
0
+ else
0
+ raise
0
+ end
0
   end
0
   
0
   def method_missing(methodname, *args)
0
     URIRef.new(@uri + methodname.to_s)
0
   end
0
+
0
+ private
0
+ def shortname_valid?(shortname)
0
+ if shortname =~ /[a-zA-Z_][a-zA-Z0-9_]+/
0
+ return true
0
+ else
0
+ return false
0
+ end
0
+ end
0
 end
0
\ No newline at end of file
...
12
13
14
15
 
 
 
16
17
18
...
12
13
14
 
15
16
17
18
19
20
0
@@ -12,7 +12,9 @@ describe "Namespaces" do
0
   end
0
   
0
   it "should have an XML and N3-friendly prefix" do
0
- pending "TODO: Thinking about how to test XML and N3 friendliness"
0
+ lambda do
0
+ test = Namespace.new('http://xmlns.com/foaf/0.1/', '*~{')
0
+ end.should raise_error
0
   end
0
   
0
   it "should be able to attach to the graph for substitution" do

Comments

    No one has commented yet.