rdf 3.0.2 → 3.0.3
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 +4 -4
- data/VERSION +1 -1
- data/lib/rdf/cli.rb +8 -2
- data/lib/rdf/model/literal.rb +9 -8
- data/lib/rdf/model/literal/boolean.rb +1 -1
- data/lib/rdf/model/literal/date.rb +1 -1
- data/lib/rdf/model/literal/datetime.rb +3 -3
- data/lib/rdf/model/literal/decimal.rb +1 -1
- data/lib/rdf/model/literal/double.rb +1 -1
- data/lib/rdf/model/literal/integer.rb +1 -1
- data/lib/rdf/model/literal/time.rb +1 -1
- data/lib/rdf/model/literal/token.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbddc1758793b9251e0f2e6570a5a222bf32aa39fcc2e73d1d454b84af90062a
|
4
|
+
data.tar.gz: 4ad7cca943663997855d26d6a741138c0bad7ad3258d8a8fa081e701d5657785
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 587ff46cfde46b088a9b5994a350bffffc189c96e26a6c9c426ae204b731872858c6b80379a36b3b17c69192b47b81f67b005bd728fd858a0db385f44e70e09e
|
7
|
+
data.tar.gz: 0a048848ce6db55add239882c35a2e0df981ec9ea0afbd3070f1cde536168382d00177a6d2467e196d69ee14a816367c29133263d39c921b5876af63b4dd1d19
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.3
|
data/lib/rdf/cli.rb
CHANGED
@@ -92,6 +92,10 @@ module RDF
|
|
92
92
|
# @return [String]
|
93
93
|
attr_reader :description
|
94
94
|
|
95
|
+
# Default value for this option
|
96
|
+
# @return [Object]
|
97
|
+
attr_reader :default
|
98
|
+
|
95
99
|
# Potential values (for select or radio) or Ruby datatype
|
96
100
|
# @return [Class, Array<String>]
|
97
101
|
attr_reader :datatype
|
@@ -110,6 +114,7 @@ module RDF
|
|
110
114
|
# @param [Symbol] symbol
|
111
115
|
# @param [Array<String>] on
|
112
116
|
# @param [String] datatype
|
117
|
+
# @param [Object] default
|
113
118
|
# @param [String] control
|
114
119
|
# @param [String] description
|
115
120
|
# @param [[:optional, :disabled, :removed, :required]] use
|
@@ -118,10 +123,10 @@ module RDF
|
|
118
123
|
# @yieldparam [OptionParser] options (nil) optional OptionParser
|
119
124
|
# @yieldreturn [Object] a possibly modified input value
|
120
125
|
def initialize(symbol: nil, on: nil, datatype: nil, control: nil,
|
121
|
-
description: nil, use: :optional, **options, &block)
|
126
|
+
description: nil, use: :optional, default: nil, **options, &block)
|
122
127
|
raise ArgumentError, "symbol is a required argument" unless symbol
|
123
128
|
raise ArgumentError, "on is a required argument" unless on
|
124
|
-
@symbol, @on, @datatype, @control, @description, @use, @callback = symbol.to_sym, Array(on), datatype, control, description, use, block
|
129
|
+
@symbol, @on, @datatype, @control, @description, @use, @default, @callback = symbol.to_sym, Array(on), datatype, control, description, use, default, block
|
125
130
|
end
|
126
131
|
|
127
132
|
def call(arg, options = {})
|
@@ -142,6 +147,7 @@ module RDF
|
|
142
147
|
{
|
143
148
|
symbol: symbol,
|
144
149
|
datatype: (datatype.is_a?(Class) ? datatype.name : datatype),
|
150
|
+
default: default,
|
145
151
|
control: control,
|
146
152
|
description: description,
|
147
153
|
use: use
|
data/lib/rdf/model/literal.rb
CHANGED
@@ -170,8 +170,7 @@ module RDF
|
|
170
170
|
@language = language.to_s.downcase.to_sym if language
|
171
171
|
@datatype = RDF::URI(datatype).freeze if datatype
|
172
172
|
@datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE)
|
173
|
-
@datatype ||= @language ? RDF.langString : RDF::
|
174
|
-
raise ArgumentError, "datatype of rdf:langString requires a language" if !@language && @datatype == RDF::langString
|
173
|
+
@datatype ||= @language ? RDF.langString : RDF::URI("http://www.w3.org/2001/XMLSchema#string")
|
175
174
|
end
|
176
175
|
|
177
176
|
##
|
@@ -226,8 +225,8 @@ module RDF
|
|
226
225
|
# * The arguments are plain literals with identical language tags
|
227
226
|
# * The first argument is a plain literal with language tag and the second argument is a simple literal or literal typed as xsd:string
|
228
227
|
has_language? ?
|
229
|
-
(language == other.language || other.datatype == RDF::
|
230
|
-
other.datatype == RDF::
|
228
|
+
(language == other.language || other.datatype == RDF::URI("http://www.w3.org/2001/XMLSchema#string")) :
|
229
|
+
other.datatype == RDF::URI("http://www.w3.org/2001/XMLSchema#string")
|
231
230
|
end
|
232
231
|
|
233
232
|
##
|
@@ -317,7 +316,7 @@ module RDF
|
|
317
316
|
# @return [Boolean] `true` or `false`
|
318
317
|
# @see http://www.w3.org/TR/rdf-concepts/#dfn-plain-literal
|
319
318
|
def plain?
|
320
|
-
[RDF.langString, RDF::
|
319
|
+
[RDF.langString, RDF::URI("http://www.w3.org/2001/XMLSchema#string")].include?(datatype)
|
321
320
|
end
|
322
321
|
|
323
322
|
##
|
@@ -327,7 +326,7 @@ module RDF
|
|
327
326
|
# @return [Boolean] `true` or `false`
|
328
327
|
# @see http://www.w3.org/TR/sparql11-query/#simple_literal
|
329
328
|
def simple?
|
330
|
-
datatype == RDF::
|
329
|
+
datatype == RDF::URI("http://www.w3.org/2001/XMLSchema#string")
|
331
330
|
end
|
332
331
|
|
333
332
|
##
|
@@ -361,6 +360,8 @@ module RDF
|
|
361
360
|
# @return [Boolean] `true` or `false`
|
362
361
|
# @since 0.2.1
|
363
362
|
def valid?
|
363
|
+
return false if language? && language.to_s !~ /^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/
|
364
|
+
return false if datatype? && datatype.invalid?
|
364
365
|
grammar = self.class.const_get(:GRAMMAR) rescue nil
|
365
366
|
grammar.nil? || !!(value =~ grammar)
|
366
367
|
end
|
@@ -487,7 +488,7 @@ module RDF
|
|
487
488
|
def method_missing(name, *args)
|
488
489
|
case name
|
489
490
|
when :to_str
|
490
|
-
return to_s if @datatype == RDF.langString || @datatype == RDF::
|
491
|
+
return to_s if @datatype == RDF.langString || @datatype == RDF::URI("http://www.w3.org/2001/XMLSchema#string")
|
491
492
|
end
|
492
493
|
super
|
493
494
|
end
|
@@ -495,7 +496,7 @@ module RDF
|
|
495
496
|
def respond_to_missing?(name, include_private = false)
|
496
497
|
case name
|
497
498
|
when :to_str
|
498
|
-
return true if @datatype == RDF.langString || @datatype == RDF::
|
499
|
+
return true if @datatype == RDF.langString || @datatype == RDF::URI("http://www.w3.org/2001/XMLSchema#string")
|
499
500
|
end
|
500
501
|
super
|
501
502
|
end
|
@@ -5,7 +5,7 @@ module RDF; class Literal
|
|
5
5
|
# @see http://www.w3.org/TR/xmlschema11-2/#boolean
|
6
6
|
# @since 0.2.1
|
7
7
|
class Boolean < Literal
|
8
|
-
DATATYPE = RDF::
|
8
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#boolean")
|
9
9
|
GRAMMAR = /^(true|false|1|0)$/.freeze
|
10
10
|
TRUES = %w(true 1).freeze
|
11
11
|
FALSES = %w(false 0).freeze
|
@@ -5,7 +5,7 @@ module RDF; class Literal
|
|
5
5
|
# @see http://www.w3.org/TR/xmlschema11-2/#date
|
6
6
|
# @since 0.2.1
|
7
7
|
class Date < Literal
|
8
|
-
DATATYPE = RDF::
|
8
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#date")
|
9
9
|
GRAMMAR = %r(\A(-?\d{4}-\d{2}-\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|GMT|Z)?\Z).freeze
|
10
10
|
FORMAT = '%Y-%m-%d'.freeze
|
11
11
|
|
@@ -5,7 +5,7 @@ module RDF; class Literal
|
|
5
5
|
# @see http://www.w3.org/TR/xmlschema11-2/#dateTime#boolean
|
6
6
|
# @since 0.2.1
|
7
7
|
class DateTime < Literal
|
8
|
-
DATATYPE = RDF::
|
8
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#dateTime")
|
9
9
|
GRAMMAR = %r(\A(-?\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?)((?:[\+\-]\d{2}:\d{2})|UTC|GMT|Z)?\Z).freeze
|
10
10
|
FORMAT = '%Y-%m-%dT%H:%M:%S%:z'.freeze
|
11
11
|
|
@@ -57,14 +57,14 @@ module RDF; class Literal
|
|
57
57
|
# @return [RDF::Literal]
|
58
58
|
def timezone
|
59
59
|
if tz == 'Z'
|
60
|
-
RDF::Literal("PT0S", datatype: RDF::
|
60
|
+
RDF::Literal("PT0S", datatype: RDF::URI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))
|
61
61
|
elsif md = tz.to_s.match(/^([+-])?(\d+):(\d+)?$/)
|
62
62
|
plus_minus, hour, min = md[1,3]
|
63
63
|
plus_minus = nil unless plus_minus == "-"
|
64
64
|
hour = hour.to_i
|
65
65
|
min = min.to_i
|
66
66
|
res = "#{plus_minus}PT#{hour}H#{"#{min}M" if min > 0}"
|
67
|
-
RDF::Literal(res, datatype: RDF::
|
67
|
+
RDF::Literal(res, datatype: RDF::URI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -11,7 +11,7 @@ module RDF; class Literal
|
|
11
11
|
# @see http://www.w3.org/TR/xmlschema11-2/#decimal
|
12
12
|
# @since 0.2.1
|
13
13
|
class Decimal < Numeric
|
14
|
-
DATATYPE = RDF::
|
14
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#decimal")
|
15
15
|
GRAMMAR = /^[\+\-]?\d+(\.\d*)?$/.freeze
|
16
16
|
|
17
17
|
##
|
@@ -11,7 +11,7 @@ module RDF; class Literal
|
|
11
11
|
# @see http://www.w3.org/TR/xmlschema11-2/#double
|
12
12
|
# @since 0.2.1
|
13
13
|
class Double < Numeric
|
14
|
-
DATATYPE = RDF::
|
14
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#double")
|
15
15
|
GRAMMAR = /^(?:NaN|\-?INF|[+\-]?(?:\d+(:?\.\d*)?|\.\d+)(?:[eE][\+\-]?\d+)?)$/.freeze
|
16
16
|
|
17
17
|
##
|
@@ -12,7 +12,7 @@ module RDF; class Literal
|
|
12
12
|
# @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#integer
|
13
13
|
# @since 0.2.1
|
14
14
|
class Integer < Decimal
|
15
|
-
DATATYPE = RDF::
|
15
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#integer")
|
16
16
|
GRAMMAR = /^[\+\-]?\d+$/.freeze
|
17
17
|
|
18
18
|
##
|
@@ -10,7 +10,7 @@ module RDF; class Literal
|
|
10
10
|
# @see http://www.w3.org/TR/xmlschema11-2/#time
|
11
11
|
# @since 0.2.1
|
12
12
|
class Time < Literal
|
13
|
-
DATATYPE = RDF::
|
13
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#time")
|
14
14
|
GRAMMAR = %r(\A(\d{2}:\d{2}:\d{2}(?:\.\d+)?)((?:[\+\-]\d{2}:\d{2})|UTC|GMT|Z)?\Z).freeze
|
15
15
|
FORMAT = '%H:%M:%S%:z'.freeze
|
16
16
|
|
@@ -5,7 +5,7 @@ module RDF; class Literal
|
|
5
5
|
# @see http://www.w3.org/TR/xmlschema11-2/#token
|
6
6
|
# @since 0.2.3
|
7
7
|
class Token < Literal
|
8
|
-
DATATYPE = RDF::
|
8
|
+
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#token")
|
9
9
|
GRAMMAR = /\A[^\x0D\x0A\x09]+\z/i.freeze # FIXME
|
10
10
|
|
11
11
|
##
|
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.0.
|
4
|
+
version: 3.0.3
|
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: 2018-
|
13
|
+
date: 2018-09-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: link_header
|
@@ -297,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
297
|
version: '0'
|
298
298
|
requirements: []
|
299
299
|
rubyforge_project:
|
300
|
-
rubygems_version: 2.7.
|
300
|
+
rubygems_version: 2.7.6
|
301
301
|
signing_key:
|
302
302
|
specification_version: 4
|
303
303
|
summary: A Ruby library for working with Resource Description Framework (RDF) data.
|