rdf 3.2.5 → 3.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rdf/cli.rb +3 -2
- data/lib/rdf/format.rb +34 -2
- data/lib/rdf/model/dataset.rb +1 -1
- data/lib/rdf/model/literal/temporal.rb +4 -4
- data/lib/rdf/model/literal/time.rb +4 -1
- data/lib/rdf/model/uri.rb +7 -0
- data/lib/rdf/nquads.rb +4 -1
- data/lib/rdf/ntriples/format.rb +4 -1
- data/lib/rdf/query/pattern.rb +2 -1
- data/lib/rdf/query/solution.rb +1 -2
- data/lib/rdf/query/solutions.rb +21 -0
- data/lib/rdf/query.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a11f72b598d08137366e7d9d0796dc7a0f6bf822484c6809a9e7905270b0b06
|
4
|
+
data.tar.gz: 67a7699bef7b127a327ba1dd3b5d53c7155325da9d8520ccf91fe51f4688cca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46f34b3fd322934aa324b3977714d7a456a4fef2d9aa28c340c484abf2b593ffe3b753b1d4a82e4aa9837321c5232d1d6fce1f46f114bad37dd3f4bf3e6a0b85
|
7
|
+
data.tar.gz: 2f07ef6e2c199240232d7185153b0b9fa41dc885bbc0fed2b616fa061440ccb6439eb993ab463f81e6535b946d4e8301d2b6a76fb397c3d5b9ee048fa58654e0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.8
|
data/lib/rdf/cli.rb
CHANGED
@@ -572,7 +572,8 @@ module RDF
|
|
572
572
|
# @param [Hash{Symbol => Object}] options already set
|
573
573
|
# @return [Array<String>] list of executable commands
|
574
574
|
# @overload commands(format: :json, **options)
|
575
|
-
#
|
575
|
+
# Returns commands as JSON, for API usage.
|
576
|
+
# @param [:json] format
|
576
577
|
# @param [Hash{Symbol => Object}] options already set
|
577
578
|
# @return [Array{Object}]
|
578
579
|
# Returns an array of commands including the command symbol
|
@@ -593,7 +594,7 @@ module RDF
|
|
593
594
|
# Subset commands based on filter options
|
594
595
|
cmds = COMMANDS.reject do |k, c|
|
595
596
|
c.fetch(:filter, {}).any? do |opt, val|
|
596
|
-
options[opt].to_s != val.to_s
|
597
|
+
options.merge(format: format)[opt].to_s != val.to_s
|
597
598
|
end
|
598
599
|
end
|
599
600
|
|
data/lib/rdf/format.rb
CHANGED
@@ -23,7 +23,9 @@ module RDF
|
|
23
23
|
#
|
24
24
|
# @example Defining a new RDF serialization format class
|
25
25
|
# class RDF::NTriples::Format < RDF::Format
|
26
|
-
# content_type 'application/n-triples',
|
26
|
+
# content_type 'application/n-triples',
|
27
|
+
# extension: :nt,
|
28
|
+
# uri: RDF::URI("http://www.w3.org/ns/formats/N-Triples")
|
27
29
|
# content_encoding 'utf-8'
|
28
30
|
#
|
29
31
|
# reader RDF::NTriples::Reader
|
@@ -222,6 +224,19 @@ module RDF
|
|
222
224
|
@@file_extensions
|
223
225
|
end
|
224
226
|
|
227
|
+
##
|
228
|
+
# Returns the unique URI for the format.
|
229
|
+
#
|
230
|
+
# @example retrieving a list of supported file format URIs
|
231
|
+
#
|
232
|
+
# RDF::Format.uris.keys
|
233
|
+
#
|
234
|
+
# @see https://www.w3.org/ns/formats/
|
235
|
+
# @return [Hash{Symbol => URI}]
|
236
|
+
def self.uris
|
237
|
+
@@uris
|
238
|
+
end
|
239
|
+
|
225
240
|
##
|
226
241
|
# Returns the set of format symbols for available RDF::Reader subclasses.
|
227
242
|
#
|
@@ -465,6 +480,7 @@ module RDF
|
|
465
480
|
# @option options [Array<String>] :aliases (nil)
|
466
481
|
# @option options [Symbol] :extension (nil)
|
467
482
|
# @option options [Array<Symbol>] :extensions (nil)
|
483
|
+
# @option options [URI] :uri (nil)
|
468
484
|
# @return [void]
|
469
485
|
#
|
470
486
|
# @overload content_type
|
@@ -504,6 +520,10 @@ module RDF
|
|
504
520
|
@@content_types[aa] << self unless @@content_types[aa].include?(self)
|
505
521
|
end
|
506
522
|
end
|
523
|
+
# URI identifying this format
|
524
|
+
if uri = options[:uri]
|
525
|
+
@@uris[RDF::URI(uri)] = self
|
526
|
+
end
|
507
527
|
end
|
508
528
|
end
|
509
529
|
|
@@ -517,7 +537,7 @@ module RDF
|
|
517
537
|
end
|
518
538
|
|
519
539
|
##
|
520
|
-
# Retrieves
|
540
|
+
# Retrieves file extensions for this RDF serialization format.
|
521
541
|
#
|
522
542
|
# The return is an array where the first element is the cannonical
|
523
543
|
# file extension for the format and following elements are alias file extensions.
|
@@ -527,6 +547,17 @@ module RDF
|
|
527
547
|
@@file_extensions.map {|ext, formats| ext if formats.include?(self)}.compact
|
528
548
|
end
|
529
549
|
|
550
|
+
##
|
551
|
+
# Retrieves any format URI defined for this format..
|
552
|
+
#
|
553
|
+
# @return [URI]
|
554
|
+
def self.uri
|
555
|
+
@@uris.invert[self]
|
556
|
+
end
|
557
|
+
class << self
|
558
|
+
alias_method :to_uri, :uri
|
559
|
+
end
|
560
|
+
|
530
561
|
protected
|
531
562
|
|
532
563
|
##
|
@@ -568,6 +599,7 @@ module RDF
|
|
568
599
|
@@readers = {} # @private
|
569
600
|
@@writers = {} # @private
|
570
601
|
@@subclasses = [] # @private
|
602
|
+
@@uris = {} # @private
|
571
603
|
|
572
604
|
##
|
573
605
|
# @private
|
data/lib/rdf/model/dataset.rb
CHANGED
@@ -128,7 +128,7 @@ module RDF; class Literal
|
|
128
128
|
#
|
129
129
|
# @return [String]
|
130
130
|
def to_s
|
131
|
-
@string
|
131
|
+
@string ||= (@object.strftime(self.class.const_get(:FORMAT)).sub('.000', '') + self.tz)
|
132
132
|
end
|
133
133
|
|
134
134
|
##
|
@@ -146,18 +146,18 @@ module RDF; class Literal
|
|
146
146
|
#
|
147
147
|
# Otherwise, the timezone is set based on the difference between the current timezone offset (if any) and `zone`.
|
148
148
|
#
|
149
|
-
# @param [String] zone (nil) In the form of {ZONE_GRAMMAR}.
|
149
|
+
# @param [DayTimeDuration, String] zone (nil) In the form of {ZONE_GRAMMAR}.
|
150
150
|
# @return [Temporal] `self`
|
151
151
|
# @raise [RangeError] if `zone < -14*60` or `zone > 14*60`
|
152
152
|
# @see https://www.w3.org/TR/xpath-functions/#func-adjust-dateTime-to-timezone
|
153
153
|
def adjust_to_timezone!(*args)
|
154
154
|
zone = args.empty? ? '+00:00' : args.first
|
155
|
-
if zone.
|
155
|
+
if zone.to_s.empty?
|
156
156
|
# Remove timezone component
|
157
157
|
@object = self.class.new(@object.strftime(self.class.const_get(:FORMAT))).object
|
158
158
|
@zone = nil
|
159
159
|
else
|
160
|
-
md = zone.match(ZONE_GRAMMAR)
|
160
|
+
md = zone.to_s.match(ZONE_GRAMMAR)
|
161
161
|
raise ArgumentError,
|
162
162
|
"expected #{zone.inspect} to be a xsd:dayTimeDuration or +/-HH:MM" unless md
|
163
163
|
|
@@ -39,7 +39,10 @@ module RDF; class Literal
|
|
39
39
|
end
|
40
40
|
# Normalize 24:00:00 to 00:00:00
|
41
41
|
hr, mi, se = tm.split(':')
|
42
|
-
|
42
|
+
if hr.to_i > 23
|
43
|
+
hr = "%.2i" % (hr.to_i % 24)
|
44
|
+
@string = nil
|
45
|
+
end
|
43
46
|
value = "#{hr}:#{mi}:#{se}"
|
44
47
|
# Normalize to 1972-12-31 dateTime base
|
45
48
|
::DateTime.parse("1972-12-31T#{hr}:#{mi}:#{se}#{@zone}")
|
data/lib/rdf/model/uri.rb
CHANGED
@@ -76,6 +76,7 @@ module RDF
|
|
76
76
|
IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
|
77
77
|
|
78
78
|
# Split an IRI into it's component parts
|
79
|
+
# scheme, authority, path, query, fragment
|
79
80
|
IRI_PARTS = /^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(\?[^#]*)?(#.*)?$/.freeze
|
80
81
|
|
81
82
|
# Remove dot expressions regular expressions
|
@@ -872,6 +873,12 @@ module RDF
|
|
872
873
|
parts = {}
|
873
874
|
if matchdata = IRI_PARTS.match(value)
|
874
875
|
scheme, authority, path, query, fragment = matchdata[1..-1]
|
876
|
+
|
877
|
+
if Gem.win_platform? && scheme && !authority && scheme.match?(/^[a-zA-Z]$/)
|
878
|
+
# A drive letter, not a scheme
|
879
|
+
scheme, path = nil, "#{scheme}:#{path}"
|
880
|
+
end
|
881
|
+
|
875
882
|
userinfo, hostport = authority.to_s.split('@', 2)
|
876
883
|
hostport, userinfo = userinfo, nil unless hostport
|
877
884
|
user, password = userinfo.to_s.split(':', 2)
|
data/lib/rdf/nquads.rb
CHANGED
@@ -20,7 +20,10 @@ module RDF
|
|
20
20
|
# @see http://www.w3.org/TR/n-quads/
|
21
21
|
# @since 0.4.0
|
22
22
|
class Format < RDF::Format
|
23
|
-
content_type 'application/n-quads',
|
23
|
+
content_type 'application/n-quads',
|
24
|
+
extension: :nq,
|
25
|
+
alias: 'text/x-nquads;q=0.2',
|
26
|
+
uri: RDF::URI("http://www.w3.org/ns/formats/N-Quads")
|
24
27
|
content_encoding 'utf-8'
|
25
28
|
|
26
29
|
reader { RDF::NQuads::Reader }
|
data/lib/rdf/ntriples/format.rb
CHANGED
@@ -16,7 +16,10 @@ module RDF::NTriples
|
|
16
16
|
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
|
17
17
|
# @see http://www.w3.org/TR/n-triples/
|
18
18
|
class Format < RDF::Format
|
19
|
-
content_type 'application/n-triples',
|
19
|
+
content_type 'application/n-triples',
|
20
|
+
extension: :nt,
|
21
|
+
alias: 'text/plain;q=0.2',
|
22
|
+
uri: RDF::URI("http://www.w3.org/ns/formats/N-Triples")
|
20
23
|
content_encoding 'utf-8'
|
21
24
|
|
22
25
|
reader { RDF::NTriples::Reader }
|
data/lib/rdf/query/pattern.rb
CHANGED
@@ -160,7 +160,7 @@ module RDF; class Query
|
|
160
160
|
#
|
161
161
|
# @param [RDF::Queryable] queryable
|
162
162
|
# the graph or repository to query
|
163
|
-
# @param [Hash{Symbol => RDF::Term}] bindings
|
163
|
+
# @param [Hash{Symbol => RDF::Term}, RDF::Query::Solution] bindings
|
164
164
|
# optional variable bindings to use
|
165
165
|
# @yield [statement]
|
166
166
|
# each matching statement
|
@@ -171,6 +171,7 @@ module RDF; class Query
|
|
171
171
|
# @see RDF::Queryable#query
|
172
172
|
# @since 0.3.0
|
173
173
|
def execute(queryable, bindings = {}, &block)
|
174
|
+
bindings = bindings.to_h if bindings.is_a?(Solution)
|
174
175
|
query = {
|
175
176
|
subject: subject.is_a?(Variable) && bindings[subject.to_sym] ? bindings[subject.to_sym] : subject,
|
176
177
|
predicate: predicate.is_a?(Variable) && bindings[predicate.to_sym] ? bindings[predicate.to_sym] : predicate,
|
data/lib/rdf/query/solution.rb
CHANGED
@@ -317,13 +317,12 @@ class RDF::Query
|
|
317
317
|
def hash
|
318
318
|
@bindings.hash
|
319
319
|
end
|
320
|
-
|
320
|
+
|
321
321
|
##
|
322
322
|
# Equivalence of solution
|
323
323
|
def eql?(other)
|
324
324
|
other.is_a?(Solution) && @bindings.eql?(other.bindings)
|
325
325
|
end
|
326
|
-
alias_method :==, :eql?
|
327
326
|
|
328
327
|
##
|
329
328
|
# Equals of solution
|
data/lib/rdf/query/solutions.rb
CHANGED
@@ -77,6 +77,15 @@ module RDF; class Query
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
##
|
81
|
+
# Sets variable names used in these solutions. If not set, the default is determined by the variables used in each solution.
|
82
|
+
#
|
83
|
+
# @param [Array<Symbol, RDF::Query::Variable>] vars
|
84
|
+
# @return [Array<Symbol>]
|
85
|
+
def variable_names=(vars)
|
86
|
+
@variable_names = vars.map(&:to_sym)
|
87
|
+
end
|
88
|
+
|
80
89
|
##
|
81
90
|
# @overload variable?
|
82
91
|
# Returns `false`.
|
@@ -294,5 +303,17 @@ module RDF; class Query
|
|
294
303
|
self
|
295
304
|
end
|
296
305
|
alias_method :limit!, :limit
|
306
|
+
|
307
|
+
##
|
308
|
+
# Equivalence of solution
|
309
|
+
def eql?(other)
|
310
|
+
super && (!other.respond_to?(:variable_names) || variable_names.eql?(other.variable_names))
|
311
|
+
end
|
312
|
+
|
313
|
+
##
|
314
|
+
# Equals of solution
|
315
|
+
def ==(other)
|
316
|
+
super && (!other.respond_to?(:variable_names) || variable_names.eql?(other.variable_names))
|
317
|
+
end
|
297
318
|
end # Solutions
|
298
319
|
end; end # RDF::Query
|
data/lib/rdf/query.rb
CHANGED
@@ -294,7 +294,7 @@ module RDF
|
|
294
294
|
# Alias for `:graph_name`.
|
295
295
|
# @param [Hash{Symbol => Object}] options
|
296
296
|
# any additional keyword options
|
297
|
-
# @option options [Hash{Symbol => RDF::Term}] bindings
|
297
|
+
# @option options [Hash{Symbol => RDF::Term}, RDF::Query::Solution] bindings
|
298
298
|
# optional variable bindings to use
|
299
299
|
# @option options [Boolean] :optimize
|
300
300
|
# Optimize query before execution.
|
@@ -313,6 +313,7 @@ module RDF
|
|
313
313
|
# Otherwise, a quick empty solution simplifies the logic below; no special case for
|
314
314
|
# the first pattern
|
315
315
|
@solutions = Query::Solutions(solutions)
|
316
|
+
bindings = bindings.to_h if bindings.is_a?(Solution)
|
316
317
|
|
317
318
|
# If there are no patterns, just return the empty solution
|
318
319
|
if empty?
|
@@ -341,7 +342,7 @@ module RDF
|
|
341
342
|
bindings.each_key do |variable|
|
342
343
|
if pattern.variables.include?(variable)
|
343
344
|
unbound_solutions, old_solutions = old_solutions, Query::Solutions()
|
344
|
-
bindings[variable].each do |binding|
|
345
|
+
Array(bindings[variable]).each do |binding|
|
345
346
|
unbound_solutions.each do |solution|
|
346
347
|
old_solutions << solution.merge(variable => binding)
|
347
348
|
end
|
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.8
|
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: 2022-
|
13
|
+
date: 2022-05-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|