rdf-rdfxml 0.2.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ === 0.2.3
2
+ * Fixed QName generation in Writer based on RDF/XML Processing recommendations
3
+
1
4
  === 0.2.2.1
2
5
  * Ruby 1.9.2 support.
3
6
  * Added script/tc to run test cases
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2.1
1
+ 0.2.3
@@ -5,4 +5,12 @@ class Nokogiri::XML::Node
5
5
  ns = self.namespace ? self.namespace.href : RDF::XML.to_s
6
6
  RDF::URI.intern(ns + self.node_name)
7
7
  end
8
- end unless Nokogiri::XML::Node.method_defined?(:uri)
8
+
9
+ def display_path
10
+ @display_path ||= case self
11
+ when Nokogiri::XML::Document then ""
12
+ when Nokogiri::XML::Element then parent ? "#{parent.display_path}/#{name}" : name
13
+ when Nokogiri::XML::Attr then "#{parent.display_path}@#{name}"
14
+ end
15
+ end
16
+ end
@@ -208,9 +208,8 @@ module RDF::RDFXML
208
208
  # Figure out the document path, if it is a Nokogiri::XML::Element or Attribute
209
209
  def node_path(node)
210
210
  case node
211
- when Nokogiri::XML::Element, Nokogiri::XML::Attr then "#{node_path(node.parent)}/#{node.name}"
212
- when String then node
213
- else ""
211
+ when Nokogiri::XML::Node then node.display_path
212
+ else node.to_s
214
213
  end
215
214
  end
216
215
 
@@ -1,8 +1,8 @@
1
1
  module RDF::RDFXML::VERSION
2
2
  MAJOR = 0
3
3
  MINOR = 2
4
- TINY = 2
5
- EXTRA = 1
4
+ TINY = 3
5
+ EXTRA = nil
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  STRING << ".#{EXTRA}" if EXTRA
@@ -393,21 +393,15 @@ module RDF::RDFXML
393
393
 
394
394
  # No vocabulary found, invent one
395
395
  # Add bindings for predicates not already having bindings
396
- # short_name of URI for creating QNames.
397
- # "#{base_uri]{#short_name}}" == uri
398
- local_name = uri.fragment
399
- local_name ||= begin
400
- path = uri.path.split("/")
401
- unless path &&
402
- path.length > 1 &&
403
- path.last.class == String &&
404
- path.last.length > 0 &&
405
- path.last.index("/") != 0
406
- return false
407
- end
408
- path.last
409
- end
410
- base_uri = uri.to_s[0..-(local_name.length + 1)]
396
+ # From RDF/XML Syntax and Processing:
397
+ # An XML namespace-qualified name (QName) has restrictions on the legal characters such that not all property URIs can be expressed
398
+ # as these names. It is recommended that implementors of RDF serializers, in order to break a URI into a namespace name and a local
399
+ # name, split it after the last XML non-NCName character, ensuring that the first character of the name is a Letter or '_'. If the
400
+ # URI ends in a non-NCName character then throw a "this graph cannot be serialized in RDF/XML" exception or error.
401
+ separation = uri.to_s.rindex(%r{[^a-zA-Z_0-9-](?=[a-zA-Z_])})
402
+ return nil unless separation
403
+ base_uri = uri.to_s[0..separation]
404
+ local_name = uri.to_s[separation+1..-1]
411
405
  @tmp_ns = @tmp_ns ? @tmp_ns.succ : "ns0"
412
406
  add_debug "create namespace definition for #{uri}"
413
407
  uri.vocab = RDF::Vocabulary(base_uri)
data/rdf-rdfxml.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rdf-rdfxml}
8
- s.version = "0.2.2.1"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gregg Kellogg"]
12
- s.date = %q{2010-08-11}
12
+ s.date = %q{2010-08-31}
13
13
  s.description = %q{ RDF::RDFXML is an RDF/XML reader and writer for Ruby using the RDF.rb library suite.
14
14
  }
15
15
  s.email = %q{gregg@kellogg-assoc.com}
data/spec/uri_spec.rb CHANGED
@@ -99,6 +99,12 @@ describe RDF::URI do
99
99
  end
100
100
  end
101
101
 
102
+ context "Invalid Formats" do
103
+ it "should detect invalid URI formats" do
104
+ lambda {Addressable::URI.parse("_:test")}.should raise_error(Addressable::URI::InvalidURIError)
105
+ end
106
+ end
107
+
102
108
  context "vocab" do
