iq_rdf 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # IqRdf - RDF Renderering for Ruby and Rails
1
+ # IqRdf - RDF Renderering for Ruby and Rails [![build status](https://secure.travis-ci.org/innoq/iq_rdf.png)](http://travis-ci.org/innoq/iq_rdf)
2
2
  IqRdf is a RDF renderer for Ruby and Rails. You can use it in any Ruby
3
- environment to render Trurtle-, N-Triple- (not implemented jet) or XML-RDF.
3
+ environment to render Trurtle-, N-Triple- (not implemented yet) or XML-RDF.
4
4
 
5
5
  IqRdf underlays a [Builder](http://builder.rubyforge.org/)-like approach to specify
6
6
  the RDF-Data by using a internal Ruby DSL. The basic Idea for specifing a triple
data/Rakefile CHANGED
@@ -30,3 +30,5 @@ end
30
30
  Rake::TestTask.new do |t|
31
31
  t.test_files = FileList['test/**/*.rb']
32
32
  end
33
+
34
+ task :default => :test
@@ -45,9 +45,99 @@ module IqRdf
45
45
  @nodes << node
46
46
  end
47
47
 
48
+ def to_ntriples
49
+ rdf_type = IqRdf::Rdf::build_uri("type")
50
+ triples = []
51
+ blank_nodes = {}
52
+
53
+ # pre-declarations -- XXX: smelly!
54
+ render_triple = nil
55
+ process_subject = nil
56
+
57
+ render_blank_node = lambda do |res|
58
+ node_id = blank_nodes[res]
59
+ unless node_id
60
+ node_id = blank_nodes.count + 1
61
+ blank_nodes[res] = node_id
62
+ end
63
+ return "_:b#{node_id}"
64
+ end
65
+
66
+ process_collection = lambda do |res|
67
+ list = render_blank_node.call(res)
68
+ # inject list components
69
+ list = IqRdf::BlankNode.new
70
+ sublist = list
71
+ total = res.elements.length
72
+ res.elements.each_with_index do |current_element, i|
73
+ sublist::rdf.build_predicate("type", IqRdf::Rdf::build_uri("List")) # _:b* a rdf:List
74
+ sublist::rdf.first(current_element) # _:b* rdf:first <...>
75
+ last = i + 1 == total
76
+ unless last
77
+ new_sublist = IqRdf::BlankNode.new
78
+ sublist::rdf.rest(new_sublist) # _:b* rdf:rest _:b*
79
+ end
80
+ process_subject.call(sublist)
81
+ sublist = new_sublist
82
+ end
83
+ return render_blank_node.call(list)
84
+ end
85
+
86
+ render_resource = lambda do |res, lang| # XXX: does not belong here
87
+ if res.is_a?(IqRdf::Literal)
88
+ return res.to_s(lang)
89
+ elsif res.is_a?(IqRdf::BlankNode)
90
+ return render_blank_node.call(res)
91
+ elsif res.is_a?(IqRdf::Collection)
92
+ return process_collection.call(res)
93
+ else
94
+ return "<#{res.full_uri}>"
95
+ end
96
+ end
97
+
98
+ render_triple = lambda do |(sbj, prd, obj), lang| # XXX: language handling is weird!? -- XXX: does not belong here
99
+ triple = [sbj, prd, obj].map { |res| render_resource.call(res, lang) }
100
+ return "#{triple.join(" ")} ."
101
+ end
102
+
103
+ process_subject = lambda do |sbj, &block| # XXX: does not belong here
104
+ if (sbj.rdf_type rescue false) # XXX: `rescue` a hack for blank nodes
105
+ lang = sbj.lang || @document_language # XXX: cargo-culted
106
+ triples << render_triple.call([sbj, rdf_type, sbj.rdf_type], lang)
107
+ end
108
+
109
+ sbj.nodes.each do |prd|
110
+ lang = prd.lang || sbj.lang || @document_language # XXX: cargo-culted
111
+ prd.nodes.each do |obj|
112
+ triple = [sbj, prd, obj]
113
+ triples << render_triple.call(triple, lang)
114
+ block.call(triple) if block
115
+ end
116
+ end
117
+ end
118
+
119
+ process_blank_node = lambda do |(sbj, prd, obj), current_res|
120
+ [sbj, obj].
121
+ select { |res| res.is_a?(IqRdf::BlankNode) && res != current_res }.
122
+ each do |res|
123
+ process_subject.call(res) do |(sbj, prd, obj)|
124
+ process_blank_node.call([sbj, prd, obj], res) # NB: recursion!
125
+ end
126
+ end
127
+ end
128
+
129
+ @nodes.each do |sbj|
130
+ process_subject.call(sbj) do |(sbj, prd, obj)|
131
+ process_blank_node.call([sbj, prd, obj], sbj) # XXX: special casing
132
+ end
133
+ end
134
+
135
+ return triples.join("\n")
136
+ end
137
+
48
138
  def to_turtle
49
139
  s = ""
50
- @namespaces.values.each do |namespace|
140
+ @namespaces.values.sort{ |n1, n2| n1.turtle_token <=> n2.turtle_token }.each do |namespace|
51
141
  s << "@prefix #{namespace.turtle_token}: <#{namespace.uri_prefix}>.\n"
52
142
  end
53
143
  s << "\n"
@@ -70,9 +160,9 @@ module IqRdf
70
160
  xml = Builder::XmlMarkup.new(:indent => 2)
71
161
  xml.instruct!
72
162
  opts = {}
73
- @namespaces.values.each{ |namespace|
163
+ @namespaces.values.each do |namespace|
74
164
  opts[namespace.token == :default ? "xmlns" : "xmlns:#{namespace.token.to_s}"] = namespace.uri_prefix
75
- }
165
+ end
76
166
  opts["xml:lang"] = @document_language if @document_language
77
167
 
78
168
  xml.rdf(:RDF, opts) do
@@ -49,7 +49,11 @@ module IqRdf
49
49
 
50
50
  def self.find_namespace_class(token)
51
51
  klass_name = self.class_name(token)
52
- IqRdf.const_get(klass_name) if IqRdf.const_defined?(klass_name)
52
+ if IqRdf.const_defined?(klass_name) && IqRdf.const_get(klass_name) < IqRdf::Namespace # Ruby 1.9 is polluting namespaces
53
+ IqRdf.const_get(klass_name)
54
+ else
55
+ nil
56
+ end
53
57
  end
54
58
 
55
59
  def self.dummy_empty_namespace
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module IqRdf
16
- VERSION = "0.1.5"
16
+ VERSION = "0.1.6"
17
17
  end
@@ -0,0 +1,183 @@
1
+ # Copyright 2011 innoQ Deutschland GmbH
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ $LOAD_PATH << File.dirname(__FILE__)
16
+
17
+ require 'test_helper'
18
+
19
+ class NTriplesTest < Test::Unit::TestCase
20
+
21
+ def test_basics
22
+ document = IqRdf::Document.new('http://example.org/')
23
+ document.namespaces :skos => 'http://www.w3.org/2004/02/skos/core#'
24
+ document << IqRdf.foo do |node|
25
+ node.skos.related(IqRdf.bar)
26
+ end
27
+
28
+ assert_equal(<<-rdf.strip, document.to_ntriples)
29
+ <http://example.org/foo> <http://www.w3.org/2004/02/skos/core#related> <http://example.org/bar> .
30
+ rdf
31
+
32
+ document = IqRdf::Document.new('http://www.test.de/', :lang => :de)
33
+ document.namespaces :foaf => 'http://xmlns.com/foaf/0.1/'
34
+
35
+ document << IqRdf::testemann do |t|
36
+ t.Foaf::knows(IqRdf::testefrau)
37
+ t.Foaf.nick("Testy")
38
+ t.Foaf.lastname("Testemann", :lang => :none)
39
+ end
40
+
41
+ assert_equal(<<-rdf.strip, document.to_ntriples)
42
+ <http://www.test.de/testemann> <http://xmlns.com/foaf/0.1/knows> <http://www.test.de/testefrau> .
43
+ <http://www.test.de/testemann> <http://xmlns.com/foaf/0.1/nick> "Testy"@de .
44
+ <http://www.test.de/testemann> <http://xmlns.com/foaf/0.1/lastname> "Testemann" .
45
+ rdf
46
+ end
47
+
48
+ def test_full_uri_subject
49
+ document = IqRdf::Document.new('http://www.test.de/')
50
+
51
+ document << IqRdf::build_full_uri_subject(URI.parse('http://www.xyz.de/#test'),
52
+ IqRdf::build_uri('SomeType')) do |t|
53
+ t.sometest("testvalue")
54
+ end
55
+
56
+ assert_equal(<<-rdf.strip, document.to_ntriples)
57
+ <http://www.xyz.de/#test> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.test.de/SomeType> .
58
+ <http://www.xyz.de/#test> <http://www.test.de/sometest> "testvalue" .
59
+ rdf
60
+ end
61
+
62
+ def test_full_uri_predicate
63
+ document = IqRdf::Document.new('http://www.test.de/')
64
+
65
+ document << IqRdf::testemann.
66
+ build_full_uri_predicate(URI.parse("http://www.test.org/hoho"), 42)
67
+
68
+ assert_equal(<<-rdf.strip, document.to_ntriples)
69
+ <http://www.test.de/testemann> <http://www.test.org/hoho> 42 .
70
+ rdf
71
+ end
72
+
73
+ def test_blank_nodes
74
+ document = IqRdf::Document.new('http://www.test.de/')
75
+
76
+ document << IqRdf::testnode.test32 do |blank_node|
77
+ blank_node.title("dies ist ein test")
78
+ blank_node.build_predicate(:test, "Another test")
79
+ blank_node.sub do |subnode|
80
+ subnode.title("blubb")
81
+ end
82
+ end
83
+
84
+ assert_equal(<<-rdf.strip, document.to_ntriples)
85
+ <http://www.test.de/testnode> <http://www.test.de/test32> _:b1 .
86
+ _:b1 <http://www.test.de/title> "dies ist ein test" .
87
+ _:b1 <http://www.test.de/test> "Another test" .
88
+ _:b1 <http://www.test.de/sub> _:b2 .
89
+ _:b2 <http://www.test.de/title> "blubb" .
90
+ rdf
91
+ end
92
+
93
+ def test_collections
94
+ document = IqRdf::Document.new('http://test.de/')
95
+
96
+ document << IqRdf::testemann.testIt([IqRdf::hello, IqRdf::goodbye, "bla"])
97
+
98
+ assert_equal(<<-rdf.strip, document.to_ntriples)
99
+ _:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
100
+ _:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://test.de/hello> .
101
+ _:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b3 .
102
+ _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
103
+ _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://test.de/goodbye> .
104
+ _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b4 .
105
+ _:b4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
106
+ _:b4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "bla" .
107
+ <http://test.de/testemann> <http://test.de/testIt> _:b2 .
108
+ rdf
109
+ end
110
+
111
+ def test_complex_features
112
+ document = IqRdf::Document.new('http://www.umweltprobenbank.de/', :lang => :de)
113
+
114
+ document.namespaces :skos => 'http://www.w3.org/2008/05/skos#',
115
+ :foaf => 'http://xmlns.com/foaf/0.1/', :upb => 'http://www.upb.de/'
116
+
117
+ document << IqRdf::testemann.myCustomNote("This is an example", :lang => :en)
118
+ document << IqRdf::testemann(IqRdf::Foaf::build_uri("Person")).
119
+ Foaf::name("Heinz Peter Testemann", :lang => :none)
120
+ document << IqRdf::testemann.Foaf::knows(IqRdf::testefrau)
121
+ document << IqRdf::testemann.Foaf::nick("Crash test dummy")
122
+
123
+ ["u1023", "xkfkrl"].each do |id|
124
+ document << IqRdf::Upb::build_uri(id, IqRdf::Skos::build_uri(:Concept)) do |doc|
125
+ doc.Skos::prefLabel("Test", :lang => :en)
126
+ doc.Skos::related(IqRdf::Rdf.anotherThing)
127
+
128
+ doc.test1("bla")
129
+ doc.testIt(:hello, :goodbye, "bla")
130
+ doc.anotherTest(URI.parse("http://www.test.de/foo"))
131
+
132
+ end
133
+ end
134
+
135
+ document << IqRdf::Skos::testnode.test32 do |blank_node|
136
+ blank_node.title("dies ist ein test")
137
+ blank_node.sub do |subnode|
138
+ subnode.title("blubb")
139
+ end
140
+ end
141
+
142
+ assert_equal(<<-rdf.strip, document.to_ntriples)
143
+ <http://www.umweltprobenbank.de/testemann> <http://www.umweltprobenbank.de/myCustomNote> "This is an example"@en .
144
+ <http://www.umweltprobenbank.de/testemann> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
145
+ <http://www.umweltprobenbank.de/testemann> <http://xmlns.com/foaf/0.1/name> "Heinz Peter Testemann" .
146
+ <http://www.umweltprobenbank.de/testemann> <http://xmlns.com/foaf/0.1/knows> <http://www.umweltprobenbank.de/testefrau> .
147
+ <http://www.umweltprobenbank.de/testemann> <http://xmlns.com/foaf/0.1/nick> "Crash test dummy"@de .
148
+ <http://www.upb.de/u1023> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos#Concept> .
149
+ <http://www.upb.de/u1023> <http://www.w3.org/2008/05/skos#prefLabel> "Test"@en .
150
+ <http://www.upb.de/u1023> <http://www.w3.org/2008/05/skos#related> <http://www.w3.org/1999/02/22-rdf-syntax-ns#anotherThing> .
151
+ <http://www.upb.de/u1023> <http://www.umweltprobenbank.de/test1> "bla"@de .
152
+ <http://www.upb.de/u1023> <http://www.umweltprobenbank.de/testIt> <http://www.umweltprobenbank.de/hello> .
153
+ <http://www.upb.de/u1023> <http://www.umweltprobenbank.de/testIt> <http://www.umweltprobenbank.de/goodbye> .
154
+ <http://www.upb.de/u1023> <http://www.umweltprobenbank.de/testIt> "bla"@de .
155
+ <http://www.upb.de/u1023> <http://www.umweltprobenbank.de/anotherTest> <http://www.test.de/foo> .
156
+ <http://www.upb.de/xkfkrl> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos#Concept> .
157
+ <http://www.upb.de/xkfkrl> <http://www.w3.org/2008/05/skos#prefLabel> "Test"@en .
158
+ <http://www.upb.de/xkfkrl> <http://www.w3.org/2008/05/skos#related> <http://www.w3.org/1999/02/22-rdf-syntax-ns#anotherThing> .
159
+ <http://www.upb.de/xkfkrl> <http://www.umweltprobenbank.de/test1> "bla"@de .
160
+ <http://www.upb.de/xkfkrl> <http://www.umweltprobenbank.de/testIt> <http://www.umweltprobenbank.de/hello> .
161
+ <http://www.upb.de/xkfkrl> <http://www.umweltprobenbank.de/testIt> <http://www.umweltprobenbank.de/goodbye> .
162
+ <http://www.upb.de/xkfkrl> <http://www.umweltprobenbank.de/testIt> "bla"@de .
163
+ <http://www.upb.de/xkfkrl> <http://www.umweltprobenbank.de/anotherTest> <http://www.test.de/foo> .
164
+ <http://www.w3.org/2008/05/skos#testnode> <http://www.umweltprobenbank.de/test32> _:b1 .
165
+ _:b1 <http://www.umweltprobenbank.de/title> "dies ist ein test"@de .
166
+ _:b1 <http://www.umweltprobenbank.de/sub> _:b2 .
167
+ _:b2 <http://www.umweltprobenbank.de/title> "blubb"@de .
168
+ rdf
169
+ end
170
+
171
+ def test_supress_if_empty_option
172
+ document = IqRdf::Document.new('http://www.test.de/')
173
+ document.namespaces :foaf => 'http://xmlns.com/foaf/0.1/'
174
+
175
+ document << IqRdf::testemann.Foaf::knows(:suppress_if_empty => true)
176
+ document << IqRdf::testemann.Foaf::knows(nil, :suppress_if_empty => true)
177
+ document << IqRdf::testemann.Foaf::knows("", :suppress_if_empty => true)
178
+ document << IqRdf::testemann.Foaf::knows([], :suppress_if_empty => true)
179
+
180
+ assert_equal("", document.to_ntriples)
181
+ end
182
+
183
+ end
data/test/turtle_test.rb CHANGED
@@ -30,8 +30,8 @@ class TurtleTest < Test::Unit::TestCase
30
30
 
31
31
  assert_equal(<<rdf, document.to_turtle)
32
32
  @prefix : <http://www.test.de/>.
33
- @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
34
33
  @prefix foaf: <http://xmlns.com/foaf/0.1/>.
34
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
35
35
 
36
36
  :testemann foaf:knows :testefrau;
37
37
  foaf:nick "Testy"@de;
@@ -92,9 +92,9 @@ rdf
92
92
 
93
93
  assert_equal(<<rdf, document.to_turtle)
94
94
  @prefix : <http://www.umweltprobenbank.de/>.
95
+ @prefix foaf: <http://xmlns.com/foaf/0.1/>.
95
96
  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
96
97
  @prefix skos: <http://www.w3.org/2008/05/skos#>.
97
- @prefix foaf: <http://xmlns.com/foaf/0.1/>.
98
98
  @prefix upb: <http://www.upb.de/>.
99
99
 
100
100
  :testemann :myCustomNote "This is an example"@en.
@@ -146,8 +146,8 @@ rdf
146
146
 
147
147
  assert_equal(<<rdf, document.to_turtle)
148
148
  @prefix : <http://www.test.de/>.
149
- @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
150
149
  @prefix foaf: <http://xmlns.com/foaf/0.1/>.
150
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
151
151
 
152
152
  :testemann foaf:knows :testefrau;
153
153
  foaf:nick "Testy"@de;
@@ -175,8 +175,8 @@ rdf
175
175
  document << IqRdf::testemann.Foaf::knows([], :suppress_if_empty => true)
176
176
  assert_equal(<<rdf, document.to_turtle)
177
177
  @prefix : <http://www.test.de/>.
178
- @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
179
178
  @prefix foaf: <http://xmlns.com/foaf/0.1/>.
179
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
180
180
 
181
181
  rdf
182
182
  end
data/test/xml_test.rb CHANGED
@@ -28,15 +28,12 @@ class XmlTest < Test::Unit::TestCase
28
28
  t.Foaf.lastname("Testemann", :lang => :none)
29
29
  end
30
30
 
31
- assert_equal(<<rdf, document.to_xml)
32
- <?xml version="1.0" encoding="UTF-8"?>
33
- <rdf:RDF xmlns="http://www.test.de/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xml:lang="de">
31
+ assert_match(<<rdf, document.to_xml)
34
32
  <rdf:Description rdf:about="http://www.test.de/testemann">
35
33
  <foaf:knows rdf:resource="http://www.test.de/testefrau"/>
36
34
  <foaf:nick>Testy</foaf:nick>
37
35
  <foaf:lastname xml:lang="">Testemann</foaf:lastname>
38
36
  </rdf:Description>
39
- </rdf:RDF>
40
37
  rdf
41
38
  end
42
39
 
@@ -51,14 +48,11 @@ rdf
51
48
  t.sometest("testvalue")
52
49
  end
53
50
 
54
- assert_equal(<<rdf, document.to_xml)
55
- <?xml version="1.0" encoding="UTF-8"?>
56
- <rdf:RDF xmlns="http://www.test.de/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
51
+ assert_match(<<rdf, document.to_xml)
57
52
  <rdf:Description rdf:about="http://www.xyz.de/#test">
58
53
  <rdf:type rdf:resource="http://www.test.de/SomeType"/>
59
54
  <sometest>testvalue</sometest>
60
55
  </rdf:Description>
61
- </rdf:RDF>
62
56
  rdf
63
57
  end
64
58
 
@@ -93,9 +87,7 @@ rdf
93
87
  end # ]
94
88
  end # ]
95
89
 
96
- assert_equal(<<rdf, document.to_xml)
97
- <?xml version="1.0" encoding="UTF-8"?>
98
- <rdf:RDF xmlns="http://www.umweltprobenbank.de/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2008/05/skos#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:upb="http://www.upb.de/" xml:lang="de">
90
+ assert_match(<<rdf, document.to_xml)
99
91
  <rdf:Description rdf:about="http://www.umweltprobenbank.de/testemann">
100
92
  <myCustomNote xml:lang="en">This is an example</myCustomNote>
101
93
  </rdf:Description>
@@ -154,7 +146,6 @@ rdf
154
146
  </rdf:Description>
155
147
  </test32>
156
148
  </rdf:Description>
157
- </rdf:RDF>
158
149
  rdf
159
150
 
160
151
  =begin
@@ -178,16 +169,14 @@ skos:testnode :test32 [
178
169
  t.age(32)
179
170
  t.married(false)
180
171
  t.weight(65.8)
181
- t.complex(IqRdf::Literal.new("A very complex type", :none, URI.parse("http://this.com/is#complex")))
182
- t.complex2(IqRdf::Literal.new("Shorter form", :none, IqRdf::myDatatype))
172
+ t.complex(IqRdf::Literal.new("A very complex type", nil, URI.parse("http://this.com/is#complex")))
173
+ t.complex2(IqRdf::Literal.new("Shorter form", nil, IqRdf::myDatatype))
183
174
  t.quotes("\"I'm \\quoted\"")
184
175
  t.line_breaks("I'm written\nover two lines")
185
176
  t.some_literal(IqRdf::Literal.new("text", :de))
186
177
  end
187
178
 
188
- assert_equal(<<rdf, document.to_xml)
189
- <?xml version="1.0" encoding="UTF-8"?>
190
- <rdf:RDF xmlns="http://www.test.de/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xml:lang="de">
179
+ assert_match(<<rdf, document.to_xml)
191
180
  <rdf:Description rdf:about="http://www.test.de/testemann">
192
181
  <foaf:knows rdf:resource="http://www.test.de/testefrau"/>
193
182
  <foaf:nick>Testy</foaf:nick>
@@ -195,14 +184,13 @@ skos:testnode :test32 [
195
184
  <age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">32</age>
196
185
  <married rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</married>
197
186
  <weight rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">65.8</weight>
198
- <complex rdf:datatype="http://this.com/is#complex" xml:lang="none">A very complex type</complex>
199
- <complex2 rdf:datatype="http://www.test.de/myDatatype" xml:lang="none">Shorter form</complex2>
187
+ <complex rdf:datatype="http://this.com/is#complex">A very complex type</complex>
188
+ <complex2 rdf:datatype="http://www.test.de/myDatatype">Shorter form</complex2>
200
189
  <quotes>"I'm \\quoted"</quotes>
201
190
  <line_breaks>I'm written
202
191
  over two lines</line_breaks>
203
192
  <some_literal xml:lang="de">text</some_literal>
204
193
  </rdf:Description>
205
- </rdf:RDF>
206
194
  rdf
207
195
  end
208
196
 
@@ -216,9 +204,7 @@ rdf
216
204
  subnode.title("blubb") # title "blubb"
217
205
  end # ]
218
206
  end # ]
219
- assert_equal(<<rdf, document.to_xml)
220
- <?xml version=\"1.0\" encoding=\"UTF-8\"?>
221
- <rdf:RDF xmlns=\"http://www.test.de/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">
207
+ assert_match(<<rdf, document.to_xml)
222
208
  <rdf:Description rdf:about=\"http://www.test.de/testnode\">
223
209
  <test32>
224
210
  <rdf:Description>
@@ -232,7 +218,6 @@ rdf
232
218
  </rdf:Description>
233
219
  </test32>
234
220
  </rdf:Description>
235
- </rdf:RDF>
236
221
  rdf
237
222
  end
238
223
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iq_rdf
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Till Schulte-Coerne
@@ -15,11 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-22 00:00:00 Z
18
+ date: 2012-10-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
22
  none: false
24
23
  requirements:
25
24
  - - ">="
@@ -28,12 +27,12 @@ dependencies:
28
27
  segments:
29
28
  - 0
30
29
  version: "0"
31
- version_requirements: *id001
32
- name: bundler
30
+ requirement: *id001
33
31
  type: :runtime
34
- - !ruby/object:Gem::Dependency
32
+ name: bundler
35
33
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
36
  none: false
38
37
  requirements:
39
38
  - - ">="
@@ -42,9 +41,10 @@ dependencies:
42
41
  segments:
43
42
  - 0
44
43
  version: "0"
45
- version_requirements: *id002
46
- name: builder
44
+ requirement: *id002
47
45
  type: :runtime
46
+ name: builder
47
+ prerelease: false
48
48
  description: IqRdf - A builder like rdf library for ruby and rails
49
49
  email:
50
50
  - till.schulte-coerne@innoq.com
@@ -79,6 +79,7 @@ files:
79
79
  - lib/iq_rdf.rb
80
80
  - rails/init.rb
81
81
  - test/iq_rdf_test.rb
82
+ - test/ntriples_test.rb
82
83
  - test/test_helper.rb
83
84
  - test/turtle_test.rb
84
85
  - test/xml_test.rb
@@ -117,6 +118,7 @@ specification_version: 3
117
118
  summary: IqRdf - A builder like rdf library for ruby and rails
118
119
  test_files:
119
120
  - test/iq_rdf_test.rb
121
+ - test/ntriples_test.rb
120
122
  - test/test_helper.rb
121
123
  - test/turtle_test.rb
122
124
  - test/xml_test.rb