Skip to content

Commit ff729b0

Browse files
committed
Finish 3.0.2
2 parents 7c7ad14 + a87d57b commit ff729b0

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.1
1+
3.0.2

lib/rdf/model/uri.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def canonicalize!
407407
# @see <http://tools.ietf.org/html/rfc3986#section-5.2>
408408
# @see RDF::URI#/
409409
# @see RDF::URI#+
410-
# @param [Array<String, RDF::URI, #to_s>] uris
410+
# @param [Array<String, RDF::URI, #to_s>] uris absolute or relative URIs.
411411
# @return [RDF::URI]
412412
# @see http://tools.ietf.org/html/rfc3986#section-5.2.2
413413
# @see http://tools.ietf.org/html/rfc3986#section-5.2.3
@@ -458,6 +458,8 @@ def join(*uris)
458458
# this method does not perform any normalization, removal of spurious
459459
# paths, or removal of parent directory references `(/../)`.
460460
#
461+
# When `fragment` is a path segment containing a colon, best practice is to prepend a `./` and use {#join}, which resolves dot-segments.
462+
#
461463
# See also `#+`, which concatenates the string forms of two URIs without
462464
# any sort of checking or processing.
463465
#

lib/rdf/reader.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ def self.open(filename, format: nil, **options, &block)
207207

208208
Util::File.open_file(filename, options) do |file|
209209
format_options = options.dup
210-
format_options[:content_type] ||= file.content_type if file.respond_to?(:content_type)
210+
format_options[:content_type] ||= file.content_type if
211+
file.respond_to?(:content_type) &&
212+
!file.content_type.to_s.include?('text/plain')
211213
format_options[:file_name] ||= filename
212214
reader = if self == RDF::Reader
213215
# We are the abstract reader class, find an appropriate reader

lib/rdf/vocab/writer.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ def serialize_value(value, key, indent: "")
231231
value.to_ruby(indent: indent + " ")
232232
elsif value.is_a?(RDF::Term)
233233
"#{value.to_s.inspect}.freeze"
234+
elsif value.is_a?(RDF::List)
235+
list_elements = value.map do |u|
236+
if u.uri?
237+
"#{u.pname.inspect}.freeze"
238+
elsif u.respond_to?(:to_ruby)
239+
u.to_ruby(indent: indent + " ")
240+
else
241+
"#{u.to_s.inspect}.freeze"
242+
end
243+
end
244+
"list(#{list_elements.join(', ')})"
234245
else
235246
"#{value.inspect}.freeze"
236247
end

lib/rdf/vocabulary.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,10 @@ def from_graph(graph, url: nil, class_name: nil, extra: nil)
492492
else statement.predicate.pname.to_sym
493493
end
494494

495+
# Skip literals other than plain or english
496+
# This is because the ruby representation does not preserve language
497+
next if statement.object.literal? && (statement.object.language || :en).to_s !~ /^en-?/
498+
495499
(term[key] ||= []) << statement.object
496500
end
497501

@@ -1080,7 +1084,7 @@ def to_ruby(indent: "")
10801084
"term(" +
10811085
(self.uri? ? self.to_s.inspect + ",\n" : "\n") +
10821086
"#{indent} " +
1083-
attributes.keys.map do |k|
1087+
attributes.keys.sort.map do |k|
10841088
values = attribute_value(k)
10851089
values = [values].compact unless values.is_a?(Array)
10861090
values = values.map do |value|

spec/reader_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,20 @@
7171
reader_mock.got_here
7272
end
7373
end
74+
75+
it "ignores content type 'text/plain'" do
76+
uri = "http://example/foo.ttl"
77+
accept = (RDF::Format.accept_types + %w(*/*;q=0.1)).join(", ")
78+
reader_mock = double("reader")
79+
expect(reader_mock).to receive(:got_here)
80+
WebMock.
81+
stub_request(:get, uri).
82+
to_return(body: "foo", status: 200, headers: { 'Content-Type' => 'text/plain'})
83+
84+
described_class.open(uri) do |r|
85+
expect(r).to be_a(RDF::Turtle::Reader)
86+
reader_mock.got_here
87+
end
88+
end
7489
end
7590
end

0 commit comments

Comments
 (0)