public
Rubygem
Description: Rena is a Ruby RDF library that I'm trying to help extend.
Clone URL: git://github.com/tommorris/rena.git
added short_name method
tommorris (author)
Fri Jul 25 02:47:55 -0700 2008
commit  37bbac1b26cd43b496a23e85a16ed6d895c7282b
tree    b0f7edcc293c816b48e6324bf555371d541721d9
parent  ea53a9fc26077cfd27f33789d0e74a1517444998
...
15
16
17
 
 
 
 
 
 
 
 
 
 
18
19
20
...
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -15,6 +15,16 @@ class URIRef
0
     end
0
   end
0
   
0
+ def short_name
0
+ if @uri.fragment()
0
+ return @uri.fragment()
0
+ elsif @uri.path.split("/").last.class == String and @uri.path.split("/").last.length > 0
0
+ return @uri.path.split("/").last
0
+ else
0
+ return false
0
+ end
0
+ end
0
+
0
   def == (other)
0
     return true if @uri == other.uri
0
   end
...
25
26
27
 
 
 
 
 
 
 
 
 
 
 
28
29
30
...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -25,6 +25,17 @@ describe "URI References" do
0
   # end.should_not raise_error
0
   # end
0
   
0
+ it "should return the 'last fragment' name" do
0
+ fragment = URIRef.new("http://example.org/foo#bar")
0
+ fragment.short_name.should == "bar"
0
+
0
+ path = URIRef.new("http://example.org/foo/bar")
0
+ path.short_name.should == "bar"
0
+
0
+ nonetest = URIRef.new("http://example.org/")
0
+ nonetest.short_name.should == false
0
+ end
0
+
0
   it "produce a valid URI character sequence (per RFC 2396 §2.1) representing an absolute URI with optional fragment identifier" do
0
     pending "TODO: figure out a series of tests for RFC 2396 §2.1 adherence"
0
   end

Comments

    No one has commented yet.