rdf 3.2.8 → 3.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a11f72b598d08137366e7d9d0796dc7a0f6bf822484c6809a9e7905270b0b06
4
- data.tar.gz: 67a7699bef7b127a327ba1dd3b5d53c7155325da9d8520ccf91fe51f4688cca3
3
+ metadata.gz: 948292ebb4f6e10c59b67e873d2d14884c53c5fab199e901e4e4dadf768f379f
4
+ data.tar.gz: 8731942201a15bcef71284fe0a79a3bc9a97b878ef2c53b757869cadefdadf54
5
5
  SHA512:
6
- metadata.gz: 46f34b3fd322934aa324b3977714d7a456a4fef2d9aa28c340c484abf2b593ffe3b753b1d4a82e4aa9837321c5232d1d6fce1f46f114bad37dd3f4bf3e6a0b85
7
- data.tar.gz: 2f07ef6e2c199240232d7185153b0b9fa41dc885bbc0fed2b616fa061440ccb6439eb993ab463f81e6535b946d4e8301d2b6a76fb397c3d5b9ee048fa58654e0
6
+ metadata.gz: 41d8fca7513dc56c6447b3b40d995b04f407e986ffc4e1a7fc86de7632ca026b6effdb8e7d3d815ba7ddb27c44e6af53a08bbde43390a065170e9a58446231d8
7
+ data.tar.gz: 5c9895f52363ffee6bc408d5e476a9a345d7aec62ec8594a8ca49f5c3ef9016f307741c0ef8b537d6fc49f714a25d2a4b0bee64631951191c750ef53809533c4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.8
1
+ 3.2.10
data/lib/rdf/cli.rb CHANGED
@@ -25,6 +25,7 @@ rescue LoadError
25
25
  rdf/xsd
26
26
  shacl
27
27
  shex
28
+ yaml_ld
28
29
  ).each do |ser|
29
30
  begin
30
31
  require ser
@@ -177,7 +178,10 @@ module RDF
177
178
  # * `parse` Boolean value to determine if input files should automatically be parsed into `repository`.
178
179
  # * `help` used for the CLI help output.
179
180
  # * `lambda` code run to execute command.
180
- # * `filter` Option values that must match for command to be used
181
+ # * `filter` value is a Hash whose keys are matched against selected command options. All specified `key/value` pairs are compared against the equivalent key in the current invocation.
182
+ # If an Array, option value (as a string) must match any value of the array (as a string)
183
+ # If a Proc, it is passed the option value and must return `true`.
184
+ # Otherwise, the option value (as a string) must equal the `value` (as a string).
181
185
  # * `control` Used to indicate how (if) command is displayed
182
186
  # * `repository` Use this repository, if set
183
187
  # * `options` an optional array of `RDF::CLI::Option` describing command-specific options.
@@ -505,9 +509,22 @@ module RDF
505
509
  # Make sure any selected command isn't filtered out
506
510
  cmds.each do |c|
507
511
  COMMANDS[c.to_sym].fetch(:filter, {}).each do |opt, val|
508
- if options[opt].to_s != val.to_s
509
- usage(option_parser, banner: "Command #{c.inspect} requires #{opt}: #{val}, not #{options.fetch(opt, 'null')}")
510
- raise ArgumentError, "Incompatible command #{c} used with option #{opt}=#{options[opt]}"
512
+ case val
513
+ when Array
514
+ unless val.map(&:to_s).include?(options[opt].to_s)
515
+ usage(option_parser, banner: "Command #{c.inspect} requires #{opt} in #{val.map(&:to_s).inspect}, not #{options.fetch(opt, 'null')}")
516
+ raise ArgumentError, "Incompatible command #{c} used with option #{opt}=#{options[opt]}"
517
+ end
518
+ when Proc
519
+ unless val.call(options[opt])
520
+ usage(option_parser, banner: "Command #{c.inspect} #{opt} inconsistent with #{options.fetch(opt, 'null')}")
521
+ raise ArgumentError, "Incompatible command #{c} used with option #{opt}=#{options[opt]}"
522
+ end
523
+ else
524
+ unless val.to_s == options[opt].to_s
525
+ usage(option_parser, banner: "Command #{c.inspect} requires compatible value for #{opt}, not #{options.fetch(opt, 'null')}")
526
+ raise ArgumentError, "Incompatible command #{c} used with option #{opt}=#{options[opt]}"
527
+ end
511
528
  end
512
529
  end
513
530
 
@@ -594,7 +611,14 @@ module RDF
594
611
  # Subset commands based on filter options
595
612
  cmds = COMMANDS.reject do |k, c|
596
613
  c.fetch(:filter, {}).any? do |opt, val|
