rdf_context 0.4.8 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. data/History.txt +27 -0
  2. data/README.rdoc +22 -9
  3. data/Rakefile +11 -6
  4. data/VERSION +1 -1
  5. data/bin/rdf_context +12 -4
  6. data/lib/rdf_context.rb +3 -1
  7. data/lib/rdf_context/aggregate_graph.rb +86 -0
  8. data/lib/rdf_context/array_hacks.rb +53 -0
  9. data/lib/rdf_context/conjunctive_graph.rb +1 -1
  10. data/lib/rdf_context/exceptions.rb +9 -7
  11. data/lib/rdf_context/graph.rb +174 -15
  12. data/lib/rdf_context/literal.rb +34 -2
  13. data/lib/rdf_context/n3_grammar.treetop +213 -129
  14. data/lib/rdf_context/n3parser.rb +281 -57
  15. data/lib/rdf_context/namespace.rb +23 -12
  16. data/lib/rdf_context/parser.rb +4 -3
  17. data/lib/rdf_context/quoted_graph.rb +38 -0
  18. data/lib/rdf_context/rdfaparser.rb +2 -1
  19. data/lib/rdf_context/rdfxmlparser.rb +4 -3
  20. data/lib/rdf_context/store/abstract_sql_store.rb +4 -4
  21. data/lib/rdf_context/store/abstract_store.rb +5 -1
  22. data/lib/rdf_context/store/sqlite3_store.rb +10 -8
  23. data/lib/rdf_context/string_hacks.rb +44 -21
  24. data/lib/rdf_context/term_utils.rb +73 -4
  25. data/lib/rdf_context/triple.rb +32 -47
  26. data/lib/rdf_context/uriref.rb +33 -26
  27. data/spec/aggregate_graph_spec.rb +59 -0
  28. data/spec/conjunctive_graph_spec.rb +1 -1
  29. data/spec/cwm_spec.rb +32 -0
  30. data/spec/graph_spec.rb +114 -3
  31. data/spec/literal_spec.rb +107 -5
  32. data/spec/matchers.rb +104 -51
  33. data/spec/n3parser_spec.rb +798 -99
  34. data/spec/namespaces_spec.rb +26 -0
  35. data/spec/quoted_graph_spec.rb +0 -0
  36. data/spec/rdf_helper.rb +197 -0
  37. data/spec/rdfa_helper.rb +15 -11
  38. data/spec/rdfa_parser_spec.rb +6 -8
  39. data/spec/rdfxml_spec.rb +21 -28
  40. data/spec/spec_helper.rb +20 -0
  41. data/spec/sqlite3_store_spec.rb +6 -5
  42. data/spec/store_helper.rb +9 -1
  43. data/spec/string_hacks_spec.rb +14 -0
  44. data/spec/{rdfxml_helper.rb → swap_helper.rb} +8 -9
  45. data/spec/swap_spec.rb +77 -0
  46. data/spec/swap_test/animal.rdf +17 -0
  47. data/spec/swap_test/anon-prop.n3 +14 -0
  48. data/spec/swap_test/anonymous_loop.n3 +2 -0
  49. data/spec/swap_test/contexts.n3 +16 -0
  50. data/spec/swap_test/daml-pref.n3 +10 -0
  51. data/spec/swap_test/i18n/hiragana.n3 +22 -0
  52. data/spec/swap_test/i18n/n3string.n3 +4 -0
  53. data/spec/swap_test/list/itemType.rdf +12 -0
  54. data/spec/swap_test/lists-simple.n3 +40 -0
  55. data/spec/swap_test/lists.n3 +35 -0
  56. data/spec/swap_test/n3/n3parser.tests_n3_10001.nt +3 -0
  57. data/spec/swap_test/n3/n3parser.tests_n3_10002.nt +7 -0
  58. data/spec/swap_test/n3/n3parser.tests_n3_10003.nt +3 -0
  59. data/spec/swap_test/n3/n3parser.tests_n3_10004.nt +119 -0
  60. data/spec/swap_test/n3/n3parser.tests_n3_10005.nt +3 -0
  61. data/spec/swap_test/n3/n3parser.tests_n3_10006.nt +225 -0
  62. data/spec/swap_test/n3/n3parser.tests_n3_10007.nt +79 -0
  63. data/spec/swap_test/n3/n3parser.tests_n3_10008.nt +5 -0
  64. data/spec/swap_test/n3/n3parser.tests_n3_10009.nt +13 -0
  65. data/spec/swap_test/n3/n3parser.tests_n3_10010.nt +21 -0
  66. data/spec/swap_test/n3/n3parser.tests_n3_10011.nt +9 -0
  67. data/spec/swap_test/n3/n3parser.tests_n3_10012.nt +53 -0
  68. data/spec/swap_test/n3/n3parser.tests_n3_10013.nt +19 -0
  69. data/spec/swap_test/n3/n3parser.tests_n3_10014.nt +103 -0
  70. data/spec/swap_test/n3/n3parser.tests_n3_10015.nt +103 -0
  71. data/spec/swap_test/n3/n3parser.tests_n3_10016.nt +3 -0
  72. data/spec/swap_test/n3/n3parser.tests_n3_10017.nt +151 -0
  73. data/spec/swap_test/n3/n3parser.tests_n3_10018.nt +9 -0
  74. data/spec/swap_test/n3/n3parser.tests_n3_10019.nt +3 -0
  75. data/spec/swap_test/n3/n3parser.tests_n3_10020.nt +13 -0
  76. data/spec/swap_test/n3parser.tests +160 -0
  77. data/spec/swap_test/nodeID/classes.n3 +9 -0
  78. data/spec/swap_test/nodeID/classes.ref.rdf +15 -0
  79. data/spec/swap_test/nodeID/ex1.rdf +15 -0
  80. data/spec/swap_test/norm/fix.rdf +33 -0
  81. data/spec/swap_test/owl-ex.rdf +150 -0
  82. data/spec/swap_test/ref/animal.n3 +11 -0
  83. data/spec/swap_test/ref/anon-prop-1.n3 +8 -0
  84. data/spec/swap_test/ref/anonymous_loop.ref +7 -0
  85. data/spec/swap_test/ref/bnode.n3 +6 -0
  86. data/spec/swap_test/ref/bnode.rdf +16 -0
  87. data/spec/swap_test/ref/colon-in-uri.n3 +15 -0
  88. data/spec/swap_test/ref/daml-ex.n3 +103 -0
  89. data/spec/swap_test/ref/daml-ont.n3 +289 -0
  90. data/spec/swap_test/ref/djb1a-out.n3 +4 -0
  91. data/spec/swap_test/ref/dot-dash.n3 +8 -0
  92. data/spec/swap_test/ref/in-xml-t.n3 +4 -0
  93. data/spec/swap_test/ref/itemType.n3 +9 -0
  94. data/spec/swap_test/ref/keywords1.n3 +11 -0
  95. data/spec/swap_test/ref/keywords2.n3 +11 -0
  96. data/spec/swap_test/ref/lists-simple-1.rdf +108 -0
  97. data/spec/swap_test/ref/lists.n3 +43 -0
  98. data/spec/swap_test/ref/lstring-out.n3 +20 -0
  99. data/spec/swap_test/ref/n3string.n3 +13 -0
  100. data/spec/swap_test/ref/no-last-nl.n3 +3 -0
  101. data/spec/swap_test/ref/numbers.n3 +18 -0
  102. data/spec/swap_test/ref/path1.n3 +8 -0
  103. data/spec/swap_test/ref/path2.n3 +39 -0
  104. data/spec/swap_test/ref/prefix1.rdf +31 -0
  105. data/spec/swap_test/ref/prefix3.rdf +31 -0
  106. data/spec/swap_test/ref/rdf-redefine.rdf +11 -0
  107. data/spec/swap_test/ref/reluri-1.rdf +18 -0
  108. data/spec/swap_test/ref/strquot.n3 +23 -0
  109. data/spec/swap_test/ref/strquot_a.n3 +23 -0
  110. data/spec/swap_test/ref/xml-base3.n3 +5 -0
  111. data/spec/swap_test/ref/xml-redefine.rdf +20 -0
  112. data/spec/swap_test/ref/xml-redefine2.rdf +23 -0
  113. data/spec/swap_test/ref/xml-syntax-basic-serialization.rdf +10 -0
  114. data/spec/swap_test/ref/xmllit.nt +3 -0
  115. data/spec/swap_test/regression.n3 +231 -0
  116. data/spec/swap_test/reluri-1.n3 +10 -0
  117. data/spec/swap_test/strquot.n3 +23 -0
  118. data/spec/swap_test/syntax/colon-in-uri.rdf +27 -0
  119. data/spec/swap_test/syntax/djb1a.n3 +3 -0
  120. data/spec/swap_test/syntax/dot-dash.n3 +15 -0
  121. data/spec/swap_test/syntax/equals1.n3 +1 -0
  122. data/spec/swap_test/syntax/equals2.n3 +1 -0
  123. data/spec/swap_test/syntax/keywords1.n3 +17 -0
  124. data/spec/swap_test/syntax/keywords2.n3 +18 -0
  125. data/spec/swap_test/syntax/lstring.n3 +26 -0
  126. data/spec/swap_test/syntax/neg-formula-predicate.n3 +1 -0
  127. data/spec/swap_test/syntax/neg-keywords3.n3 +1 -0
  128. data/spec/swap_test/syntax/neg-literal-predicate.n3 +1 -0
  129. data/spec/swap_test/syntax/neg-single-quote.n3 +1 -0
  130. data/spec/swap_test/syntax/neg-thisadoc.n3 +1 -0
  131. data/spec/swap_test/syntax/no-last-nl.n3 +2 -0
  132. data/spec/swap_test/syntax/numbers.n3 +26 -0
  133. data/spec/swap_test/syntax/path1.n3 +23 -0
  134. data/spec/swap_test/syntax/path2.n3 +31 -0
  135. data/spec/swap_test/syntax/qvars1.n3 +19 -0
  136. data/spec/swap_test/syntax/qvars2.n3 +19 -0
  137. data/spec/swap_test/syntax/this-quantifiers.n3 +164 -0
  138. data/spec/swap_test/syntax/this-rules.n3 +43 -0
  139. data/spec/swap_test/syntax/too-nested.n3 +25 -0
  140. data/spec/swap_test/syntax/trailing-semicolon.n3 +12 -0
  141. data/spec/swap_test/syntax/zero-objects.n3 +1 -0
  142. data/spec/swap_test/syntax/zero-predicates.n3 +3 -0
  143. data/spec/swap_test/tests-work.txt +25 -0
  144. data/spec/swap_test/xml-syntax/basic-serialization.n3 +8 -0
  145. data/spec/swap_test/xml-syntax/in-xml.xml +13 -0
  146. data/spec/swap_test/xml-syntax/non-ascii-pred.rdf +14 -0
  147. data/spec/swap_test/xml-syntax/rdf_prefix.n3 +2 -0
  148. data/spec/swap_test/xml-syntax/xml_prefix.n3 +7 -0
  149. data/spec/swap_test/xml-syntax/xml_prefix2.n3 +9 -0
  150. data/spec/swap_test/xml-syntax/xmlbase3.rdf +10 -0
  151. data/spec/swap_test/xml-syntax/xmllit.rdf +33 -0
  152. data/spec/triple_spec.rb +90 -46
  153. data/spec/turtle/README.txt +20 -0
  154. data/spec/turtle/bad-00.ttl +2 -0
  155. data/spec/turtle/bad-01.ttl +3 -0
  156. data/spec/turtle/bad-02.ttl +3 -0
  157. data/spec/turtle/bad-03.ttl +3 -0
  158. data/spec/turtle/bad-04.ttl +3 -0
  159. data/spec/turtle/bad-05.ttl +4 -0
  160. data/spec/turtle/bad-06.ttl +3 -0
  161. data/spec/turtle/bad-07.ttl +4 -0
  162. data/spec/turtle/bad-08.ttl +2 -0
  163. data/spec/turtle/bad-09.ttl +3 -0
  164. data/spec/turtle/bad-10.ttl +3 -0
  165. data/spec/turtle/bad-11.ttl +3 -0
  166. data/spec/turtle/bad-12.ttl +3 -0
  167. data/spec/turtle/bad-13.ttl +3 -0
  168. data/spec/turtle/bad-14.ttl +6 -0
  169. data/spec/turtle/manifest-bad.ttl +88 -0
  170. data/spec/turtle/manifest.ttl +215 -0
  171. data/spec/turtle/rdf-schema.out +126 -0
  172. data/spec/turtle/rdf-schema.ttl +156 -0
  173. data/spec/turtle/rdfq-results.out +36 -0
  174. data/spec/turtle/rdfq-results.ttl +39 -0
  175. data/spec/turtle/rdfs-namespace.out +131 -0
  176. data/spec/turtle/rdfs-namespace.ttl +160 -0
  177. data/spec/turtle/test-00.out +1 -0
  178. data/spec/turtle/test-00.ttl +2 -0
  179. data/spec/turtle/test-01.out +3 -0
  180. data/spec/turtle/test-01.ttl +7 -0
  181. data/spec/turtle/test-02.out +3 -0
  182. data/spec/turtle/test-02.ttl +5 -0
  183. data/spec/turtle/test-03.out +3 -0
  184. data/spec/turtle/test-03.ttl +5 -0
  185. data/spec/turtle/test-04.out +2 -0
  186. data/spec/turtle/test-04.ttl +4 -0
  187. data/spec/turtle/test-05.out +4 -0
  188. data/spec/turtle/test-05.ttl +4 -0
  189. data/spec/turtle/test-06.out +1 -0
  190. data/spec/turtle/test-06.ttl +3 -0
  191. data/spec/turtle/test-07.out +5 -0
  192. data/spec/turtle/test-07.ttl +3 -0
  193. data/spec/turtle/test-08.out +1 -0
  194. data/spec/turtle/test-08.ttl +3 -0
  195. data/spec/turtle/test-09.out +4 -0
  196. data/spec/turtle/test-09.ttl +10 -0
  197. data/spec/turtle/test-10.out +5 -0
  198. data/spec/turtle/test-10.ttl +5 -0
  199. data/spec/turtle/test-11.out +4 -0
  200. data/spec/turtle/test-11.ttl +10 -0
  201. data/spec/turtle/test-12.out +4 -0
  202. data/spec/turtle/test-12.ttl +9 -0
  203. data/spec/turtle/test-13.out +2 -0
  204. data/spec/turtle/test-13.ttl +7 -0
  205. data/spec/turtle/test-14.out +10000 -0
  206. data/spec/turtle/test-14.ttl +10002 -0
  207. data/spec/turtle/test-15.out +10000 -0
  208. data/spec/turtle/test-15.ttl +3 -0
  209. data/spec/turtle/test-16.out +10000 -0
  210. data/spec/turtle/test-16.ttl +10002 -0
  211. data/spec/turtle/test-17.out +1 -0
  212. data/spec/turtle/test-17.ttl +6 -0
  213. data/spec/turtle/test-18.out +2 -0
  214. data/spec/turtle/test-18.ttl +9 -0
  215. data/spec/turtle/test-19.out +1 -0
  216. data/spec/turtle/test-19.ttl +4 -0
  217. data/spec/turtle/test-20.out +2 -0
  218. data/spec/turtle/test-20.ttl +6 -0
  219. data/spec/turtle/test-21.out +3 -0
  220. data/spec/turtle/test-21.ttl +4 -0
  221. data/spec/turtle/test-22.out +3 -0
  222. data/spec/turtle/test-22.ttl +4 -0
  223. data/spec/turtle/test-23.out +1 -0
  224. data/spec/turtle/test-23.ttl +3 -0
  225. data/spec/turtle/test-24.out +2 -0
  226. data/spec/turtle/test-24.ttl +3 -0
  227. data/spec/turtle/test-25.out +7 -0
  228. data/spec/turtle/test-25.ttl +14 -0
  229. data/spec/turtle/test-26.out +1 -0
  230. data/spec/turtle/test-26.ttl +4 -0
  231. data/spec/turtle/test-27.out +1 -0
  232. data/spec/turtle/test-27.ttl +5 -0
  233. data/spec/turtle/test-28-out.ttl +6 -0
  234. data/spec/turtle/test-28.out +22 -0
  235. data/spec/turtle/test-28.ttl +22 -0
  236. data/spec/turtle/test-29.out +1 -0
  237. data/spec/turtle/test-29.ttl +1 -0
  238. data/spec/turtle/test-30.out +5 -0
  239. data/spec/turtle/test-30.ttl +12 -0
  240. data/spec/turtle_spec.rb +64 -0
  241. data/spec/uriref_spec.rb +74 -34
  242. data/test/n3_tests/rdflib/n3-writer-teset-26.n3 +31 -0
  243. data/test/n3_tests/rdflib/n3-writer-teset-26.nt +14 -0
  244. data/test/rdf_tests/xml-literal-mixed.nt +1 -2
  245. metadata +278 -39
  246. data/lib/rdf_context/n3_grammar.rb +0 -2171
  247. data/test/perf_test/test.rb +0 -11
  248. data/test/perf_test/tommorris.rdf +0 -2267
