rdf 3.2.8 → 3.2.9

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: 73bbb2bcc84c974f9ecfe2b1f9a41cf445273e76cfdbd6fd84b6141790b85092
4
+ data.tar.gz: 5a339b4166238e83c491555bc084e9132491da17c54234252b4bc60b5b8451db
5
5
  SHA512:
6
- metadata.gz: 46f34b3fd322934aa324b3977714d7a456a4fef2d9aa28c340c484abf2b593ffe3b753b1d4a82e4aa9837321c5232d1d6fce1f46f114bad37dd3f4bf3e6a0b85
7
- data.tar.gz: 2f07ef6e2c199240232d7185153b0b9fa41dc885bbc0fed2b616fa061440ccb6439eb993ab463f81e6535b946d4e8301d2b6a76fb397c3d5b9ee048fa58654e0
6
+ metadata.gz: d083cfe87a7894a616966a8d0bdc9a4d0b11814fde48a95bf94f83cc0fcc6ffd939b0ddd765079e0ca2514fbc7df182bebea0870d4a7d8f2817bba72cb7c4bab
7
+ data.tar.gz: ce59b7a5f8340f9fee88ad374c1452df356312ad3621e64e678054508616b32648e7cb49fc9fd42563cc8c8079d99500d9c779a9dcf1924e0804ca97e17ea69e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.8
1
+ 3.2.9
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
 
@@ -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
  ##
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.9
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: 2022-08-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: link_header