rdf-n3 0.2.3.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.gitignore +1 -0
  2. data/.yardopts +4 -3
  3. data/{History.txt → History.md} +30 -6
  4. data/{README.rdoc → README.md} +56 -19
  5. data/Rakefile +15 -29
  6. data/VERSION +1 -1
  7. data/example-files/sp2b.n3 +50177 -0
  8. data/lib/rdf/n3.rb +2 -2
  9. data/lib/rdf/n3/reader.rb +560 -367
  10. data/lib/rdf/n3/reader/meta.rb +640 -0
  11. data/lib/rdf/n3/reader/n3-selectors.n3 +0 -0
  12. data/lib/rdf/n3/reader/parser.rb +229 -0
  13. data/lib/rdf/n3/vocab.rb +1 -0
  14. data/lib/rdf/n3/writer.rb +324 -265
  15. data/rdf-n3.gemspec +24 -26
  16. data/script/build_meta +242 -0
  17. data/script/parse +62 -13
  18. data/script/tc +4 -4
  19. data/spec/cwm_spec.rb +11 -3
  20. data/spec/n3reader_spec.rb +233 -63
  21. data/spec/rdf_helper.rb +15 -15
  22. data/spec/spec_helper.rb +10 -4
  23. data/spec/swap_spec.rb +11 -35
  24. data/spec/swap_test/n3parser.tests +14 -14
  25. data/spec/swap_test/n3parser.yml +0 -19
  26. data/spec/swap_test/nodeID/classes.ref.rdf +1 -1
  27. data/spec/swap_test/ref/contexts-1.n3 +12 -0
  28. data/spec/swap_test/ref/prefix2.rdf +33 -0
  29. data/spec/swap_test/ref/strquot.n3 +0 -1
  30. data/spec/swap_test/ref/xml-syntax-basic-serialization.rdf +1 -1
  31. data/spec/swap_test/regression.n3 +5 -5
  32. data/spec/swap_test/regression.yml +53 -23
  33. data/spec/turtle/manifest-bad.yml +91 -0
  34. data/spec/turtle/manifest.yml +187 -0
  35. data/spec/turtle_spec.rb +12 -20
  36. data/spec/writer_spec.rb +39 -37
  37. metadata +43 -48
  38. data/lib/rdf/n3/patches/qname_hacks.rb +0 -57
  39. data/lib/rdf/n3/patches/seq.rb +0 -34
  40. data/lib/rdf/n3/reader/n3_grammar.rb +0 -3764
  41. data/lib/rdf/n3/reader/n3_grammar.treetop +0 -227
  42. data/lib/rdf/n3/reader/n3_grammar_18.rb +0 -3764
  43. data/lib/rdf/n3/reader/n3_grammar_18.treetop +0 -227
  44. data/spec/literal_spec.rb +0 -245
