rdf-xsd 3.1.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dad8d58125296d377e9e0e78ca58a54ec22678a9ee5606d0c114e7692c81a49
4
- data.tar.gz: 50637e4eefc2c785c56652982e9f306c1d053f98e5bc17da7a9311689ae21e18
3
+ metadata.gz: 8a344fd7adc4bd8ca84e939dcf26daf656c19e5f60d04b2026ed18393b07a6d9
4
+ data.tar.gz: fd035fb32fb4719ebcc72f7a133d64c690d20c9f8a8276b18d801625317119b2
5
5
  SHA512:
6
- metadata.gz: cab209b7ff9b73948805c5836ab8fc38054583bc211ef4afc412403d55889f4805d772aa6b24ac56ecf77bd045f6156a79e3c54a7cd48e239a2e2d47211270b8
7
- data.tar.gz: 719d3097a42d5c0a2194e84c28c69a266a1243e4be372116622ac1c07ff55cd94c96aa4dcfc7f66a7dee3f8cbd95cdef8d095e46bc48b3d826a593050d06523f
6
+ metadata.gz: 303a3003b754327c637caf02ca34c27fc52e50b25302dee1f2cf0d2f820d61e431814c92a5e6af4b9af8511de699f5f841c789a1719dbbe0f36a1a3c96db29ce
7
+ data.tar.gz: 63cf8178d9118864fc09b26539e95a33062309e10de38eed5b1f0c769d7bd6be47eca8a51d77e77d2faf2545bcd7e032f020a6e326400c804941d0ebc7b0f34f
data/README.md CHANGED
@@ -1,20 +1,20 @@
1
- # Extended XSD Datatypes for RDF.rb
1
+ # Extended XSD Datatypes and XQuery functions for RDF.rb
2
2
 
3
- This gem adds additional RDF::Literal subclasses for extended [XSD datatypes][]
3
+ This gem adds additional RDF::Literal subclasses for extended [XSD datatypes][] along with methods implementing many [XPath and XQuery Functions][]
4
4
 