@@ -0,0 +1,14 @@
1
+
2
+
3
+
4
+ <rdf:RDF xmlns="http://example.com/swap/test/includes/non-ascii.n3#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
6
+
7
+ <rdf:Description rdf:about="#my">
8
+ <name>Joerg</name>
9
+ </rdf:Description>
10
+
11
+ <rdf:Description rdf:about="#僕">
12
+ <名前>ヨーク</名前>
13
+ </rdf:Description>
14
+ </rdf:RDF>
@@ -0,0 +1,2 @@
1
+ @prefix rdf: <http://example.com#> .
2
+ :a rdf:b :c .
@@ -0,0 +1,7 @@
1
+ @prefix : <http://example.com/xml#> .
2
+ @prefix a: <http://example.com/m#> .
3
+
4
+ a:a a:b a:c .
5
+ a:y a:n a:i .
6
+ a:q a :P;
7
+ :v :r .
@@ -0,0 +1,9 @@
1
+ @prefix xml: <http://example.com/xml#> .
2
+ @prefix a: <http://example.com/m#> .
3
+ @prefix xmlns: <http://example.com/xmlns#> .
4
+
5
+ a:a a:b a:c .
6
+ a:y a:n a:i .
7
+ a:q a :P;
8
+ xml:v xml:r;
9
+ xmlns:w xmlns:t .
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0"?>
2
+ <rdf:RDF xml:base="http://example.org/"
3
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
4
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
5
+ <rdf:Description rdf:about="http://www.w3.org/" xml:base="test1/">
6
+ <dc:title>World Wide Web Consortium</dc:title>
7
+ <dc:source rdf:resource="test2/"/>
8
+ <dc:relation rdf:resource=""/>
9
+ </rdf:Description>
10
+ </rdf:RDF>
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ Copyright World Wide Web Consortium, (Massachusetts Institute of
5
+ Technology, Institut National de Recherche en Informatique et en
6
+ Automatique, Keio University).
7
+
8
+ All Rights Reserved.
9
+
10
+ Please see the full Copyright clause at
11
+ <http://www.w3.org/Consortium/Legal/copyright-software.html>
12
+
13
+ Description: Visibly used namespaces must be included in XML
14
+ Literal values. Treatment of namespaces that are not
15
+ visibly used (e.g. rdf: in this example) is implementation
16
+ dependent. Based on example from Issues List.
17
+
18
+
19
+ $Id: xmllit.rdf,v 1.1 2005-09-01 20:43:01 syosi Exp $
20
+
21
+ -->
22
+ <rdf:RDF xmlns="http://www.w3.org/1999/xhtml"
23
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
24
+ xmlns:html="http://NoHTML.example.org"
25
+ xmlns:my="http://my.example.org/">
26
+ <rdf:Description rdf:ID="John_Smith">
27
+ <my:Name rdf:parseType="Literal">
28
+ <html:h1 my:thing="hello">
29
+ <b><i>John</i></b>
30
+ </html:h1>
31
+ </my:Name>
32
+ </rdf:Description>
33
+ </rdf:RDF>
@@ -2,16 +2,86 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
3
  describe "Triples" do