@@ -0,0 +1,91 @@
1
+ ---
2
+ - !ruby/object:RdfHelper::TestCase
3
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-00.ttl
4
+ description: "prefix name must end in a :"
5
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-00.ttl
6
+ name: bad-00
7
+ outputDocument:
8
+ - !ruby/object:RdfHelper::TestCase
9
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-01.ttl
10
+ description: blank predicate forbidden
11
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-01.ttl
12
+ name: bad-01
13
+ outputDocument:
14
+ - !ruby/object:RdfHelper::TestCase
15
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-02.ttl
16
+ description: blank predicate forbidden
17
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-02.ttl
18
+ name: bad-02
19
+ outputDocument:
20
+ - !ruby/object:RdfHelper::TestCase
21
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-03.ttl
22
+ description: a forbidden as subject
23
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-03.ttl
24
+ name: bad-03
25
+ outputDocument:
26
+ - !ruby/object:RdfHelper::TestCase
27
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-04.ttl
28
+ description: ", not allowed in collections"
29
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-04.ttl
30
+ name: bad-04
31
+ outputDocument:
32
+ - !ruby/object:RdfHelper::TestCase
33
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-05.ttl
34
+ description: "{} not allowed in Turtle"
35
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-05.ttl
36
+ name: bad-05
37
+ outputDocument:
38
+ - !ruby/object:RdfHelper::TestCase
39
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-06.ttl
40
+ description: is and of not allowed in Turtle
41
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-06.ttl
42
+ name: bad-06
43
+ outputDocument:
44
+ - !ruby/object:RdfHelper::TestCase
45
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-07.ttl
46
+ description: paths not allowed in Turtle
47
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-07.ttl
48
+ name: bad-07
49
+ outputDocument:
50
+ - !ruby/object:RdfHelper::TestCase
51
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-08.ttl
52
+ description: "@keywords not allowed in Turtle"
53
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-08.ttl
54
+ name: bad-08
55
+ outputDocument:
56
+ - !ruby/object:RdfHelper::TestCase
57
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-09.ttl
58
+ description: => not allowed in Turtle
59
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-09.ttl
60
+ name: bad-09
61
+ outputDocument:
62
+ - !ruby/object:RdfHelper::TestCase
63
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-10.ttl
64
+ description: = not allowed in Turtle
65
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-10.ttl
66
+ name: bad-10
67
+ outputDocument:
68
+ - !ruby/object:RdfHelper::TestCase
69
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-11.ttl
70
+ description: "@forAll not allowed in Turtle"
71
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-11.ttl
72
+ name: bad-11
73
+ outputDocument:
74
+ - !ruby/object:RdfHelper::TestCase
75
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-12.ttl
76
+ description: "@forSome not allowed in Turtle"
77
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-12.ttl
78
+ name: bad-12
79
+ outputDocument:
80
+ - !ruby/object:RdfHelper::TestCase
81
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-13.ttl
82
+ description: <= not allowed in Turtle
83
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-13.ttl
84
+ name: bad-13
85
+ outputDocument:
86
+ - !ruby/object:RdfHelper::TestCase
87
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/bad-14.ttl
88
+ description: long literal with missing end
89
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/bad-14.ttl
90
+ name: bad-14
91
+ outputDocument:
@@ -0,0 +1,187 @@
1
+ ---
2
+ - !ruby/object:RdfHelper::TestCase
3
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-00.ttl
4
+ description: Blank subject
5
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-00.ttl
6
+ name: test-00
7
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-00.out
8
+ - !ruby/object:RdfHelper::TestCase
9
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-01.ttl
10
+ description: "@prefix and qnames"
11
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-01.ttl
12
+ name: test-01
13
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-01.out
14
+ - !ruby/object:RdfHelper::TestCase
15
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-02.ttl
16
+ description: ", operator"
17
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-02.ttl
18
+ name: test-02
19
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-02.out
20
+ - !ruby/object:RdfHelper::TestCase
21
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-03.ttl
22
+ description: ; operator
23
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-03.ttl
24
+ name: test-03
25
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-03.out
26
+ - !ruby/object:RdfHelper::TestCase
27
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-04.ttl
28
+ description: empty [] as subject and object
29
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-04.ttl
30
+ name: test-04
31
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-04.out
32
+ - !ruby/object:RdfHelper::TestCase
33
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-05.ttl
34
+ description: non-empty [] as subject and object
35
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-05.ttl
36
+ name: test-05
37
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-05.out
38
+ - !ruby/object:RdfHelper::TestCase
39
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-06.ttl
40
+ description: "'a' as predicate"
41
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-06.ttl
42
+ name: test-06
43
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-06.out
44
+ - !ruby/object:RdfHelper::TestCase
45
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-07.ttl
46
+ description: simple collection
47
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-07.ttl
48
+ name: test-07
49
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-07.out
50
+ - !ruby/object:RdfHelper::TestCase
51
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-08.ttl
52
+ description: empty collection
53
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-08.ttl
54
+ name: test-08
55
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-08.out
56
+ - !ruby/object:RdfHelper::TestCase
57
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-09.ttl
58
+ description: integer datatyped literal
59
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-09.ttl
60
+ name: test-09
61
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-09.out
62
+ - !ruby/object:RdfHelper::TestCase
63
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-10.ttl
64
+ description: decimal integer canonicalization
65
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-10.ttl
66
+ name: test-10
67
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-10.out
68
+ - !ruby/object:RdfHelper::TestCase
69
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-11.ttl
70
+ description: "- and _ in names and qnames"
71
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-11.ttl
72
+ name: test-11
73
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-11.out
74
+ - !ruby/object:RdfHelper::TestCase
75
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-12.ttl
76
+ description: tests for rdf:_<numbers> and other qnames starting with _
77
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-12.ttl
78
+ name: test-12
79
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-12.out
80
+ - !ruby/object:RdfHelper::TestCase
81
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-13.ttl
82
+ description: "bare : allowed"
83
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-13.ttl
84
+ name: test-13
85
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-13.out
86
+ - !ruby/object:RdfHelper::TestCase
87
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-17.ttl
88
+ description: simple long literal
89
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-17.ttl
90
+ name: test-17
91
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-17.out
92
+ - !ruby/object:RdfHelper::TestCase
93
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-18.ttl
94
+ description: long literals with escapes
95
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-18.ttl
96
+ name: test-18
97
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-18.out
98
+ - !ruby/object:RdfHelper::TestCase
99
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-19.ttl
100
+ description: floating point number
101
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-19.ttl
102
+ name: test-19
103
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-19.out
104
+ - !ruby/object:RdfHelper::TestCase
105
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-20.ttl
106
+ description: empty literals, normal and long variant
107
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-20.ttl
108
+ name: test-20
109
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-20.out
110
+ - !ruby/object:RdfHelper::TestCase
111
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-21.ttl
112
+ description: positive integer, decimal and doubles
113
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-21.ttl
114
+ name: test-21
115
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-21.out
116
+ - !ruby/object:RdfHelper::TestCase
117
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-22.ttl
118
+ description: negative integer, decimal and doubles
119
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-22.ttl
120
+ name: test-22
121
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-22.out
122
+ - !ruby/object:RdfHelper::TestCase
123
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-23.ttl
124
+ description: long literal ending in double quote
125
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-23.ttl
126
+ name: test-23
127
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-23.out
128
+ - !ruby/object:RdfHelper::TestCase
129
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-24.ttl
130
+ description: boolean literals
131
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-24.ttl
132
+ name: test-24
133
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-24.out
134
+ - !ruby/object:RdfHelper::TestCase
135
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-25.ttl
136
+ description: comments
137
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-25.ttl
138
+ name: test-25
139
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-25.out
140
+ - !ruby/object:RdfHelper::TestCase
141
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-26.ttl
142
+ description: no final mewline
143
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-26.ttl
144
+ name: test-26
145
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-26.out
146
+ - !ruby/object:RdfHelper::TestCase
147
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-27.ttl
148
+ description: duplicate prefix
149
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-27.ttl
150
+ name: test-27
151
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-27.out
152
+ - !ruby/object:RdfHelper::TestCase
153
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-28.ttl
154
+ description: decimal data types (serializing test)
155
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-28.ttl
156
+ name: test-28
157
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-28.out
158
+ - !ruby/object:RdfHelper::TestCase
159
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-29.ttl
160
+ description: Escaping U+0001 to U+007F in a URI
161
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-29.ttl
162
+ name: test-29
163
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-29.out
164
+ - !ruby/object:RdfHelper::TestCase
165
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/test-30.ttl
166
+ description: "@base"
167
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-30.ttl
168
+ name: test-30
169
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/test-30.out
170
+ - !ruby/object:RdfHelper::TestCase
171
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/rdf-schema.ttl
172
+ description: RDF Namespace document converted into Turtle
173
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/rdf-schema.ttl
174
+ name: rdf-schema
175
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/rdf-schema.out
176
+ - !ruby/object:RdfHelper::TestCase
177
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/rdfs-namespace.ttl
178
+ description: RDFS Namespace document converted into Turtle
179
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/rdfs-namespace.ttl
180
+ name: rdfs-namespace
181
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/rdfs-namespace.out
182
+ - !ruby/object:RdfHelper::TestCase
183
+ about: http://www.w3.org/2001/sw/DataAccess/df1/tests/rdfq-results.ttl
184
+ description: Example query result from http://www.w3.org/2003/03/rdfqr-tests/recording-query-results.html
185
+ inputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/rdfq-results.ttl
186
+ name: rdfq-results
187
+ outputDocument: /Users/gregg/Projects/rdf-n3/spec/turtle/rdfq-results.out
@@ -24,28 +24,20 @@ describe RDF::N3::Reader do
24
24
  specify "#{t.name}: " + (t.description || "#{t.inputDocument} against #{t.outputDocument}") do