103
109
  RDF::Vocabulary.each do |v|
104
110
  specify {v.foo.vocab.should == v}
data/spec/writer_spec.rb CHANGED
@@ -323,11 +323,11 @@ describe "RDF::RDFXML::Writer" do
323
323
  describe "with bnodes" do
324
324
  it "should not generate nodeID attribute unless node is referenced as an object" do
325
325
  @graph << [RDF::Node.new("a"), RDF::DC.title, "foo"]
326
- check_xpaths(
327
- serialize(:attributes => :untyped, :base => "http://release/"),
328
- "/rdf:RDF/rdf:Description/@dc:title" => "foo",
329
- "/rdf:RDF/rdf:Description/@rdf:nodeID" => false
330
- )
326
+ check_xpaths(
327
+ serialize(:attributes => :untyped, :base => "http://release/"),
328
+ "/rdf:RDF/rdf:Description/@dc:title" => "foo",
329
+ "/rdf:RDF/rdf:Description/@rdf:nodeID" => false
330
+ )
331
331
  end
332
332
 
333
333
  it "should generate a nodeID attribute if node is referenced as an object" do
@@ -343,7 +343,6 @@ describe "RDF::RDFXML::Writer" do
343
343
  end
344
344
 
345
345
  it "should replicate rdfcore/rdfms-seq-representation" do
346
- $verbose = true
347
346
  graph_expect = parse(%(
348
347
  <http://example.org/eg#eric> a [ <http://example.org/eg#intersectionOf> (<http://example.org/eg#Person> <http://example.org/eg#Male>)] .
349
348
  ), :reader => RDF::N3::Reader)
metadata CHANGED
@@ -1,14 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-rdfxml
3
3
  version: !ruby/object:Gem::Version
4
- hash: 85
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 2
9
- - 2
10
- - 1
11
- version: 0.2.2.1
8
+ - 3
9
+ version: 0.2.3
12
10
  platform: ruby
13
11
  authors:
14
12
  - Gregg Kellogg
@@ -16,7 +14,7 @@ autorequire:
16
14
  bindir: bin
17
15
  cert_chain: []
18
16
 
19
- date: 2010-08-11 00:00:00 -07:00
17
+ date: 2010-08-31 00:00:00 -07:00
20
18
  default_executable:
21
19
  dependencies:
22
20
  - !ruby/object:Gem::Dependency
@@ -27,7 +25,6 @@ dependencies:
27
25
  requirements:
28
26
  - - ">="
29
27
  - !ruby/object:Gem::Version
30
- hash: 19
31
28
  segments:
32
29
  - 0
33
30
  - 2
@@ -43,7 +40,6 @@ dependencies:
43
40
  requirements:
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
- hash: 29
47
43
  segments:
48
44
  - 1
49
45
  - 3
@@ -59,7 +55,6 @@ dependencies:
59
55
  requirements:
60
56
  - - ">="
61
57
  - !ruby/object:Gem::Version
62
- hash: 3
63
58
  segments:
64
59
  - 0
65
60
  version: "0"
@@ -73,7 +68,6 @@ dependencies:
73
68
  requirements:
74
69
  - - ">="
75
70
  - !ruby/object:Gem::Version
76
- hash: 19
77
71
  segments:
78
72
  - 0
79
73
  - 2
@@ -89,7 +83,6 @@ dependencies:
89
83
  requirements:
90
84
  - - ">="
91
85
  - !ruby/object:Gem::Version
92
- hash: 3
93
86
  segments:
94
87
  - 0
95
88
  version: "0"
@@ -103,7 +96,6 @@ dependencies:
103
96
  requirements:
104
97
  - - ">="
105
98
  - !ruby/object:Gem::Version
106
- hash: 3
107
99
  segments:
108
100
  - 0
109
101
  version: "0"
@@ -532,7 +524,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
532
524
  requirements:
533
525
  - - ">="
534
526
  - !ruby/object:Gem::Version
535
- hash: 3
536
527
  segments:
537
528
  - 0
538
529
  version: "0"
@@ -541,7 +532,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
541
532
  requirements:
542
533
  - - ">="
543
534
  - !ruby/object:Gem::Version
544
- hash: 3
545
535
  segments:
546
536
  - 0
547
537
  version: "0"