4
4
  before(:all) { @graph = Graph.new(:store => ListStore.new) }
5
- it "should require that the subject is a URIRef or BNode" do
6
- lambda do
7
- Triple.new(Literal.new("foo"), URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new)
8
- end.should raise_error
5
+
6
+ describe "with subjects" do
7
+ it "should allow URIRef" do
8
+ v = URIRef.new("http://foo")
9
+ Triple.new(v, RDF_TYPE, "obj").subject.should == v
10
+ end
11
+
12
+ it "should allow BNode" do
13
+ v = BNode.new
14
+ Triple.new(v, RDF_TYPE, "obj").subject.should == v
15
+ end
16
+
17
+ it "should allow Literal" do
18
+ v = Literal.untyped("foo")
19
+ Triple.new(v, RDF_TYPE, "obj").subject.should == v
20
+ end
21
+
22
+ it "should allow Graph" do
23
+ v = Graph.new
24
+ Triple.new(v, RDF_TYPE, "obj").subject.should == v
25
+ end
26
+
27
+ it "should allow QuotedGraph" do
28
+ v = QuotedGraph.new
29
+ Triple.new(v, RDF_TYPE, "obj").subject.should == v
30
+ end
9
31
  end
10
32
 
11
- it "should require that the predicate is a URIRef" do
12
- lambda do
13
- Triple.new(BNode.new, BNode.new, BNode.new)
14
- end.should raise_error
33
+ describe "with predicates" do
34
+ it "should allow URIRef" do
35
+ v = URIRef.new("http://foo")
36
+ Triple.new(RDF_NS.Seq, v, "obj").predicate.should == v
37
+ end
38
+
39
+ it "should allow BNode" do
40
+ v = BNode.new
41
+ Triple.new(RDF_NS.Seq, v, "obj").predicate.should == v
42
+ end
43
+
44
+ it "should not allow Literal" do
45
+ v = Literal.untyped("foo")
46
+ lambda {Triple.new(RDF_NS.Seq, v, "obj")}.should raise_error
47
+ end
48
+
49
+ it "should not allow Graph" do
50
+ v = Graph.new
51
+ lambda {Triple.new(RDF_NS.Seq, v, "obj")}.should raise_error
52
+ end
53
+
54
+ it "should not allow QuotedGraph" do
55
+ v = QuotedGraph.new
56
+ lambda {Triple.new(RDF_NS.Seq, v, "obj")}.should raise_error
57
+ end
58
+ end
59
+
60
+ describe "with objects" do
61
+ it "should allow URIRef" do
62
+ v = URIRef.new("http://foo")
63
+ Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
64
+ end
65
+
66
+ it "should allow BNode" do
67
+ v = BNode.new
68
+ Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
69
+ end
70
+
71
+ it "should allow Literal" do
72
+ v = Literal.untyped("foo")
73
+ Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
74
+ end
75
+
76
+ it "should allow Graph" do
77
+ v = Graph.new
78
+ Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
79
+ end
80
+
81
+ it "should allow QuotedGraph" do
82
+ v = QuotedGraph.new
83
+ Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
84
+ end
15
85
  end