25
25
  #puts t.inspect
26
26
  # Skip tests for very long files, too long
27
- if %w(test-14 test-15 test-16 rdfq-results).include?(t.name)
28
- pending("Skip very long input file")
29
- elsif !defined?(::Encoding) && %w(test-18).include?(t.name)
27
+ if !defined?(::Encoding) && %w(test-18).include?(t.name)
30
28
  pending("Not supported in Ruby 1.8")
31
- elsif %w(test-29).include?(t.name)
32
- pending("Silly test")
33
29
  else
34
- begin
35
- t.run_test do |rdf_string, parser|
36
- t.debug = []
37
- g = RDF::Graph.new
38
- RDF::Reader.for(t.inputDocument).new(rdf_string,
39
- :base_uri => t.about,
40
- :strict => true,
41
- :debug => t.debug).each do |statement|
42
- g << statement
43
- end
44
- #t.compare = :array if g.bnodes.empty?
45
- g
30
+ t.run_test do |rdf_string, parser|
31
+ t.debug = []
32
+ g = RDF::Graph.new
33
+ RDF::Reader.for(t.inputDocument).new(rdf_string,
34
+ :base_uri => t.about,
35
+ :strict => true,
36
+ :canonicalize => true,
37
+ :debug => t.debug).each do |statement|
38
+ g << statement
46
39
  end
