metade-rena 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +48 -0
- data/Rakefile +54 -0
- data/lib/rena/bnode.rb +69 -0
- data/lib/rena/exceptions/about_each_exception.rb +2 -0
- data/lib/rena/exceptions/uri_relative_exception.rb +2 -0
- data/lib/rena/graph.rb +188 -0
- data/lib/rena/literal.rb +207 -0
- data/lib/rena/n3_grammar.treetop +129 -0
- data/lib/rena/n3parser.rb +145 -0
- data/lib/rena/namespace.rb +76 -0
- data/lib/rena/rdfxmlparser.rb +188 -0
- data/lib/rena/rexml_hacks.rb +97 -0
- data/lib/rena/triple.rb +89 -0
- data/lib/rena/uriref.rb +55 -0
- data/lib/rena.rb +5 -0
- data/rena.gemspec +17 -0
- data/spec/bnode_spec.rb +29 -0
- data/spec/graph_spec.rb +127 -0
- data/spec/literal_spec.rb +136 -0
- data/spec/namespaces_spec.rb +44 -0
- data/spec/parser_spec.rb +314 -0
- data/spec/rexml_hacks_spec.rb +75 -0
- data/spec/triple_spec.rb +100 -0
- data/spec/uriref_spec.rb +60 -0
- data/test/test_uris.rb +13 -0
- data/test/xml.rdf +6 -0
- metadata +96 -0
data/spec/uriref_spec.rb
ADDED
@@ -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
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
|