16
86
 
17
87
  it "should require that the object is a URIRef, BNode, Literal or Typed Literal" do
@@ -47,32 +117,6 @@ describe "Triples" do
47
117
  end
48
118
  end
49
119
 
50
- describe "with coerced subject" do
51
- it "should accept a URIRef" do
52
- ref = URIRef.new('http://localhost/')
53
- Triple.coerce_subject(ref).should == ref
54
- end
55
-
56
- it "should accept a BNode" do
57
- node = BNode.new('a')
58
- Triple.coerce_subject(node).should == node
59
- end
60
-
61
- it "should accept a uri string and make URIRef" do
62
- Triple.coerce_subject('http://localhost/').should == URIRef.new('http://localhost/')
63
- end
64
-
65
- it "should accept an Addressable::URI object and make URIRef" do
66
- Triple.coerce_subject(Addressable::URI.parse("http://localhost/")).should == URIRef.new("http://localhost/")
67
- end
68
-
69
- it "should raise an InvalidSubject exception with any other class argument" do
70
- lambda do
71
- Triple.coerce_subject(Object.new)
72
- end.should raise_error(Triple::InvalidSubject)
73
- end
74
- end
75
-
76
120
  describe "with coerced predicate" do
77
121
  it "should make a string into a URI ref" do
