metade-rena 0.0.2

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,60 @@
1
+ require 'webrick'
2
+ include WEBrick
3
+ require 'lib/rena'
4
+ #require 'lib/uriref'
5
+
6
+ describe "URI References" do
7
+ it "should output NTriples" do
8
+ f = URIRef.new("http://tommorris.org/foaf/")
9
+ f.to_ntriples.should == "<http://tommorris.org/foaf/>"
10
+ end
11
+
12
+ it "should handle Unicode symbols inside URLs" do
13
+ lambda do
14
+ f = URIRef.new("http://example.org/#Andr%E9")
15
+ end.should_not raise_error
16
+ end
17
+
18
+ # it "do not contain any control characters (#x00 - #x1F, #x74-#x9F)" do
19
+ # lambda do
20
+ # f = URIRef.new("http://tommorris.org/blog/")
21
+ # f.test_string("http://tommorris.org/blog")
22
+ # end.should_not raise_error
23
+ #
24
+ # lambda do
25
+ # f = URIRef.new("http://xmlns.com/foaf/0.1/knows")
26
+ # f.test_string("http://xmlns.com/foaf/0.1/knows")
27
+ # end.should_not raise_error
28
+ # end
29
+
30
+ it "should return the 'last fragment' name" do
31
+ fragment = URIRef.new("http://example.org/foo#bar")
32
+ fragment.short_name.should == "bar"
33
+
34
+ path = URIRef.new("http://example.org/foo/bar")
35
+ path.short_name.should == "bar"
36
+
37
+ nonetest = URIRef.new("http://example.org/")
38
+ nonetest.short_name.should == false
39
+ end
40
+
41
+ it "produce a valid URI character sequence (per RFC 2396 §2.1) representing an absolute URI with optional fragment identifier" do
42
+ pending "TODO: figure out a series of tests for RFC 2396 §2.1 adherence"
43
+ end
44
+
45
+ it "should throw errors on suspicious protocols and non-protocols" do
46
+ lambda do
47
+ URIRef.new("javascript:alert(\"pass\")")
48
+ end.should raise_error
49
+ end
50
+
51
+ it "must not be a relative URI" do
52
+ lambda do
53
+ URIRef.new("foo")
54
+ end.should raise_error
55
+ end
56
+
57
+ it "should discourage use of %-escaped characters" do
58
+ pending "TODO: figure out a way to discourage %-escaped character usage"
59
+ end
60
+ 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,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metade-rena
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Tom Morris
8
+ - Pius Uzamere
9
+ - Patrick Sinclair
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2008-10-05 00:00:00 -07:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: addressable
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.4
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: treetop
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.4
34
+ version:
35
+ description: Rena is a Ruby library for manipulating RDF files.
36
+ email: tom@tommorris.org
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - README.txt
45
+ - Rakefile
46
+ - rena.gemspec
47
+ - lib/rena.rb
48
+ - lib/rena/bnode.rb
49
+ - lib/rena/graph.rb
50
+ - lib/rena/literal.rb
51
+ - lib/rena/n3parser.rb
52
+ - lib/rena/n3_grammar.treetop
53
+ - lib/rena/namespace.rb
54
+ - lib/rena/rdfxmlparser.rb
55
+ - lib/rena/rexml_hacks.rb
56
+ - lib/rena/triple.rb
57
+ - lib/rena/uriref.rb
58
+ - lib/rena/exceptions/about_each_exception.rb
59
+ - lib/rena/exceptions/uri_relative_exception.rb
60
+ has_rdoc: true
61
+ homepage: http://github.com/tommorris/rena
62
+ post_install_message:
63
+ rdoc_options: []
64
+
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ requirements: []
80
+
81
+ rubyforge_project:
82
+ rubygems_version: 1.2.0
83
+ signing_key:
84
+ specification_version: 2
85
+ summary: Ruby RDF library.
86
+ test_files:
87
+ - test/test_uris.rb
88
+ - test/xml.rdf
89
+ - spec/bnode_spec.rb
90
+ - spec/graph_spec.rb
91
+ - spec/literal_spec.rb
92
+ - spec/namespaces_spec.rb
93
+ - spec/parser_spec.rb
94
+ - spec/rexml_hacks_spec.rb
95
+ - spec/triple_spec.rb
96
+ - spec/uriref_spec.rb