rdf 3.2.10 → 3.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/rdf/model/list.rb +0 -13
- data/lib/rdf/model/uri.rb +60 -43
- data/lib/rdf/util/cache.rb +1 -1
- data/lib/rdf/util/uuid.rb +2 -2
- data/lib/rdf.rb +0 -1
- metadata +3 -4
- data/lib/rdf/extensions.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ef89e587b939972de3597dc342a8833f6815f2a00e06369c3384337ff78523b
|
4
|
+
data.tar.gz: 91754a8af99feb95e0c2d318d89eefe8593c8ceded4cf89e90765e77d21811b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da439fdf65b894cf527b85f6ac5315e5fc6c2066c9e642cd36ed67bb1c674b766adbb23a345030d2dbb8af4af1054efc416ebcc8731a04ee803eae682fb34229
|
7
|
+
data.tar.gz: 9da07ff7cf54522a90a0a396a5f8cad5b6b89d373a2675db89a5287865ee80db1d0359d03c6a10f30313d7eb93f101673ba2ff87cef9695e2df929a04d4e481d
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ This is a pure-Ruby library for working with [Resource Description Framework
|
|
5
5
|
|
6
6
|
* <https://ruby-rdf.github.io/rdf>
|
7
7
|
|
8
|
-
[![Gem Version](https://badge.fury.io/rb/rdf.
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/rdf.svg)](https://badge.fury.io/rb/rdf)
|
9
9
|
[![Build Status](https://github.com/ruby-rdf/rdf/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf/actions?query=workflow%3ACI)
|
10
10
|
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf/badge.svg?branch=develop)](https://coveralls.io/github/ruby-rdf/rdf?branch=develop)
|
11
11
|
[![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.11
|
data/lib/rdf/model/list.rb
CHANGED
@@ -280,19 +280,6 @@ module RDF
|
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
283
|
-
##
|
284
|
-
# Returns the element at `index`.
|
285
|
-
#
|
286
|
-
# @example
|
287
|
-
# RDF::List[1, 2, 3][0] #=> RDF::Literal(1)
|
288
|
-
#
|
289
|
-
# @param [Integer] index
|
290
|
-
# @return [RDF::Term]
|
291
|
-
# @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-5B-5D
|
292
|
-
def [](index)
|
293
|
-
at(index)
|
294
|
-
end
|
295
|
-
|
296
283
|
##
|
297
284
|
# Element Assignment — Sets the element at `index`, or replaces a subarray from the `start` index for `length` elements, or replaces a subarray specified by the `range` of indices.
|
298
285
|
#
|
data/lib/rdf/model/uri.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'cgi'
|
3
4
|
|
4
5
|
module RDF
|
@@ -28,27 +29,27 @@ module RDF
|
|
28
29
|
include RDF::Resource
|
29
30
|
|
30
31
|
# IRI components
|
31
|
-
UCSCHAR =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
IPRIVATE = Regexp.compile("[\\uE000-\\uF8FF
|
32
|
+
UCSCHAR = %(
|
33
|
+
\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF
|
34
|
+
\\u{10000}-\\u{1FFFD}\\u{20000}-\\u{2FFFD}\\u{30000}-\\u{3FFFD}
|
35
|
+
\\u{40000}-\\u{4FFFD}\\u{50000}-\\u{5FFFD}\\u{60000}-\\u{6FFFD}
|
36
|
+
\\u{70000}-\\u{7FFFD}\\u{80000}-\\u{8FFFD}\\u{90000}-\\u{9FFFD}
|
37
|
+
\\u{A0000}-\\u{AFFFD}\\u{B0000}-\\u{BFFFD}\\u{C0000}-\\u{CFFFD}
|
38
|
+
\\u{D0000}-\\u{DFFFD}\\u{E1000}-\\u{EFFFD}
|
39
|
+
).gsub(/\s+/, '')
|
40
|
+
IPRIVATE = Regexp.compile("[\\uE000-\\uF8FF\\u{F0000}-\\u{FFFFD}\\u{100000}-\\u{10FFFD}]").freeze
|
40
41
|
SCHEME = Regexp.compile("[A-Za-z](?:[A-Za-z0-9+-\.])*").freeze
|
41
42
|
PORT = Regexp.compile("[0-9]*").freeze
|
42
43
|
IP_literal = Regexp.compile("\\[[0-9A-Fa-f:\\.]*\\]").freeze # Simplified, no IPvFuture
|
43
44
|
PCT_ENCODED = Regexp.compile("%[0-9A-Fa-f][0-9A-Fa-f]").freeze
|
44
|
-
GEN_DELIMS = Regexp.compile(
|
45
|
-
SUB_DELIMS = Regexp.compile(
|
46
|
-
RESERVED = Regexp.
|
45
|
+
GEN_DELIMS = Regexp.compile(%q{[:/\?\#\[\]@]}).freeze
|
46
|
+
SUB_DELIMS = Regexp.compile(%q{[!\$&'\(\)\*\+,;=]}).freeze
|
47
|
+
RESERVED = Regexp.union(GEN_DELIMS, SUB_DELIMS).freeze
|
47
48
|
UNRESERVED = Regexp.compile("[A-Za-z0-9\._~-]").freeze
|
48
49
|
|
49
|
-
IUNRESERVED = Regexp.compile("[
|
50
|
+
IUNRESERVED = Regexp.union(UNRESERVED, Regexp.compile("[#{UCSCHAR}]")).freeze
|
50
51
|
|
51
|
-
IPCHAR = Regexp.
|
52
|
+
IPCHAR = Regexp.union(IUNRESERVED, PCT_ENCODED, SUB_DELIMS, /[:|@]/).freeze
|
52
53
|
|
53
54
|
IQUERY = Regexp.compile("(?:#{IPCHAR}|#{IPRIVATE}|/|\\?)*").freeze
|
54
55
|
|
@@ -65,7 +66,7 @@ module RDF
|
|
65
66
|
IPATH_EMPTY = Regexp.compile("").freeze
|
66
67
|
|
67
68
|
IREG_NAME = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS}))*").freeze
|
68
|
-
IHOST = Regexp.
|
69
|
+
IHOST = Regexp.union(IP_literal, IREG_NAME).freeze
|
69
70
|
IUSERINFO = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|:)*").freeze
|
70
71
|
IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?::#{PORT})?").freeze
|
71
72
|
|
@@ -116,7 +117,21 @@ module RDF
|
|
116
117
|
# Note: not all reserved characters need to be escaped in SPARQL/Turtle, but they must be unescaped when encountered
|
117
118
|
PN_ESCAPE_CHARS = /[~\.!\$&'\(\)\*\+,;=\/\?\#@%]/.freeze
|
118
119
|
PN_ESCAPES = /\\#{Regexp.union(PN_ESCAPE_CHARS, /[\-_]/)}/.freeze
|
119
|
-
|
120
|
+
|
121
|
+
# For URI encoding
|
122
|
+
# iuserinfo = *( iunreserved / pct-encoded / sub-delims / ":" )
|
123
|
+
ENCODE_USER =
|
124
|
+
ENCODE_PASSWORD = Regexp.compile("[^A-Za-z0-9\._~#{UCSCHAR}!$&'\(\)\*\+,;=:-]").freeze
|
125
|
+
# isegment = *ipchar
|
126
|
+
# ipchar = iunreserved / pct-encoded / sub-delims / ":" / "@"
|
127
|
+
ENCODE_ISEGMENT = Regexp.compile("[^A-Za-z0-9\._~#{UCSCHAR}!$&'\(\)\*\+,;=:-]").freeze
|
128
|
+
# isegment-nz-nc = 1*( iunreserved / pct-encoded / sub-delims / "@" )
|
129
|
+
ENCODE_ISEGMENT_NC = Regexp.compile("[^A-Za-z0-9\._~#{UCSCHAR}!$&'\(\)\*\+,;=-]").freeze
|
130
|
+
# iquery = *( ipchar / iprivate / "/" / "?" )
|
131
|
+
ENCODE_IQUERY = Regexp.compile("[^A-Za-z0-9\._~#{UCSCHAR}\\uE000-\\uF8FF\\u{F0000}-\\u{FFFFD}\\u{100000}-\\u{10FFFD}/?=]").freeze
|
132
|
+
# ifragment = *( ipchar / "/" / "?" )
|
133
|
+
ENCODE_IFRAGMENT = Regexp.compile("[^A-Za-z0-9\._~#{UCSCHAR}/?]").freeze
|
134
|
+
|
120
135
|
##
|
121
136
|
# Cache size may be set through {RDF.config} using `uri_cache_size`.
|
122
137
|
#
|
@@ -170,7 +185,7 @@ module RDF
|
|
170
185
|
# @return [String] normalized path
|
171
186
|
# @see http://tools.ietf.org/html/rfc3986#section-5.2.4
|
172
187
|
def self.normalize_path(path)
|
173
|
-
output, input =
|
188
|
+
output, input = String.new, path.to_s
|
174
189
|
if input.encoding != Encoding::ASCII_8BIT
|
175
190
|
input = input.dup.force_encoding(Encoding::ASCII_8BIT)
|
176
191
|
end
|
@@ -353,7 +368,7 @@ module RDF
|
|
353
368
|
# @return [Boolean] `true` or `false`
|
354
369
|
# @since 0.3.9
|
355
370
|
def valid?
|
356
|
-
RDF::URI::IRI.match(to_s) || false
|
371
|
+
RDF::URI::IRI.match?(to_s) || false
|
357
372
|
end
|
358
373
|
|
359
374
|
##
|
@@ -920,7 +935,7 @@ module RDF
|
|
920
935
|
# Return normalized version of scheme, if any
|
921
936
|
# @return [String]
|
922
937
|
def normalized_scheme
|
923
|
-
|
938
|
+
scheme.strip.downcase if scheme
|
924
939
|
end
|
925
940
|
|
926
941
|
##
|
@@ -946,7 +961,7 @@ module RDF
|
|
946
961
|
# Normalized version of user
|
947
962
|
# @return [String]
|
948
963
|
def normalized_user
|
949
|
-
URI.encode(CGI.unescape(user),
|
964
|
+
URI.encode(CGI.unescape(user), ENCODE_USER).force_encoding(Encoding::UTF_8) if user
|
950
965
|
end
|
951
966
|
|
952
967
|
##
|
@@ -972,7 +987,7 @@ module RDF
|
|
972
987
|
# Normalized version of password
|
973
988
|
# @return [String]
|
974
989
|
def normalized_password
|
975
|
-
URI.encode(CGI.unescape(password),
|
990
|
+
URI.encode(CGI.unescape(password), ENCODE_PASSWORD).force_encoding(Encoding::UTF_8) if password
|
976
991
|
end
|
977
992
|
|
978
993
|
HOST_FROM_AUTHORITY_RE = /(?:[^@]+@)?([^:]+)(?::.*)?$/.freeze
|
@@ -1000,7 +1015,7 @@ module RDF
|
|
1000
1015
|
# @return [String]
|
1001
1016
|
def normalized_host
|
1002
1017
|
# Remove trailing '.' characters
|
1003
|
-
|
1018
|
+
host.sub(/\.*$/, '').downcase if host
|
1004
1019
|
end
|
1005
1020
|
|
1006
1021
|
PORT_FROM_AUTHORITY_RE = /:(\d+)$/.freeze
|
@@ -1028,12 +1043,8 @@ module RDF
|
|
1028
1043
|
# @return [String]
|
1029
1044
|
def normalized_port
|
1030
1045
|
if port
|
1031
|
-
np =
|
1032
|
-
|
1033
|
-
nil
|
1034
|
-
else
|
1035
|
-
np.to_i
|
1036
|
-
end
|
1046
|
+
np = port.to_i
|
1047
|
+
PORT_MAPPING[normalized_scheme] != np ? np : nil
|
1037
1048
|
end
|
1038
1049
|
end
|
1039
1050
|
|
@@ -1064,30 +1075,36 @@ module RDF
|
|
1064
1075
|
# Normalized version of path
|
1065
1076
|
# @return [String]
|
1066
1077
|
def normalized_path
|
1078
|
+
if normalized_scheme == "urn"
|
1079
|
+
# Special-case URI. Normalize the NID component only
|
1080
|
+
nid, p = path.to_s.split(':', 2)
|
1081
|
+
return "#{nid.downcase}:#{p}"
|
1082
|
+
end
|
1083
|
+
|
1067
1084
|
segments = path.to_s.split('/', -1) # preserve null segments
|
1068
1085
|
|
1069
1086
|
norm_segs = case
|
1070
1087
|
when authority
|
1071
1088
|
# ipath-abempty
|
1072
|
-
segments.map {|s| normalize_segment(s,
|
1089
|
+
segments.map {|s| normalize_segment(s, ENCODE_ISEGMENT)}
|
1073
1090
|
when segments[0].nil?
|
1074
1091
|
# ipath-absolute
|
1075
1092
|
res = [nil]
|
1076
|
-
res << normalize_segment(segments[1],
|
1077
|
-
res += segments[2..-1].map {|s| normalize_segment(s,
|
1093
|
+
res << normalize_segment(segments[1], ENCODE_ISEGMENT) if segments.length > 1
|
1094
|
+
res += segments[2..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 2
|
1078
1095
|
res
|
1079
1096
|
when segments[0].to_s.index(':')
|
1080
1097
|
# ipath-noscheme
|
1081
1098
|
res = []
|
1082
|
-
res << normalize_segment(segments[0],
|
1083
|
-
res += segments[1..-1].map {|s| normalize_segment(s,
|
1099
|
+
res << normalize_segment(segments[0], ENCODE_ISEGMENT_NC)
|
1100
|
+
res += segments[1..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 1
|
1084
1101
|
res
|
1085
1102
|
when segments[0]
|
1086
1103
|
# ipath-rootless
|
1087
1104
|
# ipath-noscheme
|
1088
1105
|
res = []
|
1089
|
-
res << normalize_segment(segments[0],
|
1090
|
-
res += segments[1..-1].map {|s| normalize_segment(s,
|
1106
|
+
res << normalize_segment(segments[0], ENCODE_ISEGMENT)
|
1107
|
+
res += segments[1..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 1
|
1091
1108
|
res
|
1092
1109
|
else
|
1093
1110
|
# Should be empty
|
@@ -1096,7 +1113,7 @@ module RDF
|
|
1096
1113
|
|
1097
1114
|
res = self.class.normalize_path(norm_segs.join("/"))
|
1098
1115
|
# Special rules for specific protocols having empty paths
|
1099
|
-
|
1116
|
+
(res.empty? && %w(http https ftp tftp).include?(normalized_scheme)) ? '/' : res
|
1100
1117
|
end
|
1101
1118
|
|
1102
1119
|
##
|
@@ -1120,7 +1137,7 @@ module RDF
|
|
1120
1137
|
# Normalized version of query
|
1121
1138
|
# @return [String]
|
1122
1139
|
def normalized_query
|
1123
|
-
normalize_segment(query,
|
1140
|
+
normalize_segment(query, ENCODE_IQUERY) if query
|
1124
1141
|
end
|
1125
1142
|
|
1126
1143
|
##
|
@@ -1144,7 +1161,7 @@ module RDF
|
|
1144
1161
|
# Normalized version of fragment
|
1145
1162
|
# @return [String]
|
1146
1163
|
def normalized_fragment
|
1147
|
-
normalize_segment(fragment,
|
1164
|
+
normalize_segment(fragment, ENCODE_IFRAGMENT) if fragment
|
1148
1165
|
end
|
1149
1166
|
|
1150
1167
|
##
|
@@ -1274,7 +1291,7 @@ module RDF
|
|
1274
1291
|
self.query = case value
|
1275
1292
|
when Array, Hash
|
1276
1293
|
value.map do |(k,v)|
|
1277
|
-
k = normalize_segment(k.to_s,
|
1294
|
+
k = normalize_segment(k.to_s, /[^A-Za-z0-9\._~-]/)
|
1278
1295
|
if v.nil?
|
1279
1296
|
k
|
1280
1297
|
else
|
@@ -1282,7 +1299,7 @@ module RDF
|
|
1282
1299
|
if vv === TrueClass
|
1283
1300
|
k
|
1284
1301
|
else
|
1285
|
-
"#{k}=#{normalize_segment(vv.to_s,
|
1302
|
+
"#{k}=#{normalize_segment(vv.to_s, /[^A-Za-z0-9\._~-]/)}"
|
1286
1303
|
end
|
1287
1304
|
end.join("&")
|
1288
1305
|
end
|
@@ -1331,7 +1348,7 @@ module RDF
|
|
1331
1348
|
# Normalize a segment using a character range
|
1332
1349
|
#
|
1333
1350
|
# @param [String] value
|
1334
|
-
# @param [Regexp] expr
|
1351
|
+
# @param [Regexp] expr matches characters to be encoded
|
1335
1352
|
# @param [Boolean] downcase
|
1336
1353
|
# @return [String]
|
1337
1354
|
def normalize_segment(value, expr, downcase = false)
|
@@ -1339,7 +1356,7 @@ module RDF
|
|
1339
1356
|
value = value.dup.force_encoding(Encoding::UTF_8)
|
1340
1357
|
decoded = CGI.unescape(value)
|
1341
1358
|
decoded.downcase! if downcase
|
1342
|
-
URI.encode(decoded,
|
1359
|
+
URI.encode(decoded, expr).force_encoding(Encoding::UTF_8)
|
1343
1360
|
end
|
1344
1361
|
end
|
1345
1362
|
|
@@ -1364,7 +1381,7 @@ module RDF
|
|
1364
1381
|
def self.encode(str, expr)
|
1365
1382
|
str.gsub(expr) do
|
1366
1383
|
us = $&
|
1367
|
-
tmp =
|
1384
|
+
tmp = String.new
|
1368
1385
|
us.each_byte do |uc|
|
1369
1386
|
tmp << sprintf('%%%02X', uc)
|
1370
1387
|
end
|
data/lib/rdf/util/cache.rb
CHANGED
data/lib/rdf/util/uuid.rb
CHANGED
@@ -22,11 +22,11 @@ module RDF; module Util
|
|
22
22
|
begin
|
23
23
|
require 'uuid'
|
24
24
|
::UUID.generate(format)
|
25
|
-
rescue LoadError
|
25
|
+
rescue LoadError
|
26
26
|
begin
|
27
27
|
require 'uuidtools'
|
28
28
|
::UUIDTools::UUID.random_create.hexdigest
|
29
|
-
rescue LoadError
|
29
|
+
rescue LoadError
|
30
30
|
raise LoadError.new("no such file to load -- uuid or uuidtools")
|
31
31
|
end
|
32
32
|
end
|
data/lib/rdf.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arto Bendiken
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|
@@ -210,7 +210,6 @@ files:
|
|
210
210
|
- lib/rdf.rb
|
211
211
|
- lib/rdf/changeset.rb
|
212
212
|
- lib/rdf/cli.rb
|
213
|
-
- lib/rdf/extensions.rb
|
214
213
|
- lib/rdf/format.rb
|
215
214
|
- lib/rdf/mixin/countable.rb
|
216
215
|
- lib/rdf/mixin/durable.rb
|
@@ -295,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
295
294
|
- !ruby/object:Gem::Version
|
296
295
|
version: '0'
|
297
296
|
requirements: []
|
298
|
-
rubygems_version: 3.4.
|
297
|
+
rubygems_version: 3.4.10
|
299
298
|
signing_key:
|
300
299
|
specification_version: 4
|
301
300
|
summary: A Ruby library for working with Resource Description Framework (RDF) data.
|
data/lib/rdf/extensions.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# This file provides compatibility monkeypatches to standard library classes
|
3
|
-
# Implementation taken from MIT-licensed https://github.com/marcandre/backports
|
4
|
-
#
|
5
|
-
|
6
|
-
# https://github.com/marcandre/backports/blob/master/lib/backports/2.4.0/regexp/match.rb
|
7
|
-
unless Regexp.method_defined? :match?
|
8
|
-
class Regexp
|
9
|
-
def match?(*args)
|
10
|
-
!match(*args).nil?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# https://github.com/marcandre/backports/blob/master/lib/backports/2.4.0/string/match.rb
|
16
|
-
unless String.method_defined? :match?
|
17
|
-
class String
|
18
|
-
def match?(*args)
|
19
|
-
!match(*args).nil?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|