47
- #rescue #Spec::Expectations::ExpectationNotMetError => e
48
- # pending() { raise }
40
+ g
49
41
  end
50
42
  end
51
43
  end
@@ -69,7 +61,7 @@ describe RDF::N3::Reader do
69
61
  end
70
62
  end.should raise_error(RDF::ReaderError)
71
63
  end
72
- rescue #Spec::Expectations::ExpectationNotMetError => e
64
+ rescue RSpec::Expectations::ExpectationNotMetError => e
73
65
  pending() { raise }
74
66
  end
75
67
  end
@@ -20,16 +20,17 @@ describe RDF::N3::Writer do
20
20
  input = %(<http://xmlns.com/foaf/0.1/b> <http://xmlns.com/foaf/0.1/c> <http://xmlns.com/foaf/0.1/d> .)
21
21
  serialize(input, nil,
22
22
  [%r(^@prefix foaf: <http://xmlns.com/foaf/0.1/> \.$),
23
- %r(^foaf:b foaf:c foaf:d \.$)]
23
+ %r(^foaf:b foaf:c foaf:d \.$)],
24
+ :prefixes => { :foaf => RDF::FOAF}
24
25
  )
25
26
  end
26
27
 
27
28
  it "should use qname URIs with empty prefix" do
28
- input = %(@prefix : <http://xmlns.com/foaf/0.1/> . <http://xmlns.com/foaf/0.1/b> <http://xmlns.com/foaf/0.1/c> <http://xmlns.com/foaf/0.1/d> .)
29
+ input = %(<http://xmlns.com/foaf/0.1/b> <http://xmlns.com/foaf/0.1/c> <http://xmlns.com/foaf/0.1/d> .)
29
30
  serialize(input, nil,
30
31
  [%r(^@prefix : <http://xmlns.com/foaf/0.1/> \.$),
31
32
  %r(^:b :c :d \.$)],
32
- :default_namespace => RDF::FOAF
33
+ :prefixes => { "" => RDF::FOAF}
33
34
  )
34
35
  end
35
36
 
@@ -46,9 +47,9 @@ describe RDF::N3::Writer do
46
47
  serialize(input, nil,
47
48
  [%r(^\s+a :class;$),
48
49
  %r(^\s+rdfs:label "label"),
49
- %r(^:b dc11:title \"title\"),
50
+ %r(^:b dc:title \"title\"),
50
51
  %r(^\s+:c :d)],
51
- :default_namespace => RDF::FOAF
52
+ :prefixes => { "" => RDF::FOAF, :dc => "http://purl.org/dc/elements/1.1/", :rdfs => RDF::RDFS}
52
53
  )
53
54
  end
54
55
 
@@ -58,7 +59,7 @@ describe RDF::N3::Writer do
58
59
  [%r(^@prefix : <http://xmlns.com/foaf/0.1/> \.$),
59
60
  %r(^:b :c :d,$),
60
61
  %r(^\s+:e \.$)],
61
- :default_namespace => RDF::FOAF
62
+ :prefixes => { "" => RDF::FOAF}
62
63
  )
63
64
  end
64
65
 
@@ -68,7 +69,7 @@ describe RDF::N3::Writer do
68
69
  [%r(^@prefix : <http://xmlns.com/foaf/0.1/> \.$),
69
70
  %r(^:b :c :d;$),
70
71
  %r(^\s+:e :f \.$)],
71
- :default_namespace => RDF::FOAF
72
+ :prefixes => { "" => RDF::FOAF}
72
73
  )
73
74
  end
74
75
  end
@@ -78,7 +79,7 @@ describe RDF::N3::Writer do
78
79
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . [:a :b] .)
79
80
  serialize(input, nil,
80
81
  [%r(^\s*\[ :a :b\] \.$)],
81
- :default_namespace => RDF::FOAF
82
+ :prefixes => { "" => RDF::FOAF}
82
83
  )
83
84
  end
84
85
 
@@ -87,7 +88,7 @@ describe RDF::N3::Writer do
87
88
  serialize(input, nil,
88
89
  [%r(^\s*\[ :a :b;$),
89
90
  %r(^\s+:c :d\] \.$)],
90
- :default_namespace => RDF::FOAF
91
+ :prefixes => { "" => RDF::FOAF}
91
92
  )
92
93
  end
93
94
 
@@ -95,7 +96,7 @@ describe RDF::N3::Writer do
95
96
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . :a :b [:c :d] .)
96
97
  serialize(input, nil,
97
98
  [%r(^\s*\:a :b \[ :c :d\] \.$)],
98
- :default_namespace => RDF::FOAF
99
+ :prefixes => { "" => RDF::FOAF}
99
100
  )
100
101
  end
101
102
  end
@@ -105,7 +106,7 @@ describe RDF::N3::Writer do
105
106
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . (:a :b) .)
106
107
  serialize(input, nil,
107
108
  [%r(^\(:a :b\) \.$)],
108
- :default_namespace => RDF::FOAF
109
+ :prefixes => { "" => RDF::FOAF}
109
110
  )
110
111
  end
111
112
 
@@ -113,7 +114,7 @@ describe RDF::N3::Writer do
113
114
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . :a :b ( "apple" "banana" ) .)
114
115
  serialize(input, nil,
115
116
  [%r(^:a :b \("apple" "banana"\) \.$)],
116
- :default_namespace => RDF::FOAF
117
+ :prefixes => { "" => RDF::FOAF}
117
118
  )
118
119
  end
119
120
 
@@ -121,7 +122,7 @@ describe RDF::N3::Writer do
121
122
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . :a :b () .)
122
123
  serialize(input, nil,
123
124
  [%r(^:a :b \(\) \.$)],
124
- :default_namespace => RDF::FOAF
125
+ :prefixes => { "" => RDF::FOAF}
125
126
  )
126
127
  end
127
128
 
@@ -129,7 +130,7 @@ describe RDF::N3::Writer do
129
130
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . :emptyList = () .)
130
131
  serialize(input, nil,
131
132
  [%r(^:emptyList (<.*sameAs>|owl:sameAs) \(\) \.$)],
132
- :default_namespace => RDF::FOAF
133
+ :prefixes => { "" => RDF::FOAF}
133
134
  )
