Skip to content

Commit 0f2323b

Browse files
committed
Release 1.1.4
* Remove whitespace around outer RDF tag; not ideal but it works. (issue #33) * Add back support for `max_depth` writer option (default 10). (issue #27) * correct XML escaping of illegal characters in literals (@barmintor) * Don't write out property value both as attribute and element by expanding attribute key to a URI before removing from properties. * To work around odd Nokogiri issue with reading files while specifying an encoding, read the file in to memory before passing to Nokogiri. (issue #35)
2 parents c69b4fb + 39ebe84 commit 0f2323b

14 files changed

Lines changed: 2836 additions & 47 deletions

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ rvm:
77
- 1.9.3
88
- 2.0
99
- 2.1
10-
- jruby-19mode
10+
- 2.2
11+
- jruby
1112
- rbx-2
1213
gemfile:
1314
- Gemfile

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
101101
[Ruby]: http://ruby-lang.org/
102102
[RDF]: http://www.w3.org/RDF/
103103
[RDF.rb]: http://rubygems.org/gems/rdf
104-
[RDF/XML]: http://www.w3.org/TR/REC-rdf-syntax/ "RDF/XML Syntax Specification"
104+
[RDF/XML]: hhttp://www.w3.org/TR/rdf-syntax-grammar/ "RDF/XML Syntax Specification"
105105
[YARD]: http://yardoc.org/
106106
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
107107
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html

Rakefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,14 @@ end
4848

4949
task :specs => :spec
5050
task :default => :spec
51+
52+
53+
desc "Generate etc/doap.{nt,ttl} from etc/doap.html."
54+
task :doap do
55+
require 'rdf/rdfxml'
56+
require 'rdf/turtle'
57+
require 'rdf/ntriples'
58+
g = RDF::Graph.load("etc/doap.rdf")
59+
RDF::NTriples::Writer.open("etc/doap.nt") {|w| w <<g }
60+
RDF::Turtle::Writer.open("etc/doap.ttl", standard_prefixes: true) {|w| w <<g }
61+
end

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.3
1+
1.1.4

etc/doap.nt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<http://rubygems.org/gems/rdf-rdfxml> <http://usefulinc.com/ns/doap#developer> <http://greggkellogg.net/foaf#me> .
1010
<http://rubygems.org/gems/rdf-rdfxml> <http://usefulinc.com/ns/doap#helper> <http://njh.me/> .
1111
<http://rubygems.org/gems/rdf-rdfxml> <http://usefulinc.com/ns/doap#documenter> <http://greggkellogg.net/foaf#me> .
12+
<http://rubygems.org/gems/rdf-rdfxml> <http://usefulinc.com/ns/doap#implements> <http://www.w3.org/TR/rdf-syntax-grammar/> .
1213
<http://rubygems.org/gems/rdf-rdfxml> <http://usefulinc.com/ns/doap#download-page> <http://rubygems.org/gems/rdf-rdfxml> .
1314
<http://rubygems.org/gems/rdf-rdfxml> <http://usefulinc.com/ns/doap#homepage> <http://github.com/gkellogg/rdf-rdfxml> .
1415
<http://rubygems.org/gems/rdf-rdfxml> <http://usefulinc.com/ns/doap#mailing-list> <http://lists.w3.org/Archives/Public/public-rdf-ruby/> .

etc/doap.rdf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<doap:developer rdf:resource="http://greggkellogg.net/foaf#me"/>
2020
<doap:helper rdf:resource="http://njh.me/"/>
2121
<doap:documenter rdf:resource="http://greggkellogg.net/foaf#me"/>
22+
<doap:implements rdf:resource="http://www.w3.org/TR/rdf-syntax-grammar/"/>
2223
<doap:download-page rdf:resource="http://rubygems.org/gems/rdf-rdfxml"/>
2324
<doap:homepage rdf:resource="http://github.com/gkellogg/rdf-rdfxml"/>
2425
<doap:mailing-list rdf:resource="http://lists.w3.org/Archives/Public/public-rdf-ruby/"/>

etc/doap.ttl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@prefix dc: <http://purl.org/dc/terms/> .
2+
@prefix doap: <http://usefulinc.com/ns/doap#> .
3+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
4+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
5+
@prefix xhv: <http://www.w3.org/1999/xhtml/vocab#> .
6+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
7+
8+
<http://rubygems.org/gems/rdf-rdfxml> a doap:Project;
9+
dc:creator <http://greggkellogg.net/foaf#me>;
10+
doap:blog <http://greggkellogg.net/>;
11+
doap:bug-database <http://github.com/ruby-rdf/rdf-rdfxml/issues>;
12+
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
13+
<http://dbpedia.org/resource/Ruby_(programming_language)>;
14+
doap:created "2010-06-03"^^xsd:date;
15+
doap:description """
16+
RDF::RDFXML is an RDF/XML reader/writer for Ruby using the RDF.rb library suite.
17+
"""@en;
18+
doap:developer <http://greggkellogg.net/foaf#me>;
19+
doap:documenter <http://greggkellogg.net/foaf#me>;
20+
doap:download-page <http://rubygems.org/gems/rdf-rdfxml>;
21+
doap:helper <http://njh.me/>;
22+
doap:homepage <http://github.com/gkellogg/rdf-rdfxml>;
23+
doap:implements <http://www.w3.org/TR/rdf-syntax-grammar/>;
24+
doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/>;
25+
doap:maintainer <http://greggkellogg.net/foaf#me>;
26+
doap:name "RDF::RDFXML";
27+
doap:shortdesc "RDF/XML reader/writer for Ruby."@en;
28+
xhv:license <http://creativecommons.org/licenses/publicdomain/>;
29+
foaf:maker <http://greggkellogg.net/foaf#me> .

example-files/dwcterms.rdf

Lines changed: 2679 additions & 0 deletions
Large diffs are not rendered by default.

lib/rdf/rdfxml/reader/nokogiri.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def initialize_xml(input, options = {})
232232
options[:encoding] ||= 'utf-8'
233233
options[:encoding] = options[:encoding].to_s if options[:encoding]
234234

235-
::Nokogiri::XML.parse(input, base_uri.to_s, options[:encoding]) do |config|
235+
::Nokogiri::XML.parse(input.respond_to?(:read) ? input.read : input.to_s, base_uri.to_s, options[:encoding]) do |config|
236236
config.noent
237237
end
238238
end

lib/rdf/rdfxml/writer.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class Writer < RDF::RDFa::Writer
6565
# the prefix mappings to use (not supported by all writers)
6666
# @option options [#to_s] :base_uri (nil)
6767
# the base URI to use when constructing relative URIs
68+
# @option options [Integer] :max_depth (10)
69+
# Maximum depth for recursively defining resources
6870
# @option options [#to_s] :lang (nil)
6971
# Output as root xml:lang attribute, and avoid generation _xml:lang_ where possible
7072
# @option options [Symbol] :attributes (nil)
@@ -92,7 +94,8 @@ def haml_template
9294

9395
def write_epilogue
9496
@force_RDF_about = {}
95-
@attributes = @options[:attributes] || :none
97+
@max_depth = @options.fetch(:max_depth, 10)
98+
@attributes = @options.fetch(:attributes, :none)
9699

97100
super
98101
end
@@ -151,7 +154,7 @@ def render_subject(subject, predicates, options = {}, &block)
151154
{}
152155
end
153156

154-
predicates -= attr_props.keys
157+
predicates -= attr_props.keys.map {|k| expand_curie(k).to_s}
155158
super(subject, predicates, options.merge(:attr_props => attr_props), &block)
156159
end
157160
# See if we can serialize as attribute.
@@ -259,9 +262,10 @@ def render_property(predicate, objects, options = {}, &block)
259262
raise RDF::WriterError, "Missing property template" if template.nil?
260263

261264
options = {
262-
:object => objects.first,
263-
:predicate => predicate,
264-
:property => get_qname(predicate),
265+
object: objects.first,
266+
predicate: predicate,
267+
property: get_qname(predicate),
268+
recurse: @depth <= @max_depth
265269
}.merge(options)
266270
hamlify(template, options, &block)
267271
end
@@ -285,9 +289,10 @@ def render_collection(predicate, list, options = {}, &block)
285289
template = options[:haml] || haml_template[:collection]
286290

287291
options = {
288-
:list => list,
289-
:predicate => predicate,
290-
:property => get_qname(predicate),
292+
list: list,
293+
predicate: predicate,
294+
property: get_qname(predicate),
295+
recurse: @depth <= @max_depth,
291296
}.merge(options)
292297
hamlify(template, options) do |object|
293298
yield object

0 commit comments

Comments
 (0)