Skip to content

Commit 6325096

Browse files
committed
Finish 3.1.5
2 parents 7e547c3 + df74f33 commit 6325096

9 files changed

Lines changed: 42 additions & 25 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.4
1+
3.1.5

bin/rdf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env ruby
2-
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
2+
$:.unshift(File.expand_path("../../lib", __FILE__))
33
require 'rubygems'
4-
require 'rdf/cli'
4+
require 'rdf'
55

66
options = RDF::CLI.options(ARGV)
77

lib/rdf.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ module RDF
7676
# Utilities
7777
autoload :Util, 'rdf/util'
7878

79+
# CLI
80+
autoload :CLI, 'rdf/cli'
81+
7982
##
8083
# Alias for `RDF::Resource.new`.
8184
#

lib/rdf/cli.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require 'linkeddata'
99
rescue LoadError
1010
# Silently load without linkeddata, but try some others
11-
%w(reasoner rdfa rdfxml turtle vocab json/ld ld/patch).each do |ser|
11+
%w(microdata n3 rdfa rdfxml reasoner tabular trig trix turtle vocab xsd json/ld ld/patch).each do |ser|
1212
begin
1313
require ser.include?('/') ? ser : "rdf/#{ser}"
1414
rescue LoadError
@@ -296,6 +296,12 @@ def to_hash
296296
control: :none,
297297
on: ["-o", "--output FILE"],
298298
description: "File to write output, defaults to STDOUT") {|arg| File.open(arg, "w")},
299+
RDF::CLI::Option.new(
300+
symbol: :ordered,
301+
control: :checkbox,
302+
datatype: TrueClass,
303+
on: ["--ordered"],
304+
description: "Use order preserving repository"),
299305
RDF::CLI::Option.new(
300306
symbol: :format,
301307
control: :select,
@@ -495,14 +501,16 @@ def self.exec(args, output: $stdout, option_parser: nil, messages: {}, **options
495501
options[:format] = options[:format].to_sym if options[:format]
496502
options[:output_format] = options[:output_format].to_sym if options[:output_format]
497503

498-
@repository = RDF::Repository.new
504+
@repository = options[:ordered] ?
505+
[].extend(RDF::Enumerable, RDF::Queryable) :
506+
RDF::Repository.new
499507

500508
# Parse input files if any command requires it
501509
if cmds.any? {|c| COMMANDS[c.to_sym][:parse]}
502510
start = Time.new
503511
count = 0
504512
self.parse(args, **options) do |reader|
505-
@repository << reader
513+
reader.each_statement {|st| @repository << st}
506514
end
507515
secs = Time.new - start
508516
options[:logger].info "Parsed #{repository.count} statements with #{@readers.join(', ')} in #{secs} seconds @ #{count/secs} statements/second."

lib/rdf/model/uri.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ def user=(value)
902902
# Normalized version of user
903903
# @return [String]
904904
def normalized_user
905-
URI.encode(CGI.unescape(user), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/) if user
905+
URI.encode(CGI.unescape(user), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/).force_encoding(Encoding::UTF_8) if user
906906
end
907907

908908
##
@@ -928,7 +928,7 @@ def password=(value)
928928
# Normalized version of password
929929
# @return [String]
930930
def normalized_password
931-
URI.encode(CGI.unescape(password), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/) if password
931+
URI.encode(CGI.unescape(password), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/).force_encoding(Encoding::UTF_8) if password
932932
end
933933

934934
HOST_FROM_AUTHORITY_RE = /(?:[^@]+@)?([^:]+)(?::.*)?$/.freeze
@@ -1295,7 +1295,7 @@ def normalize_segment(value, expr, downcase = false)
12951295
value = value.dup.force_encoding(Encoding::UTF_8)
12961296
decoded = CGI.unescape(value)
12971297
decoded.downcase! if downcase
1298-
URI.encode(decoded, /[^(?:#{expr})]/)
1298+
URI.encode(decoded, /[^(?:#{expr})]/).force_encoding(Encoding::UTF_8)
12991299
end
13001300
end
13011301

lib/rdf/util/file.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module RDF; module Util
1414
# allowing the use of `Rack::Cache` to avoid network access.
1515
#
1616
# To use other HTTP clients, consumers can subclass
17-
# {RDF::Util::File::HttpAdapter} and set the {RDF::Util::File.http_adapter}.
17+
# {RDF::Util::File::HttpAdapter} and set the {RDF::Util::File.}.
1818
#
1919
# Also supports the file: scheme for access to local files.
2020
#
@@ -121,8 +121,8 @@ def self.open_url(base_uri, proxy: nil, headers: {}, verify_none: false, **optio
121121

122122
redirect_count = 0
123123
max_redirects = 5
124-
parsed_url = ::URI.parse(base_uri)
125-
parsed_proxy = ::URI.parse(proxy.to_s)
124+
parsed_url = RDF::URI.parse(base_uri)
125+
parsed_proxy = RDF::URI.parse(proxy.to_s)
126126
base_uri = parsed_url.to_s
127127
remote_document = nil
128128

spec/cli_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,16 @@
7676
end
7777
end
7878

79+
describe "--ordered" do
80+
it "sets :ordered" do
81+
options = RDF::CLI.options(%w(help --ordered) << triple)
82+
expect(options.options[:ordered]).to be_truthy
83+
end
84+
end
85+
7986
describe "--evaluate" do
8087
it "sets :evaluate" do
81-
options = RDF::CLI.options(%w(helpcount --format ntriples --evaluate) << triple)
88+
options = RDF::CLI.options(%w(help count --format ntriples --evaluate) << triple)
8289
expect(options.options[:evaluate]).to eql triple
8390
end
8491
end

spec/model_uri_spec.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,18 @@
470470
"urn" => [
471471
"urn:ex:s001",
472472
"urn:ex:s001"
473+
],
474+
"utf-8" => [
475+
"Dürst",
476+
"Dürst"
473477
]
474478
}.each do |name, (input, output)|
475479
it "#canonicalize #{name}" do
476480
u1 = RDF::URI(input)
477481
u2 = RDF::URI(output)
478482
expect(u1.canonicalize.hash).to eq u2.hash
479483
expect(u1.canonicalize.to_s).to eq u2.to_s
480-
expect(u1).to eq u1
484+
expect(u1.canonicalize).to eq u1.canonicalize
481485
end
482486
end
483487
it "#canonicalize! alters resource" do
@@ -486,11 +490,6 @@
486490
expect(u1.canonicalize!.to_s).to eq u2.to_s
487491
expect(u1).to eq u2
488492
end
489-
it "#canonicalize does not fail with Encoding::CompatibilityError on weird IRIs" do
490-
u1 = RDF::URI "htЫtp://user:passoЫd@exaЫmple.com:8080/path ПУТЬ?queЫry=valЫue#fragmeЫnt"
491-
u2 = RDF::URI "ht%D0%ABtp://user:passoЫd@exaЫmple.com:8080/path%20ПУТЬ?queЫry=valЫue#fragmeЫnt"
492-
expect {u1.canonicalize.to_s.dup.force_encoding(u2.to_s.encoding)}.not_to raise_error
493-
end
494493
end
495494

496495
describe "#/" do

spec/util_logger_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,38 +100,38 @@ def initialize(logger = nil)
100100
describe "#log_info" do
101101
it "Logs messages, and yield return" do
102102
subject.log_info("a", "b") {"c"}
103-
expect(subject.logger.to_s).to eql "INFO a: b: c\n"
103+
expect(subject.logger.to_s).to eql " INFO a: b: c\n"
104104
end
105105

106106
it "adds lineno" do
107107
subject.log_info("a", lineno: 10)
108-
expect(subject.logger.to_s).to eql "INFO [line 10] a\n"
108+
expect(subject.logger.to_s).to eql " INFO [line 10] a\n"
109109
end
110110

111111
it "adds depth with option" do
112112
subject.log_info("a", depth: 2)
113-
expect(subject.logger.to_s).to eql "INFO a\n"
113+
expect(subject.logger.to_s).to eql " INFO a\n"
114114
end
115115

116116
it "adds depth with option" do
117117
subject.log_info("a", depth: 2)
118-
expect(subject.logger.to_s).to eql "INFO a\n"
118+
expect(subject.logger.to_s).to eql " INFO a\n"
119119
end
120120

121121
it "uses logger from @options" do
122122
logger = LogTester.new
123123
logger.options[:logger] = RDF::Spec.logger
124124
logger.log_info("a")
125125
expect(logger.instance_variable_get(:@logger).to_s).to be_empty
126-
expect(logger.options[:logger].to_s).to eql "INFO a\n"
126+
expect(logger.options[:logger].to_s).to eql " INFO a\n"
127127
end
128128

129129
it "uses logger from options" do
130130
logger = LogTester.new
131131
l = RDF::Spec.logger
132132
logger.log_info("a", logger: l)
133133
expect(logger.instance_variable_get(:@logger).to_s).to be_empty
134-
expect(l.to_s).to eql "INFO a\n"
134+
expect(l.to_s).to eql " INFO a\n"
135135
end
136136

137137
it "increments log_statistics" do

0 commit comments

Comments
 (0)