134
135
  end
135
136
 
@@ -137,7 +138,7 @@ describe RDF::N3::Writer do
137
138
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . () :a :b .)
138
139
  serialize(input, nil,
139
140
  [%r(^\(\) :a :b \.$)],
140
- :default_namespace => RDF::FOAF
141
+ :prefixes => { "" => RDF::FOAF}
141
142
  )
142
143
  end
143
144
 
@@ -145,7 +146,7 @@ describe RDF::N3::Writer do
145
146
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . (:a) :b :c .)
146
147
  serialize(input, nil,
147
148
  [%r(^\(:a\) :b :c \.$)],
148
- :default_namespace => RDF::FOAF
149
+ :prefixes => { "" => RDF::FOAF}
149
150
  )
150
151
  end
151
152
 
@@ -153,7 +154,7 @@ describe RDF::N3::Writer do
153
154
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . :listOf2Empties = (() ()) .)
154
155
  serialize(input, nil,
155
156
  [%r(^:listOf2Empties (<.*sameAs>|owl:sameAs) \(\(\) \(\)\) \.$)],
156
- :default_namespace => RDF::FOAF
157
+ :prefixes => { "" => RDF::FOAF}
157
158
  )
158
159
  end
159
160
 
@@ -161,7 +162,7 @@ describe RDF::N3::Writer do
161
162
  input = %(@prefix : <http://xmlns.com/foaf/0.1/> . :twoAnons = ([a :mother] [a :father]) .)
162
163
  serialize(input, nil,
163
164
  [%r(^:twoAnons (<.*sameAs>|owl:sameAs) \(\[\s*a :mother\] \[\s*a :father\]\) \.$)],
164
- :default_namespace => RDF::FOAF
165
+ :prefixes => { "" => RDF::FOAF}
165
166
  )
166
167
  end
167
168
 
@@ -191,12 +192,25 @@ describe RDF::N3::Writer do
191
192
  %r(@prefix : <http://xmlns.com/foaf/0.1/> \.),
192
193
  %r(@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \.),
193
194
  ],
194
- :default_namespace => RDF::FOAF
195
+ :prefixes => { "" => RDF::FOAF, :rdfs => RDF::RDFS, :owl => RDF::OWL, :rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}
195
196
  )