5
- * <http://github.com/ruby-rdf/rdf-xsd>
6
-
7
- [![Gem Version](https://badge.fury.io/rb/rdf-xsd.png)](http://badge.fury.io/rb/rdf-xsd)
8
- [![Build Status](https://travis-ci.org/ruby-rdf/rdf-xsd.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-xsd)
5
+ [![Gem Version](https://badge.fury.io/rb/rdf-xsd.png)](https://badge.fury.io/rb/rdf-xsd)
6
+ [![Build Status](https://github.com/ruby-rdf/rdf-xsd/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf-xsd/actions?query=workflow%3ACI)
7
+ [![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-xsd/badge.svg)](https://coveralls.io/github/ruby-rdf/rdf-xsd?branch=develop)
8
+ [![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
9
9
 
10
10
  ## Features
11
11
 
12
12
  * Additional xsd:integer subtypes
13
13
  * xsd:float based on xsd:double
14
- * xsd:duration
14
+ * xsd:duration, xsd:yearMonthDuration, and xsd:dayTimeDuration.
15
15
  * rdf:XMLLiteral
16
16
  * XML Exclusive Canonicalization (Nokogiri & REXML)
17
- * XML Literal comparisions (EquivalentXml, ActiveSupport or String)
17
+ * XML Literal comparisons (EquivalentXml, ActiveSupport or String)
18
18
 
19
19
  ## Examples
20
20
 
@@ -22,32 +22,34 @@ This gem adds additional RDF::Literal subclasses for extended [XSD datatypes][]
22
22
  require 'rdf/xsd'
23
23
 
24
24
  ## Dependencies
25
- * [Ruby](http://ruby-lang.org/) (>= 2.4)
26
- * [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.1)
27
- * Soft dependency on [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.10)
28
- * Soft dependency on [EquivalentXML](http://rubygems.org/gems/equivalent-xml) (>= 0.6.0)
29
- * Soft dependency on [ActiveSupport](http://rubygems.org/gems/activesupport) (>= 3.0.0)
25
+ * [Ruby](https://ruby-lang.org/) (>= 2.6)
26
+ * [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
27
+ * Soft dependency on [Nokogiri](https://rubygems.org/gems/nokogiri) (>= 1.12)
28
+ * Soft dependency on [EquivalentXML](https://rubygems.org/gems/equivalent-xml) (~> 0.6)
29
+ * Soft dependency on [ActiveSupport](https://rubygems.org/gems/activesupport) (~> 6.2)
30
30
 
31
31
  ## Documentation
32
- Full documentation available on [Rubydoc.info][XSD doc]
32
+ Full documentation available on [GitHub][XSD doc]
33
33
 
34
34
  ### Principle Classes
35
35
  * {RDF::Literal::Base64Binary}
36
36
  * {RDF::Literal::Duration}
37
+ * {RDF::Literal::YearMonthDuration}
38
+ * {RDF::Literal::DayTimeDuration}
37
39
  * {RDF::Literal::Float}
38
40
  * {RDF::Literal::HexBinary}
39
41
  * {RDF::Literal::NonPositiveInteger}
40
- * {RDF::Literal::NegativeInteger}
42
+ * {RDF::Literal::NegativeInteger}
41
43
  * {RDF::Literal::Long}
42
- * {RDF::Literal::Int}
43
- * {RDF::Literal::Short}
44
- * {RDF::Literal::Byte}
44
+ * {RDF::Literal::Int}
45
+ * {RDF::Literal::Short}
46
+ * {RDF::Literal::Byte}
45
47
  * {RDF::Literal::NonNegativeInteger}
46
- * {RDF::Literal::PositiveInteger}
47
- * {RDF::Literal::UnsignedLong}
48
- * {RDF::Literal::UnsignedInt}
49
- * {RDF::Literal::UnsignedShort}
50
- * {RDF::Literal::UnsignedByte}
48
+ * {RDF::Literal::PositiveInteger}
49
+ * {RDF::Literal::UnsignedLong}
50
+ * {RDF::Literal::UnsignedInt}
51
+ * {RDF::Literal::UnsignedShort}
52
+ * {RDF::Literal::UnsignedByte}
51
53
  * {RDF::Literal::YearMonth}
52
54
  * {RDF::Literal::Year}
53
55
  * {RDF::Literal::MonthDay}
@@ -57,18 +59,18 @@ Full documentation available on [Rubydoc.info][XSD doc]
57
59
 
58
60
  ## Installation
59
61
 
60
- The recommended installation method is via [RubyGems](http://rubygems.org/).
62
+ The recommended installation method is via [RubyGems](https://rubygems.org/).
61
63
  To install the latest official release of the `RDF::XSD` gem, do:
62
64
 
63
65
  % [sudo] gem install rdf-xsd
64
66
 
65
67
  ## Mailing List
66
68
 
67
- * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
69
+ * <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
68
70
 
69
71
  ## Author
70
72
 
71
- * [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
73
+ * [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
72
74
 
73
75
  ## Contributing
74
76
  This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
@@ -83,19 +85,23 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
83
85
  list in the the `README`. Alphabetical order applies.
84
86
  * Do note that in order for us to merge any non-trivial changes (as a rule
85
87
  of thumb, additions larger than about 15 lines of code), we need an
86
- explicit [public domain dedication][PDD] on record from you.
88
+ explicit [public domain dedication][PDD] on record from you,
89
+ which you will be asked to agree to on the first commit to a repo within the organization.
90
+ Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
87
91
 
88
92
  ## License
89
93
 
90
94
  This is free and unencumbered public domain software. For more information,
91
- see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
92
-
93
- Portions of tests are derived from [W3C DAWG tests](http://www.w3.org/2001/sw/DataAccess/tests/) and have [other licensing terms](http://www.w3.org/2001/sw/DataAccess/tests/data-r2/LICENSE).
94
-
95
- [Ruby]: http://ruby-lang.org/
96
- [RDF]: http://www.w3.org/RDF/
97
- [YARD]: http://yardoc.org/
98
- [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
99
- [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
100
- [Backports]: http://rubygems.org/gems/backports
101
- [XSD Datatypes]: http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-datatypes
95
+ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
96
+
97
+ Portions of tests are derived from [W3C DAWG tests](https://www.w3.org/2001/sw/DataAccess/tests/) and have [other licensing terms](https://www.w3.org/2001/sw/DataAccess/tests/data-r2/LICENSE).
98
+
99
+ [Ruby]: https://ruby-lang.org/
100
+ [RDF]: https://www.w3.org/RDF/
101
+ [YARD]: https://yardoc.org/
102
+ [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
103
+ [PDD]: https://unlicense.org/#unlicensing-contributions
104
+ [Backports]: https://rubygems.org/gems/backports
105
+ [XSD Datatypes]: https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-datatypes
106
+ [XPath and XQuery Functions]: https://www.w3.org/TR/xpath-functions/
107
+ [XSD Doc]: https://ruby-rdf.github.io/rdf-xsd
data/UNLICENSE CHANGED
@@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
21
  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
22
  OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
- For more information, please refer to <http://unlicense.org/>
24
+ For more information, please refer to <https://unlicense.org/>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.0
1
+ 3.2.1
@@ -5,7 +5,7 @@ module RDF; class Literal
5
5
  ##
6
6
  # More specific sub-types of double
7
7
  # Derived types
8
- # @see http://www.w3.org/TR/xpath-functions/#datatypes
8
+ # @see https://www.w3.org/TR/xpath-functions/#datatypes
9
9
 
10
10
  ##
11
11
  # anyURI represents a Uniform Resource Identifier Reference (URI).
@@ -14,9 +14,9 @@ module RDF; class Literal
14
14
  # This type should be used to specify the intention that the value fulfills
15
15
  # the role of a URI as defined by [RFC 2396], as amended by [RFC 2732].
16
16
  #
17
- # @see http://www.w3.org/TR/xmlschema11-2/#anyURI
18
- # @see http://www.ietf.org/rfc/rfc2396.txt
19
- # @see http://www.ietf.org/rfc/rfc2732.txt
17
+ # @see https://www.w3.org/TR/xmlschema11-2/#anyURI
18
+ # @see https://www.ietf.org/rfc/rfc2396.txt
19
+ # @see https://www.ietf.org/rfc/rfc2732.txt
20
20
  class AnyURI < RDF::Literal
21
21
  DATATYPE = RDF::XSD.anyURI
22
22
 
@@ -5,13 +5,13 @@ module RDF; class Literal
5
5
  ##
6
6
  # More specific sub-types of double
7
7
  # Derived types
8
- # @see http://www.w3.org/TR/xpath-functions/#datatypes
8
+ # @see https://www.w3.org/TR/xpath-functions/#datatypes
9
9
 
10
10
  ##
11
11
  # hexBinary represents arbitrary hex-encoded binary data. The value space of hexBinary is the set of finite-length
12
12
  # sequences of binary octets.
13
13
  #
14
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#hexBinary
14
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#hexBinary
15
15
  class HexBinary < RDF::Literal
16
16
  DATATYPE = RDF::XSD.hexBinary
17
17
  GRAMMAR = %r(\A[0-9a-fA-F]+\Z)
@@ -57,7 +57,7 @@ module RDF; class Literal
57
57
  # finite-length sequences of binary octets. For base64Binary data the entire binary stream is encoded using the Base64
58
58
  # Alphabet in [RFC 2045].
59
59
  #
60
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#hexBinary
60
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#hexBinary
61
61
  class Base64Binary < RDF::Literal
62
62
  DATATYPE = RDF::XSD.base64Binary
63
63
 
@@ -84,7 +84,7 @@ module RDF; class Literal
84
84
  # Converts this literal into its canonical lexical representation.
85
85
  #
86
86
  # @return [RDF::Literal] `self`
87
- # @see http://www.w3.org/TR/xmlschema-2/#dateTime
87
+ # @see https://www.w3.org/TR/xmlschema-2/#dateTime
88
88
  def canonicalize!
89
89
  @string = ::Base64.encode64(@object)
90
90
  self
data/lib/rdf/xsd/date.rb CHANGED
@@ -7,11 +7,11 @@ module RDF; class Literal
7
7
  #
8
8
  # The dateTimeStamp datatype is ·derived· from dateTime by giving the value required to its explicitTimezone facet. The result is that all values of dateTimeStamp are required to have explicit time zone offsets and the datatype is totally ordered.
9
9
  #
10
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dateTimeStamp
10
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dateTimeStamp
11
11
  class DateTimeStamp < RDF::Literal::DateTime
12
12
  DATATYPE = RDF::XSD.dateTimeStamp
13
13
  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
14
- FORMAT = '%Y-%m-%dT%H:%M:%SZ'.freeze
14
+ FORMAT = '%Y-%m-%dT%H:%M:%S'.freeze
15
15
  end
16
16
 
17
17
  ##
@@ -20,11 +20,11 @@ module RDF; class Literal
20
20
  # long, non-periodic instances e.g. 1999-10 to represent the whole month of 1999-10, independent of how many days this
21
21
  # month has.
22
22
  #
23
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gYearMonth
23
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gYearMonth
24
24
  class YearMonth < RDF::Literal::Date
25
25
  DATATYPE = RDF::XSD.gYearMonth
26
26
  GRAMMAR = %r(\A(-?\d{4,}-\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
27
- FORMAT = '%Y-%m%Z'.freeze
27
+ FORMAT = '%Y-%m'.freeze
28
28
 
29
29
  def initialize(value, datatype: nil, lexical: nil, **options)
30
30
  @string = lexical || value.to_s
@@ -38,11 +38,11 @@ module RDF; class Literal
38
38
  # defined in § 5.2.1 of [ISO 8601]. Specifically, it is a set of one-year long, non-periodic instances e.g. lexical
39
39
  # 1999 to represent the whole year 1999, independent of how many months and days this year has.
40
40
  #
41
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gYear
41
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gYear
42
42
  class Year < RDF::Literal::Date
43
43
  DATATYPE = RDF::XSD.gYear
44
44
  GRAMMAR = %r(\A(-?\d{4,})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
45
- FORMAT = '%Y%Z'.freeze
45
+ FORMAT = '%Y'.freeze
46
46
 
47
47
  def initialize(value, datatype: nil, lexical: nil, **options)
48
48
  @string = lexical || value.to_s
@@ -56,11 +56,11 @@ module RDF; class Literal
56
56
  # recurring dates are not supported by this datatype. The value space of gMonthDay is the set of calendar dates,
57
57
  # as defined in § 3 of [ISO 8601]. Specifically, it is a set of one-day long, annually periodic instances.
58
58
  #
59
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gMonthDay
59
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gMonthDay
60
60
  class MonthDay < RDF::Literal::Date
61
61
  DATATYPE = RDF::XSD.gMonthDay
62
62
  GRAMMAR = %r(\A--(\d{2}-\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
63
- FORMAT = '%m-%d%Z'.freeze
63
+ FORMAT = '%m-%d'.freeze
64
64
 
65
65
  def initialize(value, datatype: nil, lexical: nil, **options)
66
66
  @string = lexical || value.to_s
@@ -74,11 +74,11 @@ module RDF; class Literal
74
74
  # recurring days are not supported by this datatype. The value space of gDay is the space of a set of calendar
75
75
  # dates as defined in § 3 of [ISO 8601]. Specifically, it is a set of one-day long, monthly periodic instances.
76
76
  #
77
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gDay
77
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gDay
78
78
  class Day < RDF::Literal::Date
79
79
  DATATYPE = RDF::XSD.gDay
80
80
  GRAMMAR = %r(\A---(\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
81
- FORMAT = '%d%Z'.freeze
81
+ FORMAT = '%d'.freeze
82
82
 
83
83
  def initialize(value, datatype: nil, lexical: nil, **options)
84
84
  @string = lexical || value.to_s
@@ -91,11 +91,11 @@ module RDF; class Literal
91
91
  # gMonth is a gregorian month that recurs every year. The value space of gMonth is the space of a set of calendar
92
92
  # months as defined in § 3 of [ISO 8601]. Specifically, it is a set of one-month long, yearly periodic instances.
93
93
  #
94
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gMonth
94
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gMonth
95
95
  class Month < RDF::Literal::Date
96
96
  DATATYPE = RDF::XSD.gMonth
97
97
  GRAMMAR = %r(\A--(\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
98
- FORMAT = '%m%Z'.freeze
98
+ FORMAT = '%m'.freeze
99
99
 
100
100
  def initialize(value, datatype: nil, lexical: nil, **options)
101
101
  @string = lexical || value.to_s
@@ -1,7 +1,7 @@
1
1
  module RDF; class Literal
2
2
  # Note that in XML Schema, Float is not really derived from Double,
3
3
  # but implementations are identical in Ruby
4
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#float
4
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#float
5
5
  class Float < Double
6
6
  DATATYPE = RDF::XSD.float
7
7
  end
@@ -5,7 +5,9 @@ module RDF; class Literal
5
5
  ##
6
6
  # A duration literal.
7
7
  #
8
- # @see http://www.w3.org/TR/xmlschema11-2/#duration
8
+ # `duration` is a datatype that represents durations of time. The concept of duration being captured is drawn from those of [ISO 8601](https://www.w3.org/TR/xmlschema11-2/#ISO8601), specifically durations without fixed endpoints.
9
+ #
10
+ # @see https://www.w3.org/TR/xmlschema11-2/#duration
9
11
  class Duration < Literal
10
12
  DATATYPE = RDF::XSD.duration
11
13
  GRAMMAR = %r(\A
@@ -14,12 +16,12 @@ module RDF; class Literal
14
16
  | (?:(?:(?<mo>\d+)M)(?:(?<da>\d+)D)?)
15
17
  | (?:(?<da>\d+)D)
16
18
  )
17
- (?:T(?:(?:(?:(?<hr>\d+)H)(?:(?<mi>\d+)M)?(?<se>\d+(?:\.\d+)?S)?)
19
+ (?:T(?:(?:(?:(?<hr>\d+)H)(?:(?<mi>\d+)M)?(?:(?<se>\d+(?:\.\d+)?)S)?)
18
20
  | (?:(?:(?<mi>\d+)M)(?:(?<se>\d+(?:\.\d+)?)S)?)
19
21
  | (?:(?<se>\d+(?:\.\d+)?)S)
20
22
  )
21
23
  )?
22
- |(?:T(?:(?:(?:(?<hr>\d+)H)(?:(?<mi>\d+)M)?(?<se>\d+(?:\.\d+)?S)?)
24
+ |(?:T(?:(?:(?:(?<hr>\d+)H)(?:(?<mi>\d+)M)?(?:(?<se>\d+(?:\.\d+)?)S)?)
23
25
  | (?:(?:(?<mi>\d+)M)(?:(?<se>\d+(?:\.\d+)?)S)?)
24
26
  | (?:(?<se>\d+(?:\.\d+)?)S)
25
27
  )
@@ -28,66 +30,59 @@ module RDF; class Literal
28
30
  \z)x.freeze
29
31
 
30
32
  ##
31
- # * Given a Numeric, assumes that it is milliseconds
32
- # * Given a String, parse as xsd:duration
33
- # * Hash form is used for internal representation
34
- # @param [Duration, Hash, Numeric, #to_s] value
35
- # @option options [String] :lexical (nil)
33
+ # Creates a new Duration instance.
34
+ #
35
+ # * Given a `String`, parse as `xsd:duration` into months and seconds
36
+ # * Given a `Hash` containing any of `:yr`, `:mo`, :da`, `:hr`, `:mi` and `:si`, it is transformed into months and seconds
37
+ # * Given a Rational, the result is interpreted as days, hours, minutes, and seconds.
38
+ # * Given an Integer, the result is interpreted as years and months.
39
+ # * Object representation is the `Array(months, seconds)`
40
+ #
41
+ # @param [Literal::Duration, Hash, Array, Literal::Numeric, #to_s] value
42
+ # If provided an Array, it is the same as the object form of this literal, an array of two integers, the first of which may be negative.
43
+ # @param [String] lexical (nil)
44
+ # Supplied lexical representation of this literal,
45
+ # otherwise it comes from transforming `value` to a string form..
46
+ # @param [URI] datatype (nil)
47
+ # @param [Hash{Symbol => Object}] options other options passed to `RDF::Literal#initialize`.
48
+ # @option options [Boolean] :validate (false)
49
+ # @option options [Boolean] :canonicalize (false)
36
50
  def initialize(value, datatype: nil, lexical: nil, **options)
37
51
  super
38
52
  @object = case value
39
53
  when Hash
40
- value = value.dup
41
- value[:yr] ||= value[:years]
42
- value[:mo] ||= value[:months]
43
- value[:da] ||= value[:days]
44
- value[:hr] ||= value[:hours]
45
- value[:mi] ||= value[:minutes]
46
- value[:se] ||= value[:seconds]
47
-
48
- value
49
- when Duration, Numeric
50
- {:se => value.to_f}
51
- else
52
- parse(value.to_s)
54
+ months = value[:yr].to_i * 12 + value[:mo].to_i
55
+ seconds = value[:da].to_i * 3600 * 24 +
56
+ value[:hr].to_i * 3600 +
57
+ value[:mi].to_i * 60 +
58
+ value[:se].to_f
59
+
60
+ if value[:si]
61
+ if months != 0
62
+ months = -months
63
+ else
64
+ seconds = -seconds
65
+ end
66
+ end
67
+ [months, seconds]
68
+ when Rational
69
+ [0, value * 24 * 3600]
70
+ when Integer, ::Integer
71
+ [value.to_i, 0]
72
+ when Literal::Duration then value.object
73
+ when Array then value
74
+ else parse(value.to_s)
53
75
  end
54
76
  end
55
77
 
56
78
  ##
57
79
  # Converts this literal into its canonical lexical representation.
58
80
  #
59
- # Also normalizes elements
60
- #
61
- # @return [RDF::Literal] `self`
62
- # @see http://www.w3.org/TR/xmlschema11-2/#dateTime
81
+ # @return [Literal] `self`
82
+ # @see https://www.w3.org/TR/xmlschema11-2/#dateTime
63
83
  def canonicalize!
64
- @string = @humanize = nil
65
- if @object[:se].to_i > 60
66
- m_r = (@object[:se].to_f / 60) - 1
67
- @object[:se] -= m_r * 60
68
- @object[:mi] = @object[:mi].to_i + m_r
69
- end
70
- if @object[:mi].to_i > 60
71
- h_r = (@object[:mi].to_i / 60) - 1
72
- @object[:mi] -= h_r * 60
73
- @object[:hr] = @object[:hr].to_i + h_r
74
- end
75
- if @object[:hr].to_i > 24
76
- d_r = (@object[:hr].to_i / 24) - 1
77
- @object[:hr] -= d_r * 24
78
- @object[:da] = @object[:da].to_i + d_r
79
- end
80
- if @object[:da].to_i > 30
81
- m_r = (@object[:da].to_i / 30) - 1
82
- @object[:da] -= m_r * 30
83
- @object[:mo] = @object[:mo].to_i + m_r
84
- end
85
- if @object[:mo].to_i > 12
86
- y_r = (@object[:mo].to_i / 12) - 1
87
- @object[:mo] -= y_r * 12
88
- @object[:yr] = @object[:yr].to_i + y_r
89
- end
90
- @object.to_s # side-effect
84
+ @string = @humanize = @hash = nil
85
+ self.to_s # side-effect
91
86
  self
92
87
  end
93
88
 
@@ -99,7 +94,23 @@ module RDF; class Literal
99
94
  #
100
95
  # @return [Boolean]
101
96
  def valid?
102
- !!(value =~ GRAMMAR)
97
+ !!value.match?(self.class.const_get(:GRAMMAR))
98
+ end
99
+
100
+ ##
101
+ # Returns a hash representation.
102
+ #
103
+ # @return [Hash]
104
+ def to_h
105
+ @hash ||= {
106
+ si: ('-' if (@object.first == 0 ? @object.last : @object.first) < 0),
107
+ yr: (@object.first.abs / 12),
108
+ mo: (@object.first.abs % 12),
109
+ da: (@object.last.abs.to_i / (3600 * 24)),
110
+ hr: ((@object.last.abs.to_i / 3600) % 24),
111
+ mi: ((@object.last.abs.to_i / 60) % 60),
112
+ se: sec_str.to_f
113
+ }
103
114
  end
104
115
 
105
116
  ##
@@ -108,14 +119,22 @@ module RDF; class Literal
108
119
  # @return [String]
109
120
  def to_s
110
121
  @string ||= begin
111
- str = @object[:si] == '-' ? "-P" : "P"
112
- str << "%dY" % @object[:yr].to_i if @object[:yr]
113
- str << "%dM" % @object[:mo].to_i if @object[:mo]
114
- str << "%dD" % @object[:da].to_i if @object[:da]
115
- str << "T" if @object[:hr] || @object[:mi] || @object[:se]
116
- str << "%dH" % @object[:hr].to_i if @object[:hr]
117
- str << "%dM" % @object[:mi].to_i if @object[:mi]
118
- str << "#{sec_str}S" if @object[:se]
122
+ hash = to_h
123
+ str = (@object.first == 0 ? @object.last : @object.first) < 0 ? '-P' : 'P'
124
+ hash = to_h
125
+ str << "%dY" % hash[:yr] if hash[:yr] > 0
126
+ str << "%dM" % hash[:mo] if hash[:mo] > 0
127
+ str << "%dD" % hash[:da] if hash[:da] > 0
128
+ str << "T" if (hash[:hr] + hash[:mi] + hash[:se]) > 0
129
+ str << "%dH" % hash[:hr] if hash[:hr] > 0
130
+ str << "%dM" % hash[:mi] if hash[:mi] > 0
131
+ str << sec_str + 'S' if hash[:se] > 0
132
+ # Ensure some legal representation
133
+ if str.end_with?('P')
134
+ is_a?(Literal::YearMonthDuration) ? 'P0M' : 'PT0S'
135
+ else
136
+ str
137
+ end
119
138
  end
120
139
  end
121
140
 
@@ -129,57 +148,85 @@ module RDF; class Literal
129
148
  @humanize ||= {}
130
149
  @humanize[lang] ||= begin
131
150
  # Just english, for now
151
+ return "Invalid duration #{value.to_s.inspect}" unless valid?
152
+
153
+ md = value.match(GRAMMAR)
132
154
  ar = []
133
- ar << plural(@object[:yr], "year")
134
- ar << plural(@object[:mo], "month")
135
- ar << plural(@object[:da], "day")
136
- ar << plural(@object[:hr], "hour")
137
- ar << plural(@object[:mi], "minute")
138
- ar << plural(sec_str, "second") if @object[:se]
139
- ar = ar.compact
155
+ ar << plural(md[:yr], "year") if md[:yr]
156
+ ar << plural(md[:mo], "month") if md[:mo]
157
+ ar << plural(md[:da], "day") if md[:da]
158
+ ar << plural(md[:hr], "hour") if md[:hr]
159
+ ar << plural(md[:mi], "minute") if md[:mi]
160
+ ar << plural(md[:se], "second") if md[:se]
140
161
  last = ar.pop
141
162
  first = ar.join(" ")
142
163
  res = first.empty? ? last : "#{first} and #{last}"
143
- @object[:si] == '-' ? "#{res} ago" : res
164
+ md[:si] == '-' ? "#{res} ago" : res
144
165
  end
145
166
  end
146
167
 
147
168
  ##
148
- # Equal compares as DateTime objects
169
+ # Returns `true` if `self` and `other` are durations of the same length.
170
+ #
171
+ # From the XQuery function [op:duration-equal](https://www.w3.org/TR/xpath-functions/#func-duration-equal).
172
+ #
173
+ # @see https://www.w3.org/TR/xpath-functions/#func-duration-equal
149
174
  def ==(other)
150
175
  # If lexically invalid, use regular literal testing
151
176
  return super unless self.valid?
152
177
 
153
- case other
154
- when Duration
155
- return super unless other.valid?
156
- self.to_f == other.to_f
157
- when String
158
- self.to_s(:xml) == other
159
- when Numeric
160
- self.to_f == other
161
- when Literal::DateTime, Literal::Time, Literal::Date
162
- false
163
- else
164
- super
165
- end
178
+ other.is_a?(Literal::Duration) && other.valid? ? @object == other.object : super
166
179
  end
167
180
 
168
- # @return [Float]
169
- def to_f
170
- ( @object[:yr].to_i * 365 * 24 * 3600 +
171
- @object[:mo].to_i * 30 * 24 * 3600 +
172
- @object[:da].to_i * 24 * 3600 +
173
- @object[:hr].to_i * 3600 +
174
- @object[:mi].to_i * 60 +
175
- @object[:se].to_f
176
- ) * (@object[:si] == '-' ? -1 : 1)
177
- end
181
+ # Years
182
+ #
183
+ # From the XQuery function [fn:years-from-duration](https://www.w3.org/TR/xpath-functions/#func-years-from-duration).
184
+ #
185
+ # @return [Integer]
186
+ # @see https://www.w3.org/TR/xpath-functions/#func-years-from-duration
187
+ def years; Integer.new(to_h[:yr] * (to_h[:si] ? -1 : 1)); end
178
188
 
189
+ # Months
190
+ #
191
+ # From the XQuery function [fn:months-from-duration](https://www.w3.org/TR/xpath-functions/#func-months-from-duration).
192
+ #
179
193
  # @return [Integer]
180
- def to_i; Integer(self.to_f); end
181
-
182
- private
194
+ # @see https://www.w3.org/TR/xpath-functions/#func-months-from-duration
195
+ def months; Integer.new(to_h[:mo] * (to_h[:si] ? -1 : 1)); end
196
+
197
+ # Days
198
+ #
199
+ # From the XQuery function [fn:days-from-duration](https://www.w3.org/TR/xpath-functions/#func-days-from-duration).
200
+ #
201
+ # @return [Integer]
202
+ # @see https://www.w3.org/TR/xpath-functions/#func-days-from-duration
203
+ def days; Integer.new(to_h[:da] * (to_h[:si] ? -1 : 1)); end
204
+
205
+ # Hours
206
+ #
207
+ # From the XQuery function [fn:hours-from-duration](https://www.w3.org/TR/xpath-functions/#func-hours-from-duration).
208
+ #
209
+ # @return [Integer]
210
+ # @see https://www.w3.org/TR/xpath-functions/#func-hours-from-duration
211
+ def hours; Integer.new(to_h[:hr] * (to_h[:si] ? -1 : 1)); end
212
+
213
+ # Minutes
214
+ #
215
+ # From the XQuery function [fn:minutes-from-duration](https://www.w3.org/TR/xpath-functions/#func-minutes-from-duration).
216
+ #
217
+ # @return [Integer]
218
+ # @see https://www.w3.org/TR/xpath-functions/#func-minutes-from-duration
219
+ def minutes; Integer.new(to_h[:mi] * (to_h[:si] ? -1 : 1)); end
220
+
221
+ # Seconds
222
+ #
223
+ # From the XQuery function [fn:seconds-from-duration](https://www.w3.org/TR/xpath-functions/#func-seconds-from-duration).
224
+ #
225
+ # @return [Decimal]
226
+ # @see https://www.w3.org/TR/xpath-functions/#func-seconds-from-duration
227
+ def seconds; Decimal.new(to_h[:se] * (to_h[:si] ? -1 : 1)); end
228
+
229
+ private
183
230
  # Reverse convert from XSD version of duration
184
231
  # XSD allows -P1111Y22M33DT44H55M66.666S with any combination in regular order
185
232
  # We assume 1M == 30D, but are out of spec in this regard
@@ -188,22 +235,137 @@ module RDF; class Literal
188
235
  # @param [String] value XSD formatted duration
189
236
  # @return [Duration]
190
237
  def parse(value)
191
- value.to_s.match(GRAMMAR)
238
+ return [0, 0] unless md = value.to_s.match(GRAMMAR)
239
+
240
+ months = md[:yr].to_i * 12 + md[:mo].to_i
241
+ seconds = md[:da].to_i * 3600 * 24 +
242
+ md[:hr].to_i * 3600 +
243
+ md[:mi].to_i * 60 +
244
+ md[:se].to_f
245
+
246
+ if md[:si]
247
+ if months != 0
248
+ months = -months
249
+ else
250
+ seconds = -seconds
251
+ end
252
+ end
253
+
254
+ [months, seconds]
192
255
  end
193
256
 
194
257
  def sec_str
195
- sec = @object[:se].to_f
258
+ sec = @object.last.abs % 60
196
259
  ((sec.truncate == sec ? "%d" : "%2.3f") % sec).sub(/(\.[1-9]+)0+$/, '\1')
197
260
  end
198
261
  end # Duration
199
262
 
263
+ ##
264
+ # A `YearMonthDuration` literal.
265
+ #
266
+ # `yearMonthDuration` is a datatype ·derived· from `xsd:duration` by restricting its ·lexical representations· to instances of `yearMonthDurationLexicalRep`. The ·value space· of `yearMonthDuration` is therefore that of `duration` restricted to those whose ·seconds· property is 0. This results in a `duration` datatype which is totally ordered.
267
+ #
268
+ # @see https://www.w3.org/TR/xmlschema11-2/#yearMonthDuration
269
+ class YearMonthDuration < Duration
270
+ DATATYPE = RDF::XSD.yearMonthDuration
271
+ GRAMMAR = %r(\A
272
+ (?<si>-)?
273
+ P(?:(?:(?:(?:(?<yr>\d+)Y)(?:(?<mo>\d+)M)?)
274
+ | (?:(?:(?<mo>\d+)M))
275
+ )
276
+ )
277
+ \z)x.freeze
278
+
279
+ ##
280
+ # Returns the sum of two xs:yearMonthDuration values.
281
+ #
282
+ # From the XQuery function [op:add-yearMonthDurations](https://www.w3.org/TR/xpath-functions/#func-add-yearMonthDurations).
283
+ #
284
+ # @param [YearMonthDuration] other
285
+ # @return [YearMonthDuration]
286
+ # @see https://www.w3.org/TR/xpath-functions/#func-add-yearMonthDurations
287
+ def +(other)
288
+ return type_error("#{other.inspect} is not a valid YearMonthDuration") unless other.is_a?(Literal::YearMonthDuration) && other.valid?
289
+ self.class.new([object.first + other.object.first, 0])
290
+ end
291
+
292
+ ##
293
+ # Returns the result of subtracting one xs:yearMonthDuration value from another.
294
+ #
295
+ # From the XQuery function [op:subtract-yearMonthDurations](https://www.w3.org/TR/xpath-functions/#func-subtract-yearMonthDurations).
296
+ #
297
+ # @param [YearMonthDuration] other
298
+ # @return [YearMonthDuration]
299
+ # @see https://www.w3.org/TR/xpath-functions/#func-subtract-yearMonthDurations
300
+ def -(other)
301
+ return type_error("#{other.inspect} is not a valid YearMonthDuration") unless other.is_a?(Literal::YearMonthDuration) && other.valid?
302
+ self.class.new([object.first - other.object.first, 0])
303
+ end
304
+
305
+ ##
306
+ # Returns the result of multiplying the value of self by `other`. The result is rounded to the nearest month.
307
+ #
308
+ # From the XQuery function [op:multiply-yearMonthDuration](https://www.w3.org/TR/xpath-functions/#func-multiply-yearMonthDuration).
309
+ #
310
+ # @param [Literal::Numeric, ::Numeric, DayTimeDuration] other
311
+ # @return [YearMonthDuration]
312
+ # @see https://www.w3.org/TR/xpath-functions/#func-multiply-yearMonthDuration
313
+ def *(other)
314
+ return type_error("#{other.inspect} is not a valid Numeric") unless (other.is_a?(::Numeric) || other.is_a?(Literal::Numeric))
315
+ self.class.new([(object.first * other.to_f).round, 0])
316
+ end
317
+
318
+ ##
319
+ # Returns the result of dividing the value of self by `other`. The result is rounded to the nearest month.
320
+ #
321
+ # From the XQuery functions [op:divide-yearMonthDuration](https://www.w3.org/TR/xpath-functions/#func-divide-yearMonthDuration) and [op:divide-yearMonthDuration-by-yearMonthDuration](https://www.w3.org/TR/xpath-functions/#func-divide-yearMonthDuration-by-yearMonthDuration).
322
+ #
323
+ # @param [Literal::Numeric, ::Numeric, YearMonthDuration] other
324
+ # @return [YearMonthDuration, Decimal]
325
+ # @see https://www.w3.org/TR/xpath-functions/#func-divide-yearMonthDuration
326
+ # @see https://www.w3.org/TR/xpath-functions/#func-divide-yearMonthDuration-by-yearMonthDuration
327
+ def /(other)
328
+ case other
329
+ when Literal::YearMonthDuration
330
+ return type_error("#{other.inspect} is not a valid YearMonthDuration or Numeric") unless other.valid?
331
+ Decimal.new(object.first / other.object.first.to_f)
332
+ when Literal::Numeric, ::Numeric
333
+ self.class.new([(object.first / other.to_f).round, 0])
334
+ else
335
+ type_error("#{other.inspect} is not a valid YearMonthDuration or Numeric")
336
+ end
337
+ end
338
+
339
+ ##
340
+ # Compares this literal to `other` for sorting purposes.
341
+ #
342
+ # From the XQuery function [op:yearMonthDuration-greater-than](https://www.w3.org/TR/xpath-functions/#func-yearMonthDuration-less-than).
343
+ #
344
+ # @param [Literal::YearMonthDuration] other
345
+ # @return [Boolean] `true` if less than other for defined datatypes
346
+ # @see https://www.w3.org/TR/xpath-functions/#func-yearMonthDuration-less-than
347
+ # @see https://www.w3.org/TR/xpath-functions/#func-yearMonthDuration-greater-than
348
+ def <=>(other)
349
+ return type_error("#{other.inspect} is not a valid YearMonthDuration") unless other.is_a?(Literal::YearMonthDuration) && other.valid?
350
+ @object.first <=> other.object.first
351
+ end
352
+
353
+ ##
354
+ # Converts the dayTimeDuration into rational seconds.
355
+ #
356
+ # @return [Rational]
357
+ def to_i
358
+ object.first.to_i
359
+ end
360
+ end # YearMonthDuration
361
+
200
362
  ##
201
363
  # A DayTimeDuration literal.
202
364
  #
203
- # dayTimeDuration is a datatype ·derived· from duration by restricting its ·lexical representations· to instances of dayTimeDurationLexicalRep. The ·value space· of dayTimeDuration is therefore that of duration restricted to those whose ·months· property is 0. This results in a duration datatype which is totally ordered.
365
+ # `dayTimeDuration` is a datatype ·derived· from `duration` by restricting its ·lexical representations· to instances of `dayTimeDurationLexicalRep`. The ·value space· of `dayTimeDuration` is therefore that of `duration` restricted to those whose ·months· property is 0. This results in a duration datatype which is totally ordered.
204
366
  #
205
- # @see http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration
206
- class DayTimeDuration < Literal
367
+ # @see https://www.w3.org/TR/xmlschema11-2/#dayTimeDuration
368
+ class DayTimeDuration < Duration
207
369
  DATATYPE = RDF::XSD.dayTimeDuration
208
370
  GRAMMAR = %r(\A
209
371
  (?<si>-)?
@@ -221,22 +383,87 @@ module RDF; class Literal
221
383
  )
222
384
  )
223
385
  \z)x.freeze
224
- end # DayTimeDuration
225
386
 
226
- ##
227
- # A YearMonthDuration literal.
228
- #
229
- # yearMonthDuration is a datatype ·derived· from duration by restricting its ·lexical representations· to instances of yearMonthDurationLexicalRep. The ·value space· of yearMonthDuration is therefore that of duration restricted to those whose ·seconds· property is 0. This results in a duration datatype which is totally ordered.
230
- #
231
- # @see http://www.w3.org/TR/xmlschema11-2/#yearMonthDuration
232
- class YearMonthDuration < Literal
233
- DATATYPE = RDF::XSD.yearMonthDuration
234
- GRAMMAR = %r(\A
235
- (?<si>-)?
236
- P(?:(?:(?:(?:(?<yr>\d+)Y)(?:(?<mo>\d+)M)?)
237
- | (?:(?:(?<mo>\d+)M))
238
- )
239
- )
240
- \z)x.freeze
387
+ ##
388
+ # Returns the sum of two xs:dayTimeDuration values.
389
+ #
390
+ # From the XQuery function [op:add-dayTimeDurations](https://www.w3.org/TR/xpath-functions/#func-add-dayTimeDurations).
391
+ #
392
+ # @param [DayTimeDuration] other
393
+ # @return [DayTimeDuration]
394
+ # @see https://www.w3.org/TR/xpath-functions/#func-add-dayTimeDurations
395
+ def +(other)
396
+ return type_error("#{other.inspect} is not a valid DayTimeDuration") unless other.is_a?(Literal::DayTimeDuration) && other.valid?
397
+ self.class.new([0, object.last + other.object.last])
398
+ end
399
+
400
+ ##
401
+ # Returns the result of subtracting one xs:dayTimeDuration value from another.
402
+ #
403
+ # From the XQuery function [op:subtract-dayTimeDurationss](https://www.w3.org/TR/xpath-functions/#func-subtract-dayTimeDurations).
404
+ #
405
+ # @param [DayTimeDuration] other
406
+ # @return [DayTimeDuration]
407
+ # @see https://www.w3.org/TR/xpath-functions/#func-subtract-dayTimeDurations
408
+ def -(other)
409
+ return type_error("#{other.inspect} is not a valid DayTimeDuration") unless other.is_a?(Literal::DayTimeDuration) && other.valid?
410
+ self.class.new([0, object.last - other.object.last])
411
+ end
412
+
413
+ ##
414
+ # Returns the result of multiplying the value of self by `other`. The result is rounded to the nearest month.
415
+ #
416
+ # From the XQuery function [op:multiply-dayTimeDuration](https://www.w3.org/TR/xpath-functions/#func-multiply-dayTimeDuration).
417
+ #
418
+ # @param [Literal::Numeric, ::Numeric] other
419
+ # @return [DayTimeDuration]
420
+ # @see https://www.w3.org/TR/xpath-functions/#func-multiply-dayTimeDuration
421
+ def *(other)
422
+ return type_error("#{other.inspect} is not a valid Numeric") unless (other.is_a?(::Numeric) || other.is_a?(Literal::Numeric))
423
+ self.class.new([0, object.last * other.to_f])
424
+ end
425
+
426
+ ##
427
+ # Returns the result of dividing the value of self by `other`. The result is rounded to the nearest month.
428
+ #
429
+ # From the XQuery functions [op:divide-yearMonthDuration](https://www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration) and [op:divide-yearMonthDuration-by-yearMonthDuration](https://www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration-by-dayTimeDuration).
430
+ #
431
+ # @param [Literal::Numeric, ::Numeric, DayTimeDuration] other
432
+ # @return [DayTimeDuration, Decimal]
433
+ # @see https://www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration
434
+ # @see https://www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration-by-dayTimeDuration
435
+ def /(other)
436
+ case other
437
+ when DayTimeDuration
438
+ return type_error("#{other.inspect} is not a valid DayTimeDuration or Numeric") unless other.valid?
439
+ Decimal.new(object.last / other.object.last.to_f)
440
+ when Literal::Numeric, ::Numeric
441
+ self.class.new([0, object.last / other.to_f])
442
+ else
443
+ type_error("#{other.inspect} is not a valid DayTimeDuration or Numeric")
444
+ end
445
+ end
446
+
447
+ ##
448
+ # Compares this literal to `other` for sorting purposes.
449
+ #
450
+ # From the XQuery function [op:dayTimeDuration-less-than](https://www.w3.org/TR/xpath-functions/#func-dayTimeDuration-less-than).
451
+ #
452
+ # @param [DayTimeDuration] other
453
+ # @return [Boolean] `true` if less than other for defined datatypes
454
+ # @see https://www.w3.org/TR/xpath-functions/#func-dayTimeDuration-less-than
455
+ # @see https://www.w3.org/TR/xpath-functions/#func-dayTimeDuration-greater-than
456
+ def <=>(other)
457
+ return type_error("#{other.inspect} is not a valid DayTimeDuration") unless other.is_a?(Literal::DayTimeDuration) && other.valid?
458
+ @object.last <=> other.object.last
459
+ end
460
+
461
+ ##
462
+ # Converts the dayTimeDuration into rational seconds.
463
+ #
464
+ # @return [Rational]
465
+ def to_r
466
+ Rational(object.last) / (24 * 3600)
467
+ end
241
468
  end # DayTimeDuration
242
469
  end; end # RDF::Literal
@@ -15,7 +15,7 @@ if defined?(::Nokogiri)
15
15
  # or NoteSet in the context of its containing document, and second to
16
16
  # serialize to a lexical representation.
17
17
  #
18
- # @see # @see http://www.w3.org/TR/xml-exc-c14n/
18
+ # @see # @see https://www.w3.org/TR/xml-exc-c14n/
19
19
  class Node
20
20
  ##
21
21
  # Canonicalize the Node. Return a new instance of this node
@@ -89,7 +89,7 @@ if defined?(::Nokogiri)
89
89
  # as being canonical with all child nodes canonicalized.
90
90
  #
91
91
  # @param [Hash{Symbol => Object}] options
92
- # Passed to {Nokogiri::XML::Node#c14nxl}
92
+ # Passed to `Nokogiri::XML::Node#c14nxl`
93
93
  def c14nxl(options = {})
94
94
  # Create a new NodeSet
95
95
  set = self.dup
@@ -173,7 +173,7 @@ class REXML::Element
173
173
  # Apply namespaces either passed as an option, or that are in scope.
174
174
  #
175
175
  # @param [Hash{Symbol => Object}] options
176
- # From {Nokogiri::XML::Node#c14nxl}
176
+ # From `Nokogiri::XML::Node#c14nxl`
177
177
  def c14nxl(options = {})
178
178
  # Add in-scope namespace definitions, unless supplied
179
179
  options[:namespaces] ||= self.namespaces
@@ -3,9 +3,9 @@ module RDF; class Literal
3
3
  ##
4
4
  # nonPositiveInteger is derived from integer by setting the value of maxInclusive to be 0. This results in
5
5
  # the standard mathematical concept of the non-positive integers. The value space of nonPositiveInteger is the
6
- # infinite set {...,-2,-1,0}. The base type of nonPositiveInteger is integer.
6
+ # infinite set `{...,-2,-1,0}`. The base type of nonPositiveInteger is integer.
7
7
  #
8
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#nonPositiveInteger
8
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#nonPositiveInteger
9
9
  class NonPositiveInteger < Integer
10
10
  DATATYPE = RDF::XSD.nonPositiveInteger
11
11
  GRAMMAR = /^(?:[\+\-]?0)|(?:-\d+)$/.freeze
@@ -29,9 +29,9 @@ module RDF; class Literal
29
29
  ##
30
30
  # negativeInteger is derived from nonPositiveInteger by setting the value of maxInclusive to be -1. This
31
31
  # results in the standard mathematical concept of the negative integers. The value space of negativeInteger is
32
- # the infinite set {...,-2,-1}. The base type of negativeInteger is nonPositiveInteger.
32
+ # the infinite set `{...,-2,-1}`. The base type of negativeInteger is nonPositiveInteger.
33
33
  #
34
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#negativeInteger
34
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#negativeInteger
35
35
  class NegativeInteger < NonPositiveInteger
36
36
  GRAMMAR = /^\-\d+$/.freeze
37
37
  DATATYPE = RDF::XSD.negativeInteger
@@ -57,7 +57,7 @@ module RDF; class Literal
57
57
  # and minInclusive to be -9223372036854775808.
58
58
  #
59
59
  # The base type of long is integer.
60
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#long
60
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#long
61
61
  class Long < Integer
62
62
  DATATYPE = RDF::XSD.long
63
63
 
@@ -70,7 +70,7 @@ module RDF; class Literal
70
70
  # int is derived from long by setting the value of maxInclusive to be 2147483647 and minInclusive to be
71
71
  # -2147483648. The base type of int is long.
72
72
  #
73
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#int
73
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#int
74
74
  class Int < Long
75
75
  DATATYPE = RDF::XSD.int
76
76
 
@@ -83,7 +83,7 @@ module RDF; class Literal
83
83
  # short is derived from int by setting the value of maxInclusive to be 32767 and minInclusive to be
84
84
  # -32768. The base type of short is int.
85
85
  #
86
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#short
86
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#short
87
87
  class Short < Int
88
88
  DATATYPE = RDF::XSD.short
89
89
 
@@ -96,7 +96,7 @@ module RDF; class Literal
96
96
  # byte is derived from short by setting the value of maxInclusive to be 127 and minInclusive to be -128.
97
97
  # The base type of byte is short.
98
98
  #
99
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#byte
99
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#byte
100
100
  class Byte < Short
101
101
  DATATYPE = RDF::XSD.byte
102
102
 
@@ -110,7 +110,7 @@ module RDF; class Literal
110
110
  # the standard mathematical concept of the non-negative integers. The value space of nonNegativeInteger is the
111
111
  # infinite set [0,1,2,...]. The base type of nonNegativeInteger is integer.
112
112
  #
113
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#nonNegativeInteger
113
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#nonNegativeInteger
114
114
  class NonNegativeInteger < Integer
115
115
  GRAMMAR = /^(?:(?:[\+\-]?0)|(?:\+?\d+))$/.freeze
116
116
  DATATYPE = RDF::XSD.nonNegativeInteger
@@ -125,7 +125,7 @@ module RDF; class Literal
125
125
  # results in the standard mathematical concept of the positive integer numbers. The value space of
126
126
  # positiveInteger is the infinite set [1,2,...]. The base type of positiveInteger is nonNegativeInteger.
127
127
  #
128
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#positiveInteger
128
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#positiveInteger
129
129
  class PositiveInteger < NonNegativeInteger
130
130
  GRAMMAR = /^\+?\d+$/.freeze
131
131
  DATATYPE = RDF::XSD.positiveInteger
@@ -139,7 +139,7 @@ module RDF; class Literal
139
139
  # unsignedLong is derived from nonNegativeInteger by setting the value of maxInclusive to be
140
140
  # 18446744073709551615. The base type of unsignedLong is nonNegativeInteger.
141
141
  #
142
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedLong
142
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedLong
143
143
  class UnsignedLong < NonNegativeInteger
144
144
  GRAMMAR = /^\d+$/.freeze
145
145
  DATATYPE = RDF::XSD.unsignedLong
@@ -153,7 +153,7 @@ module RDF; class Literal
153
153
  # unsignedInt is derived from unsignedLong by setting the value of maxInclusive to be 4294967295. The base
154
154
  # type of unsignedInt is unsignedLong.
155
155
  #
156
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedInt
156
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedInt
157
157
  class UnsignedInt < UnsignedLong
158
158
  DATATYPE = RDF::XSD.unsignedInt
159
159
 
@@ -166,7 +166,7 @@ module RDF; class Literal
166
166
  # unsignedShort is derived from unsignedInt by setting the value of maxInclusive to be 65535. The base
167
167
  # type of unsignedShort is unsignedInt.
168
168
  #
169
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedShort
169
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedShort
170
170
  class UnsignedShort < UnsignedInt
171
171
  DATATYPE = RDF::XSD.unsignedShort
172
172
 
@@ -179,7 +179,7 @@ module RDF; class Literal
179
179
  # unsignedByte is derived from unsignedShort by setting the value of maxInclusive to be 255. The base
180
180
  # type of unsignedByte is unsignedShort.
181
181
  #
182
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedByte
182
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#unsignedByte
183
183
  class UnsignedByte < UnsignedShort
184
184
  DATATYPE = RDF::XSD.unsignedByte
185
185
 
data/lib/rdf/xsd/xml.rb CHANGED
@@ -20,13 +20,13 @@ module RDF; class Literal
20
20
  # original document, canonicalization cannot be performed directly within this
21
21
  # class.
22
22
  #
23
- # This gem includes Exclusive Canonical XML extensions {Nokogiri::XML::Node#c14nxl},
24
- # {Nokogiri::XML::NodeSet#c14nxl}, {REXML::Element#c14nxl} and {Array#c14nxl} (necessary
23
+ # This gem includes Exclusive Canonical XML extensions `Nokogiri::XML::Node#c14nxl`,
24
+ # `Nokogiri::XML::NodeSet#c14nxl`, `REXML::Element#c14nxl` and `Array#c14nxl` (necessary
25
25
  # for REXML node children, which is the REXML implementation of a NodeSet)
26
26
  #
27
- # @see http://www.w3.org/TR/rdf-concepts/#section-XMLLiteral
28
- # @see http://www.w3.org/TR/rdfa-core/#s_xml_literals
29
- # @see http://www.w3.org/TR/xml-exc-c14n/
27
+ # @see https://www.w3.org/TR/rdf-concepts/#section-XMLLiteral
28
+ # @see https://www.w3.org/TR/rdfa-core/#s_xml_literals
29
+ # @see https://www.w3.org/TR/xml-exc-c14n/
30
30
  class XML < Literal
31
31
  DATATYPE = RDF.XMLLiteral
32
32
  GRAMMAR = nil
@@ -77,7 +77,7 @@ module RDF; class Literal
77
77
  # @param [Object] other
78
78
  # @return [Boolean] `true` or `false`
79
79
  #
80
- # @see http://www.w3.org/TR/rdf-concepts/#section-XMLLiteral
80
+ # @see https://www.w3.org/TR/rdf-concepts/#section-XMLLiteral
81
81
  def eql?(other)
82
82
  if other.is_a?(Literal::XML)
83
83
  case @library
@@ -141,7 +141,7 @@ module RDF; class Literal
141
141
  #
142
142
  # HTML Literals are managed equivalent to XML Literals. Processors
143
143
  # are responsible for coercing the input to an
144
- # [DOM DocumentFragment](http://www.w3.org/TR/dom/#interface-documentfragment).
144
+ # [DOM DocumentFragment](https://www.w3.org/TR/dom/#interface-documentfragment).
145
145
  #
146
146
  # @see https://dvcs.w3.org/hg/rdf/raw-file/default/rdf-concepts/index.html#section-html
147
147
  class HTML < XML
data/lib/rdf/xsd.rb CHANGED
@@ -7,8 +7,8 @@ require 'rdf'
7
7
  # @example Requiring the `RDF::XSD` module
8
8
  # require 'rdf/xsd'
9
9
  #
10
- # @see http://rubygems.org/gems/rdf
11
- # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-datatypes
10
+ # @see https://rubygems.org/gems/rdf
11
+ # @see https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-datatypes
12
12
  #
13
- # @author [Gregg Kellogg](http://greggkellogg.net/)
13
+ # @author [Gregg Kellogg](https://greggkellogg.net/)
14
14
  Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'xsd', '*.rb')) {|f| require f}
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-xsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg
8
8
  - Kellogg
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-12-12 00:00:00.000000000 Z
12
+ date: 2022-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
@@ -17,42 +17,56 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '3.1'
20
+ version: '3.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '3.1'
27
+ version: '3.2'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rexml
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.2'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.2'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: activesupport
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: '5.0'
48
+ version: '6.1'
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
- version: '5.0'
55
+ version: '6.1'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: rspec
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
60
  - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: '3.9'
62
+ version: '3.10'
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: '3.9'
69
+ version: '3.10'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: rspec-its
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -73,29 +87,30 @@ dependencies:
73
87
  requirements:
74
88
  - - "~>"
75
89
  - !ruby/object:Gem::Version
76
- version: '3.1'
90
+ version: '3.2'
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: '3.1'
97
+ version: '3.2'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: yard
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - "~>"
89
103
  - !ruby/object:Gem::Version
90
- version: 0.9.20
104
+ version: '0.9'
91
105
  type: :development
92
106
  prerelease: false
93
107
  version_requirements: !ruby/object:Gem::Requirement
94
108
  requirements:
95
109
  - - "~>"
96
110
  - !ruby/object:Gem::Version
97
- version: 0.9.20
98
- description: Adds RDF::Literal subclasses for extended XSD datatypes.
111
+ version: '0.9'
112
+ description: Adds RDF::Literal subclasses for extended XSD datatypes with methods
113
+ for many XPath and XQuery functions.
99
114
  email: public-rdf-ruby@w3.org
100
115
  executables: []
101
116
  extensions: []
@@ -115,10 +130,15 @@ files:
115
130
  - lib/rdf/xsd/integer.rb
116
131
  - lib/rdf/xsd/version.rb
117
132
  - lib/rdf/xsd/xml.rb
118
- homepage: http://ruby-rdf.github.com/rdf-xsd
133
+ homepage: https://github.com/ruby-rdf/rdf-xsd
119
134
  licenses:
120
135
  - Unlicense
121
- metadata: {}
136
+ metadata:
137
+ documentation_uri: https://ruby-rdf.github.io/rdf-xsd
138
+ bug_tracker_uri: https://github.com/ruby-rdf/rdf-xsd/issues
139
+ homepage_uri: https://github.com/ruby-rdf/rdf-xsd
140
+ mailing_list_uri: https://lists.w3.org/Archives/Public/public-rdf-ruby/
141
+ source_code_uri: https://github.com/ruby-rdf/rdf-xsd
122
142
  post_install_message: |2
123
143
 
124
144
  For best results, use nokogiri and equivalent-xml gems as well.
@@ -130,15 +150,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
150
  requirements:
131
151
  - - ">="
132
152
  - !ruby/object:Gem::Version
133
- version: '2.4'
153
+ version: '2.6'
134
154
  required_rubygems_version: !ruby/object:Gem::Requirement
135
155
  requirements:
136
156
  - - ">="
137
157
  - !ruby/object:Gem::Version
138
158
  version: '0'
139
159
  requirements: []
140
- rubygems_version: 3.0.6
141
- signing_key:
160
+ rubygems_version: 3.3.3
161
+ signing_key:
142
162
  specification_version: 4
143
- summary: Extended XSD Datatypes for RDF.rb.
163
+ summary: Extended XSD Datatypes and XPath and XQuery functions for RDF.rb.
144
164
  test_files: []