78
122
  Triple.coerce_predicate("http://localhost/").should == URIRef.new('http://localhost/')
@@ -90,47 +134,47 @@ describe "Triples" do
90
134
  end
91
135
  end
92
136
 
93
- describe "with coerced object" do
137
+ describe "with coerced node" do
94
138
  it 'should make a literal for Integer types' do
95
139
  ref = 5
96
- Triple.coerce_object(ref).should == Literal.build_from(ref)
140
+ Triple.coerce_node(ref).should == Literal.build_from(ref)
97
141
  end
98
142
 
99
143
  it 'should make a literal for Float types' do
100
144
  ref = 15.4
101
- Triple.coerce_object(ref).should == Literal.build_from(ref)
145
+ Triple.coerce_node(ref).should == Literal.build_from(ref)
102
146
  end
103
147
 
104
148
  it 'should make a literal for Date types' do
105
149
  ref = Date::civil(2010, 1, 2)
106
- Triple.coerce_object(ref).should == Literal.build_from(ref)
150
+ Triple.coerce_node(ref).should == Literal.build_from(ref)
107
151
  end
108
152
 
109
153
  it 'should make a literal for DateTime types' do
110
154
  ref = DateTime.parse('2010-01-03T01:02:03')
111
- Triple.coerce_object(ref).should == Literal.build_from(ref)
155
+ Triple.coerce_node(ref).should == Literal.build_from(ref)
112
156
  end