196
197
  #$verbose = false
197
198
  end
198
199
  end
199
200
 
201
+ describe "strings" do
202
+ it "encodes embedded \"\"\"" do
203
+ n3 = %(:a :b """testing string parsing in N3.
204
+ """ .)
205
+ serialize(n3, nil, [/testing string parsing in N3.\n/])
206
+ end
207
+
208
+ it "encodes embedded \"" do
209
+ n3 = %(:a :b """string with " escaped quote marks""" .)
210
+ serialize(n3, nil, [/string with \\" escaped quote mark/])
211
+ end
212
+ end
213
+
200
214
  # W3C Turtle Test suite from http://www.w3.org/2000/10/swap/test/regression.n3
201
215
  describe "w3c turtle tests" do
202
216
  require 'rdf_helper'
@@ -208,25 +222,13 @@ describe RDF::N3::Writer do
208
222
  positive_tests.each do |t|
209
223
  #puts t.inspect
210
224
  #next unless t.name == "test-04"
225
+ next if t.name == "test-29" # FIXME
211
226
 
212
- specify "#{t.name}: " + (t.description || "#{t.inputDocument}") do
213
- # Skip tests for very long files, too long
214
- if %w(test-14 test-15 test-16 rdfq-results).include?(t.name)
215
- pending("Skip very long input file")
216
- elsif !defined?(::Encoding) && %w(test-18).include?(t.name)
217
- pending("Not supported in Ruby 1.8")
218
- elsif %w(test-29).include?(t.name)
219
- pending("Silly test")
220
- else
221
- begin
222
- t.run_test do |rdf_string|
223
- t.compare = :none
224
- serialize(rdf_string, t.about.to_s)
225
- end
226
- #rescue #Spec::Expectations::ExpectationNotMetError => e
227
- # pending() { raise }
228
- end
229
- end
227
+ specify "#{t.name}: " + (t.description || "#{t.outputDocument}") do
228
+ @graph = parse(t.output, :base_uri => t.about, :format => :ntriples)
229
+ n3 = serialize(t.output, t.about, [], :format => :n3)
230
+ g2 = parse(n3, :base_uri => t.about)
231
+ g2.should be_equivalent_graph(@graph, :trace => @debug.join("\n"))
230
232
  end
231
233
  end
232
234
  end