Skip to content

Commit 6bceabb

Browse files
committed
Finish 3.0.13
2 parents 2212f81 + 390fa92 commit 6bceabb

File tree

10 files changed

+44
-19
lines changed

10 files changed

+44
-19
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.12
1+
3.0.13

lib/rdf.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
require 'rdf/version'
77
require 'rdf/extensions'
88

9+
# When loading, issue deprecation warning on forthcoming unsupported versions of Ruby
10+
warn "[DEPRECATION] Ruby 2.4+ required in next version 3.1 of RDF.rb" if RUBY_VERSION < "2.4"
11+
912
module RDF
1013
# RDF mixins
1114
autoload :Countable, 'rdf/mixin/countable'

lib/rdf/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def to_hash
262262
description: "Validate parsed input",
263263
control: :none,
264264
parse: true,
265-
help: "validate [options] [args...]\nvalidates parsed input (may also be used with --validate)",
265+
help: "validate [options] [args...]\nvalidates resulting repository (may also be used with --validate to check for parse-time errors)",
266266
lambda: ->(argv, opts) do
267267
opts[:output].puts "Input is " + (repository.valid? ? "" : "in") + "valid"
268268
end,

lib/rdf/model/literal.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module RDF
4949
# RDF::Literal.new(123).datatype #=> XSD.integer
5050
# RDF::Literal.new(9223372036854775807).datatype #=> XSD.integer
5151
# RDF::Literal.new(3.1415).datatype #=> XSD.double
52-
# RDF::Literal.new(Time.now).datatype #=> XSD.time
52+
# RDF::Literal.new(Time.now).datatype #=> XSD.dateTime
5353
# RDF::Literal.new(Date.new(2010)).datatype #=> XSD.date
5454
# RDF::Literal.new(DateTime.new(2010)).datatype #=> XSD.dateTime
5555
#
@@ -119,8 +119,8 @@ def self.new(value, language: nil, datatype: nil, lexical: nil, validate: false,
119119
when ::Float then RDF::Literal::Double
120120
when ::BigDecimal then RDF::Literal::Decimal
121121
when ::DateTime then RDF::Literal::DateTime
122+
when ::Time then RDF::Literal::DateTime
122123
when ::Date then RDF::Literal::Date
123-
when ::Time then RDF::Literal::Time # FIXME: Ruby's Time class can represent datetimes as well
124124
when ::Symbol then RDF::Literal::Token
125125
else self
126126
end
@@ -360,7 +360,7 @@ def has_datatype?
360360
# @return [Boolean] `true` or `false`
361361
# @since 0.2.1
362362
def valid?
363-
return false if language? && language.to_s !~ /^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/
363+
return false if language? && language.to_s !~ /^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/
364364
return false if datatype? && datatype.invalid?
365365
grammar = self.class.const_get(:GRAMMAR) rescue nil
366366
grammar.nil? || value.match?(grammar)

lib/rdf/model/uri.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ def join(*uris)
431431
joined_parts[:query] = uri.query
432432
else
433433
# Merge path segments from section 5.2.3
434-
base_path = path.to_s.sub(/\/[^\/]*$/, '/')
434+
# Note that if the path includes no segments, the entire path is removed
435+
# > return a string consisting of the reference's path component appended to all but the last segment of the base URI's path (i.e., excluding any characters after the right-most "/" in the base URI path, or excluding the entire base URI path if it does not contain any "/" characters).
436+
base_path = path.to_s.include?('/') ? path.to_s.sub(/\/[^\/]*$/, '/') : ''
435437
joined_parts[:path] = self.class.normalize_path(base_path + uri.path)
436438
joined_parts[:query] = uri.query
437439
end

lib/rdf/util/file.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class HttpAdapter
3232
# @return [Hash] A hash of HTTP request headers
3333
def self.headers headers: {}
3434
headers['Accept'] ||= default_accept_header
35+
headers['User-Agent'] ||= default_user_agent
3536
headers
3637
end
3738

@@ -40,14 +41,24 @@ def self.headers headers: {}
4041
def self.default_accept_header
4142
(RDF::Format.accept_types + %w(*/*;q=0.1)).join(", ")
4243
end
43-
44+
45+
##
46+
# @return [String] the default User-Agent used when fetching resources.
47+
def self.default_user_agent
48+
"Ruby RDF.rb/#{RDF::VERSION}"
49+
end
50+
4451
##
4552
# @abstract
4653
# @param [String] base_uri to open
4754
# @param [String] proxy
4855
# HTTP Proxy to use for requests.
4956
# @param [Array, String] headers ({})
5057
# HTTP Request headers
58+
#
59+
# Defaults `Accept` header based on available reader content types to allow for content negotiation based on available readers.
60+
#
61+
# Defaults `User-Agent` header, unless one is specified.
5162
# @param [Boolean] verify_none (false)
5263
# Don't verify SSL certificates
5364
# @param [Hash{Symbol => Object}] options
@@ -249,19 +260,13 @@ def http_adapter(use_net_http = false)
249260
##
250261
# Open the file, returning or yielding {RemoteDocument}.
251262
#
252-
# Adds Accept header based on available reader content types to allow
253-
# for content negotiation based on available readers.
254-
#
255263
# Input received as non-unicode, is transformed to UTF-8. With Ruby >= 2.2, all UTF is normalized to [Unicode Normalization Form C (NFC)](http://unicode.org/reports/tr15/#Norm_Forms).
256264
#
257265
# HTTP resources may be retrieved via proxy using the `proxy` option. If `RestClient` is loaded, they will use the proxy globally by setting something like the following:
258266
# `RestClient.proxy = "http://proxy.example.com/"`.
259267
# When retrieving documents over HTTP(S), use the mechanism described in [Providing and Discovering URI Documentation](http://www.w3.org/2001/tag/awwsw/issue57/latest/) to pass the appropriate `base_uri` to the block or as the return.
260268
#
261-
# Applications needing HTTP caching may consider
262-
# [Rest Client](https://rubygems.org/gems/rest-client) and
263-
# [REST Client Components](https://rubygems.org/gems/rest-client-components)
264-
# allowing the use of `Rack::Cache` as a local file cache.
269+
# Applications needing HTTP caching may consider [Rest Client](https://rubygems.org/gems/rest-client) and [REST Client Components](https://rubygems.org/gems/rest-client-components) allowing the use of `Rack::Cache` as a local file cache.
265270
#
266271
# @example using a local HTTP cache
267272
# require 'restclient/components'
@@ -275,6 +280,11 @@ def http_adapter(use_net_http = false)
275280
# HTTP Proxy to use for requests.
276281
# @param [Array, String] headers ({})
277282
# HTTP Request headers
283+
#
284+
# Defaults `Accept` header based on available reader content types to allow for content negotiation based on available readers.
285+
#
286+
# Defaults `User-Agent` header, unless one is specified.
287+
#
278288
# @param [Boolean] verify_none (false)
279289
# Don't verify SSL certificates
280290
# @param [Hash{Symbol => Object}] options

rdf.gemspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ Gem::Specification.new do |gem|
1111
gem.summary = 'A Ruby library for working with Resource Description Framework (RDF) data.'
1212
gem.description = 'RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data.'
1313
gem.metadata = {
14-
"documentation_uri" => "https://rubydoc.info/github/ruby-rdf/rdf"
14+
"documentation_uri" => "https://rubydoc.info/github/ruby-rdf/rdf",
15+
"bug_tracker_uri" => "https://github.com/ruby-rdf/rdf/issues",
16+
"homepage_uri" => "https://ruby-rdf.github.io/rdf",
17+
"mailing_list_uri" => "https://lists.w3.org/Archives/Public/public-rdf-ruby/",
18+
"source_code_uri" => "https://github.com/ruby-rdf/rdf",
1519
}
1620

1721
gem.authors = ['Arto Bendiken', 'Ben Lavender', 'Gregg Kellogg']

spec/model_literal_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def self.literal(selector)
2525
when :date then [Date.new(2010)]
2626
when :datetime then [DateTime.new(2011)]
2727
when :time then [Time.parse('01:02:03Z')]
28-
when :date then [Date.new(2010)]
2928
else
3029
raise("unexpected literal: :#{selector}")
3130
end
@@ -138,7 +137,7 @@ def self.literals(*selector)
138137
3.1415 => "double",
139138
Date.new(2010) => "date",
140139
DateTime.new(2011) => "dateTime",
141-
Time.parse("01:02:03Z") => "time"
140+
Time.parse("01:02:03Z") => "dateTime"
142141
}.each_pair do |value, type|
143142
it "returns xsd.#{type} for #{value.inspect} #{value.class}" do
144143
expect(RDF::Literal.new(value).datatype).to eq XSD[type]
@@ -217,7 +216,7 @@ def self.literals(*selector)
217216
literal(:double) => "3.1415",
218217
literal(:date) => "2010-01-01",
219218
literal(:datetime) => "2011-01-01T00:00:00Z",
220-
literal(:time) => "01:02:03Z"
219+
literal(:time) => "#{Date.today}T01:02:03Z"
221220
}.each_pair do |args, rep|
222221
it "returns #{rep} for #{args.inspect}" do
223222
literal = RDF::Literal.new(*args)

spec/model_uri_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@
606606
%w(http://a/bb/ccc/.. g#s) => "<http://a/bb/ccc/g#s>",
607607

608608
%w(file:///a/bb/ccc/d;p?q g) => "<file:///a/bb/ccc/g>",
609+
# merging rootless base URL paths (json-ld-api 397f48b959c4517fef55a7b2623ad432e923240c)
610+
%w(tag:example a) => "<tag:a>",
609611
}.each_pair do |(lhs, rhs), result|
610612
it "creates #{result} from <#{lhs}> and '#{rhs}'" do
611613
expect(RDF::URI.new(lhs).join(rhs.to_s).to_base).to eq result

spec/util_file_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
expect(subject).to include "application/xhtml+xml;q=0.7"
5252
end
5353
end
54+
55+
describe ".default_user_agent" do
56+
subject {RDF::Util::File::HttpAdapter.default_user_agent}
57+
specify {is_expected.to eq "Ruby RDF.rb/#{RDF::VERSION}"}
58+
end
5459
end
5560

5661
describe RDF::Util::File::FaradayAdapter do
@@ -103,7 +108,7 @@
103108
to_return(body: File.read(File.expand_path("../../etc/doap.nt", __FILE__)),
104109
status: 200,
105110
headers: { 'Content-Type' => RDF::NTriples::Format.content_type.first})
106-
r = RDF::Util::File.open_file(uri) do |f|
111+
r = RDF::Util::File.open_file(uri) do |f|
107112
expect(f).to respond_to(:read)
108113
expect(f.content_type).to eq RDF::NTriples::Format.content_type.first
109114
expect(f.code).to eq 200

0 commit comments

Comments
 (0)