113
157
 
114
158
  it "should leave URIRefs alone" do
115
159
  ref = URIRef.new("http://localhost/")
116
- Triple.coerce_object(ref).should == ref
160
+ Triple.coerce_node(ref).should == ref
117
161
  end
118
162
 
119
163
  it "should accept an Addressable::URI object and make URIRef" do
120
- Triple.coerce_object(Addressable::URI.parse("http://localhost/")).should == URIRef.new("http://localhost/")
164
+ Triple.coerce_node(Addressable::URI.parse("http://localhost/")).should == URIRef.new("http://localhost/")
121
165
  end
122
166
 
123
167
  it "should leave BNodes alone" do
124
168
  ref = BNode.new()
125
- Triple.coerce_object(ref).should == ref
169
+ Triple.coerce_node(ref).should == ref
126
170
  end
127
171
 
128
172
  it "should leave Literals alone" do
129
173
  ref = Literal.untyped('foo')
130
- Triple.coerce_object(ref).should == ref
174
+ Triple.coerce_node(ref).should == ref
131
175
 
132
176
  typedref = Literal.build_from('foo')
133
- Triple.coerce_object(ref).should == ref
177
+ Triple.coerce_node(ref).should == ref
134
178
  end
135
179
 
136
180
  end
@@ -138,7 +182,7 @@ describe "Triples" do
138
182
  describe "with wildcards" do
