pius-rena 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ require 'lib/rena'
2
+
3
+ describe "Triples" do
4
+ it "should have a subject" do
5
+ f = Triple.new(BNode.new, URIRef.new('http://xmlns.com/foaf/0.1/knows'), BNode.new)
6
+ f.subject.class.should == BNode
7
+ # puts f.to_ntriples
8
+ end
9
+
10
+ it "should require that the subject is a URIRef or BNode" do
11
+ lambda do
12
+ Triple.new(Literal.new("foo"), URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new)
13
+ end.should raise_error
14
+ end
15
+
16
+ it "should require that the predicate is a URIRef" do
17
+ lambda do
18
+ Triple.new(BNode.new, BNode.new, BNode.new)
19
+ end.should raise_error
20
+ end
21
+
22
+ it "should require that the object is a URIRef, BNode, Literal or Typed Literal" do
23
+ lambda do
24
+ Triple.new(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), [])
25
+ end.should raise_error
26
+ end
27
+
28
+ it "should emit an NTriple" do
29
+ f = Triple.new(URIRef.new("http://tommorris.org/foaf#me"), URIRef.new("http://xmlns.com/foaf/0.1/name"), Literal.new("Tom Morris"))
30
+ f.to_ntriples.should == "<http://tommorris.org/foaf#me> <http://xmlns.com/foaf/0.1/name> \"Tom Morris\" ."
31
+ end
32
+ end
@@ -0,0 +1,47 @@
1
+ require 'lib/rena'
2
+ #require 'lib/uriref'
3
+
4
+ describe "URI References" do
5
+ it "should output NTriples" do
6
+ f = URIRef.new("http://tommorris.org/foaf/")
7
+ f.to_ntriples.should == "<http://tommorris.org/foaf/>"
8
+ end
9
+
10
+ it "should handle Unicode symbols inside URLs" do
11
+ lambda do
12
+ f = URIRef.new("http://example.org/#Andr%E9")
13
+ end.should_not raise_error
14
+ end
15
+
16
+ # it "do not contain any control characters (#x00 - #x1F, #x74-#x9F)" do
17
+ # lambda do
18
+ # f = URIRef.new("http://tommorris.org/blog/")
19
+ # f.test_string("http://tommorris.org/blog")
20
+ # end.should_not raise_error
21
+ #
22
+ # lambda do
23
+ # f = URIRef.new("http://xmlns.com/foaf/0.1/knows")
24
+ # f.test_string("http://xmlns.com/foaf/0.1/knows")
25
+ # end.should_not raise_error
26
+ # end
27
+
28
+ it "produce a valid URI character sequence (per RFC 2396 §2.1) representing an absolute URI with optional fragment identifier" do
29
+ pending "TODO: figure out a series of tests for RFC 2396 §2.1 adherence"
30
+ end
31
+
32
+ it "should throw errors on suspicious protocols and non-protocols" do
33
+ lambda do
34
+ URIRef.new("javascript:alert(\"pass\")")
35
+ end.should raise_error
36
+ end
37
+
38
+ it "must not be a relative URI" do
39
+ lambda do
40
+ URIRef.new("foo")
41
+ end.should raise_error
42
+ end
43
+
44
+ it "should discourage use of %-escaped characters" do
45
+ pending "TODO: figure out a way to discourage %-escaped character usage"
46
+ end
47
+ end
data/test/test_uris.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require 'uri'
3
+ require 'cgi'
4
+ require 'rubygems'
5
+ require 'addressable/uri'
6
+
7
+ class TestUris < Test::Unit::TestCase
8
+ def test_encoding
9
+ f = Addressable::URI.parse("http://example.org/André")
10
+ assert_equal("http://example.org/André", f.to_s)
11
+ assert_equal(false, f.relative?)
12
+ end
13
+ end
data/test/xml.rdf ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" ?>
2
+ <rdf:RDF xmlns:rdf="http://www.w3.org/TR/rdf-syntax-grammar" xmlns:foaf="http://xmlns.com/foaf/0.1/">
3
+ <rdf:Description rdf:resource="http://example.org/foo">
4
+ <foaf:name>Tom</foaf:name>
5
+ </rdf:Description>
6
+ </rdf:RDF>
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pius-rena
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tom Morris
8
+ - Pius Uzamere
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-07-13 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: addressable
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.1
24
+ version:
25
+ description: Rena is a Ruby library for manipulating RDF files.
26
+ email: tom@tommorris.org
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - README.txt
35
+ - Rakefile
36
+ - rena.gemspec
37
+ - lib/rena.rb
38
+ - lib/rena/bnode.rb
39
+ - lib/rena/graph.rb
40
+ - lib/rena/literal.rb
41
+ - lib/rena/namespace.rb
42
+ - lib/rena/rdfxmlparser.rb
43
+ - lib/rena/rexml_hacks.rb
44
+ - lib/rena/triple.rb
45
+ - lib/rena/uriref.rb
46
+ - lib/rena/exceptions/about_each_exception.rb
47
+ - lib/rena/exceptions/uri_relative_exception.rb
48
+ has_rdoc: true
49
+ homepage: http://github.com/tommorris/rena
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.2.0
71
+ signing_key:
72
+ specification_version: 2
73
+ summary: Ruby RDF library.
74
+ test_files:
75
+ - test/test_uris.rb
76
+ - test/xml.rdf
77
+ - test/spec/bnode.spec.rb
78
+ - test/spec/graph.spec.rb
79
+ - test/spec/literal.spec.rb
80
+ - test/spec/namespaces.spec.rb
81
+ - test/spec/parser.spec.rb
82
+ - test/spec/rexml_hacks.spec.rb
83
+ - test/spec/triple.spec.rb
84
+ - test/spec/uriref.spec.rb