597
- options.merge(format: format)[opt].to_s != val.to_s
614
+ case val
615
+ when Array
616
+ !val.map(&:to_s).include?(options[opt].to_s)
617
+ when Proc
618
+ !val.call(options[opt])
619
+ else
620
+ val.to_s != options[opt].to_s
621
+ end
598
622
  end
599
623
  end
600
624
 
@@ -41,7 +41,7 @@ module RDF
41
41
  def load(url, graph_name: nil, **options)
42
42
  raise TypeError.new("#{self} is immutable") if immutable?
43
43
 
44
- Reader.open(url, base_uri: url, **options) do |reader|
44
+ Reader.open(url, **options.merge(base_uri: url)) do |reader|
45
45
  if graph_name
46
46
  statements = []
47
47
  reader.each_statement do |statement|
@@ -3,10 +3,11 @@ module RDF; class Literal
3
3
  # A date literal.
4
4
  #
5
5
  # @see http://www.w3.org/TR/xmlschema11-2/#date
6
+ # @see https://www.w3.org/TR/xmlschema11-2/#rf-lexicalMappings-datetime
6
7
  # @since 0.2.1
7
8
  class Date < Temporal
8
9
  DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#date")
9
- GRAMMAR = %r(\A(-?\d{4}-\d{2}-\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|GMT|Z)?\Z).freeze
10
+ GRAMMAR = %r(\A(#{YEARFRAG}-#{MONTHFRAG}-#{DAYFRAG})(#{TZFRAG})?\z).freeze
10
11
  FORMAT = '%Y-%m-%d'.freeze
11
12
 
12
13
  ##
@@ -3,10 +3,22 @@ module RDF; class Literal
3
3
  # A date/time literal.
4
4
  #
5
5
  # @see http://www.w3.org/TR/xmlschema11-2/#dateTime
6
+ # @see https://www.w3.org/TR/xmlschema11-2/#rf-lexicalMappings-datetime
6
7
  # @since 0.2.1
7
8
  class DateTime < Temporal
8
9
  DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#dateTime")
9
- GRAMMAR = %r(\A(-?(?:\d{4}|[1-9]\d{4,})-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?)((?:[\+\-]\d{2}:\d{2})|UTC|GMT|Z)?\Z).freeze
10
+ GRAMMAR = %r(\A
11
+ (#{YEARFRAG}
12
+ -#{MONTHFRAG}
13
+ -#{DAYFRAG}
14
+ T
15
+ (?:
16
+ (?:
17
+ #{HOURFRAG}
18
+ :#{MINUTEFRAG}
19
+ :#{SECONDFRAG})
20
+ | #{EODFRAG}))
21
+ (#{TZFRAG})?\z)x.freeze
10
22
  FORMAT = '%Y-%m-%dT%H:%M:%S.%L'.freeze
11
23
 
12
24
  ##
@@ -10,6 +10,15 @@ module RDF; class Literal
10
10
  |(?:(?<si>-)?PT(?<hr>\d{1,2})H(?:(?<mi>\d{1,2})M)?)
11
11
  \z)x.freeze
12
12
 
13
+ YEARFRAG = %r(-?(?:(?:[1-9]\d{3,})|(?:0\d{3})))
14
+ MONTHFRAG = %r((?:(?:0[1-9])|(?:1[0-2])))
15
+ DAYFRAG = %r((?:(?:0[1-9])|(?:[12]\d)|(?:3[01])))
16
+ HOURFRAG = %r((?:[01]\d)|(?:2[0-3]))
17
+ MINUTEFRAG = %r([0-5]\d)
18
+ SECONDFRAG = %r([0-5]\d(?:\.\d+)?)
19
+ EODFRAG = %r(24:00:00(?:\.0+)?)
20
+ TZFRAG = %r((?:[\+\-]\d{2}:\d{2})|UTC|GMT|Z)
21
+
13
22
  ##
14
23
  # Compares this literal to `other` for sorting purposes.
15
24
  #
@@ -8,10 +8,11 @@ module RDF; class Literal
8
8
  # following time zone indicator.
9
9
  #
10
10
  # @see http://www.w3.org/TR/xmlschema11-2/#time
11
+ # @see https://www.w3.org/TR/xmlschema11-2/#rf-lexicalMappings-datetime
11
12
  # @since 0.2.1
12
13
  class Time < Temporal
13
14
  DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#time")
14
- GRAMMAR = %r(\A(\d{2}:\d{2}:\d{2}(?:\.\d+)?)((?:[\+\-]\d{2}:\d{2})|UTC|GMT|Z)?\Z).freeze
15
+ GRAMMAR = %r(\A((?:#{HOURFRAG}:#{MINUTEFRAG}:#{SECONDFRAG})|#{EODFRAG})(#{TZFRAG})?\z).freeze
15
16
  FORMAT = '%H:%M:%S.%L'.freeze
16
17
 
17
18
  ##
@@ -125,16 +125,18 @@ module RDF::NTriples
125
125
  # @see http://www.w3.org/TR/n-triples/
126
126
  def self.escape_ascii(u, encoding)
127
127
  case (u = u.ord)
128
- when (0x00..0x07) then escape_utf16(u)
129
- when (0x0A) then "\\n"
130
- when (0x0D) then "\\r"
131
- when (0x0E..0x1F) then escape_utf16(u)
132
- when (0x22) then "\\\""
133
- when (0x5C) then "\\\\"
134
- when (0x7F) then escape_utf16(u)
135
- when (0x00..0x7F) then u.chr
136
- else
137
- raise ArgumentError.new("expected an ASCII character in (0x00..0x7F), but got 0x#{u.to_s(16)}")
128
+ when (0x08) then "\\b"
129
+ when (0x09) then "\\t"
130
+ when (0x0A) then "\\n"
131
+ when (0x0C) then "\\f"
132
+ when (0x0D) then "\\r"
133
+ when (0x22) then "\\\""
134
+ when (0x5C) then "\\\\"
135
+ when (0x00..0x1F) then escape_utf16(u)
136
+ when (0x7F) then escape_utf16(u)
137
+ when (0x20..0x7E) then u.chr
138
+ else
139
+ raise ArgumentError.new("expected an ASCII character in (0x00..0x7F), but got 0x#{u.to_s(16)}")
138
140
  end
139
141
  end
140
142
 
@@ -85,7 +85,7 @@ module RDF; module Util
85
85
  id = value.__id__
86
86
  @cache[key] = id
87
87
  @index[id] = key
88
- ObjectSpace.define_finalizer(value, proc {|id| @cache.delete(@index.delete(id))})
88
+ ObjectSpace.define_finalizer(value, finalizer_proc)
89
89
  end
90
90
  value
91
91
  end
@@ -100,6 +100,12 @@ module RDF; module Util
100
100
  @cache.delete(key)
101
101
  @index.delete(id) if id
102
102
  end
103
+
104
+ private
105
+
106
+ def finalizer_proc
107
+ proc { |id| @cache.delete(@index.delete(id)) }
108
+ end
103
109
  end # ObjectSpaceCache
104
110
 
105
111
  ##
@@ -181,10 +181,10 @@ module RDF; module Util
181
181
  end
182
182
 
183
183
  ##
184
- # @overload log_depth(options, &block)
184
+ # @overload log_depth(depth: 1, **options, &block)
185
185
  # Increase depth around a method invocation
186
+ # @param [Integer] :depth Additional recursion depth
186
187
  # @param [Hash{Symbol}] options (@options || {})
187
- # @option options [Integer] :depth Additional recursion depth
188
188
  # @option options [Logger, #<<] :logger
189
189
  # @yield
190
190
  # Yields with no arguments
@@ -194,8 +194,8 @@ module RDF; module Util
194
194
  # @overload log_depth
195
195
  # # Return the current log depth
196
196
  # @return [Integer]
197
- def log_depth(**options, &block)
198
- self.logger(**options).log_depth(&block)
197
+ def log_depth(depth: 1, **options, &block)
198
+ self.logger(**options).log_depth(depth: depth, &block)
199
199
  end
200
200
 
201
201
  private
@@ -244,7 +244,7 @@ module RDF; module Util
244
244
  end
245
245
 
246
246
  ##
247
- # @overload log_depth(options, &block)
247
+ # @overload log_depth(depth: 1, **options, &block)
248
248
  # Increase depth around a method invocation
249
249
  # @param [Integer] depth (1) recursion depth
250
250
  # @param [Hash{Symbol}] options (@options || {})
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.8
4
+ version: 3.2.10
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-05-28 00:00:00.000000000 Z
13
+ date: 2023-04-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: link_header
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.10'
117
+ version: '3.12'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.10'
124
+ version: '3.12'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec-its
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '3.14'
145
+ version: '3.18'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '3.14'
152
+ version: '3.18'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '1.8'
173
+ version: '1.10'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.8'
180
+ version: '1.10'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: faraday_middleware
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -295,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
295
295
  - !ruby/object:Gem::Version
296
296
  version: '0'
297
297
  requirements: []
298
- rubygems_version: 3.3.3
298
+ rubygems_version: 3.4.6
299
299
  signing_key:
300
300
  specification_version: 4
301
301
  summary: A Ruby library for working with Resource Description Framework (RDF) data.