139
183
  it "should accept nil" do
140
184
  t = Triple.new(nil, nil, nil)
141
- t.is_patern?.should be_true
185
+ t.is_pattern?.should be_true
142
186
  end
143
187
  end
144
188
 
@@ -168,7 +212,7 @@ describe "Triples" do
168
212
  end
169
213
  end
170
214
 
171
- it "should be equal to paterns" do
215
+ it "should be equal to patterns" do
172
216
  @test_cases.each do |triple|
173
217
  [
174
218
  Triple.new(triple.subject, triple.predicate, triple.object),
@@ -0,0 +1,20 @@
1
+ These are the tests for the Turtle Terse RDF Triple Language
2
+ that must be passed by conformant systems. See
3
+ http://www.dajobe.org/2004/01/turtle/
4
+ for the full conformance information.
5
+
6
+ The format is a set of good tests and bad tests.
7
+
8
+ Good tests are a pair of files:
9
+ abc.ttl abc.out
10
+ which are the input Turtle file and the expected output RDF triples,
11
+ written in N-Triples.
12
+
13
+ bad tests are of the form
14
+ bad-XX.ttl
15
+ which must fail.
16
+
17
+ The tests should be performed with an assumed base URI
18
+ of http://www.w3.org/2001/sw/DataAccess/df1/tests/
19
+
20
+ Dave
@@ -0,0 +1,2 @@
1
+ # prefix name must end in a :
2
+ @prefix a <#> .
@@ -0,0 +1,3 @@
1
+ # Forbidden by RDF - predicate cannot be blank
2
+ @prefix : <http://example.org/base#> .
3
+ :a [ :b :c ] :d .
@@ -0,0 +1,3 @@
1
+ # Forbidden by RDF - predicate cannot be blank
2
+ @prefix : <http://example.org/base#> .
3
+ :a [] :b .
@@ -0,0 +1,3 @@
1
+ # 'a' only allowed as a predicate
2
+ @prefix : <http://example.org/base#> .
3
+ a :a :b .
@@ -0,0 +1,3 @@
1
+ # No comma is allowed in collections
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ :a :b ( "apple", "banana" ) .
@@ -0,0 +1,4 @@
1
+ # N3 {}s are not in Turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ { :a :b :c . } :d :e .
4
+
@@ -0,0 +1,3 @@
1
+ # is and of are not in turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ :a is :b of :c .
@@ -0,0 +1,4 @@
1
+ # paths are not in turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ :a.:b.:c .
4
+ :a^:b^:c .
@@ -0,0 +1,2 @@
1
+ @keywords something.
2
+ # @keywords is not in turtle
@@ -0,0 +1,3 @@
1
+ # implies is not in turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ :a => :b .
@@ -0,0 +1,3 @@
1
+ # equivalence is not in turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ :a = :b .
@@ -0,0 +1,3 @@
1
+ # @forAll is not in turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ @forAll :x .
@@ -0,0 +1,3 @@
1
+ # @forSome is not in turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ @forSome :x .
@@ -0,0 +1,3 @@
1
+ # <= is not in turtle
2
+ @prefix : <http://example.org/stuff/1.0/> .
3
+ :a <= :b .
@@ -0,0 +1,6 @@
1
+ # Test long literals with missing end
2
+ @prefix : <http://example.org/ex#> .
3
+ :a :b """a long
4
+ literal
5
+ with
6
+ newlines
@@ -0,0 +1,88 @@
1
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
3
+ @prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
4
+ @prefix qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .
5
+
6
+ <> rdf:type mf:Manifest ;
7
+ rdfs:comment "Turtle bad syntax test cases (must fail)" ;
8
+ mf:entries
9
+ (
10
+
11
+ [ mf:name "bad-00" ;
12
+ rdfs:comment "prefix name must end in a :" ;
13
+ mf:action [ qt:data <bad-00.ttl> ] ;
14
+ ]
15
+
16
+ [ mf:name "bad-01" ;
17
+ rdfs:comment "blank predicate forbidden" ;
18
+ mf:action [ qt:data <bad-01.ttl> ] ;
19
+ ]
20
+
21
+ [ mf:name "bad-02" ;
22
+ rdfs:comment "blank predicate forbidden" ;
23
+ mf:action [ qt:data <bad-02.ttl> ] ;
24
+ ]
25
+
26
+ [ mf:name "bad-03" ;
27
+ rdfs:comment "a forbidden as subject" ;
28
+ mf:action [ qt:data <bad-03.ttl> ] ;
29
+ ]
30
+
31
+ [ mf:name "bad-04" ;
32
+ rdfs:comment ", not allowed in collections" ;
33
+ mf:action [ qt:data <bad-04.ttl> ] ;
34
+ ]
35
+
36
+ [ mf:name "bad-05" ;
37
+ rdfs:comment "{} not allowed in Turtle" ;
38
+ mf:action [ qt:data <bad-05.ttl> ] ;
39
+ ]
40
+
41
+ [ mf:name "bad-06" ;
42
+ rdfs:comment "is and of not allowed in Turtle" ;
43
+ mf:action [ qt:data <bad-06.ttl> ] ;
44
+ ]
45
+
46
+ [ mf:name "bad-07" ;
47
+ rdfs:comment "paths not allowed in Turtle" ;
48
+ mf:action [ qt:data <bad-07.ttl> ] ;
49
+ ]
50
+
51
+ [ mf:name "bad-08" ;
52
+ rdfs:comment "@keywords not allowed in Turtle" ;
53
+ mf:action [ qt:data <bad-08.ttl> ] ;
54
+ ]
55
+
56
+ [ mf:name "bad-09" ;
57
+ rdfs:comment "=> not allowed in Turtle" ;
58
+ mf:action [ qt:data <bad-09.ttl> ] ;
59
+ ]
60
+
61
+ [ mf:name "bad-10" ;
62
+ rdfs:comment "= not allowed in Turtle" ;
63
+ mf:action [ qt:data <bad-10.ttl> ] ;
64
+ ]
65
+
66
+ [ mf:name "bad-11" ;
67
+ rdfs:comment "@forAll not allowed in Turtle" ;
68
+ mf:action [ qt:data <bad-11.ttl> ] ;
69
+ ]
70
+
71
+ [ mf:name "bad-12" ;
72
+ rdfs:comment "@forSome not allowed in Turtle" ;
73
+ mf:action [ qt:data <bad-12.ttl> ] ;
74
+ ]
75
+
76
+ [ mf:name "bad-13" ;
77
+ rdfs:comment "<= not allowed in Turtle" ;
78
+ mf:action [ qt:data <bad-13.ttl> ] ;
79
+ ]
80
+
81
+ [ mf:name "bad-14" ;
82
+ rdfs:comment "long literal with missing end" ;
83
+ mf:action [ qt:data <bad-14.ttl> ] ;
84
+ ]
85
+
86
+
87
+ # End of tests
88
+ ).