Skip to content

Commit ed82a0b

Browse files
committed
Finish 3.3.3
2 parents e0b67d7 + dd28e6d commit ed82a0b

23 files changed

Lines changed: 217 additions & 101 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
ruby: ['3.0', 3.1, 3.2, 3.3, ruby-head, jruby]
28+
ruby: ['3.0', 3.1, 3.2, 3.3, 3.4, ruby-head, jruby]
2929
steps:
3030
- name: Clone repository
3131
uses: actions/checkout@v3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
.env
23
.tmp
34
.yardoc
45
pkg
@@ -9,6 +10,7 @@ tmp
910
Gemfile.lock
1011
.bundle/
1112
*.sw?
13+
*~
1214
benchmark/
1315
/.byebug_history
1416
/coverage/

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,24 @@ Internally, an `RDF::Statement` is treated as another resource, along with `RDF:
280280

281281
**Note: This feature is subject to change or elimination as the standards process progresses.**
282282

283-
### Serializing a Graph containing quoted triples
283+
### Serializing a Graph containing triple terms
284284

285285
require 'rdf/ntriples'
286286
statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
287-
graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
287+
reifier = RDF::Node.new
288+
graph = RDF::Graph.new do |g|
289+
g << [reifier, RDF.reifies, statement]
290+
g << [reifier, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
291+
end
288292
graph.dump(:ntriples, validate: false)
289-
# => '<<<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
293+
# ==> '_:bn <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>)>> .
294+
_:bn <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
290295

291-
### Reading a Graph containing quoted triples
296+
### Reading a Graph containing triple terms
292297

293298
By default, the N-Triples reader will reject a document containing a subject resource.
294299

295-
nt = '<<<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
300+
nt = '<<(<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>)>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
296301
graph = RDF::Graph.new do |graph|
297302
RDF::NTriples::Reader.new(nt) {|reader| graph << reader}
298303
end
@@ -346,6 +351,7 @@ other gems:
346351
* [RDF::TriG][] (extension)
347352
* [RDF::TriX][] (extension)
348353
* [RDF::Turtle][] (extension)
354+
* [RDF::Borsh][] (extension)
349355

350356
The meta-gem [LinkedData][LinkedData doc] includes many of these gems.
351357

@@ -511,6 +517,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
511517
[RDF 1.2]: https://www.w3.org/TR/rdf12-concepts/
512518
[SPARQL 1.1]: https://www.w3.org/TR/sparql11-query/
513519
[RDF.rb]: https://ruby-rdf.github.io/
520+
[RDF::Borsh]: https://ruby-rdf.github.io/rdf-borsh
514521
[RDF::DO]: https://ruby-rdf.github.io/rdf-do
515522
[RDF::Mongo]: https://ruby-rdf.github.io/rdf-mongo
516523
[RDF::Sesame]: https://ruby-rdf.github.io/rdf-sesame

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.2
1+
3.3.3

lib/rdf/mixin/enumerable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def to_a
8484
# * `:validity` allows a concrete Enumerable implementation to indicate that it does or does not support valididty checking. By default implementations are assumed to support validity checking.
8585
# * `:skolemize` supports [Skolemization](https://www.w3.org/wiki/BnodeSkolemization) of an `Enumerable`. Implementations supporting this feature must implement a `#skolemize` method, taking a base URI used for minting URIs for BNodes as stable identifiers and a `#deskolemize` method, also taking a base URI used for turning URIs having that prefix back into the same BNodes which were originally skolemized.
8686
# * `:rdf_full` supports RDF 1.2 Full profile, including support for embedded Triple Terms.
87-
# * `:quoted_triples` supports RDF-star quoted triples.
87+
# * `:quoted_triples` supports RDF-star quoted triples. (DEPRECATED)
8888
# * `:base_direction` supports RDF 1.2 directional language-tagged strings.
8989
#
9090
# @param [Symbol, #to_sym] feature

lib/rdf/model/graph.rb

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module RDF
2020
#
2121
# @example Loading graph data from a URL
2222
# require 'rdf/rdfxml' # for RDF/XML support
23-
#
23+
#
2424
# graph = RDF::Graph.load("http://www.bbc.co.uk/programmes/b0081dq5.rdf")
2525
#
2626
# @example Accessing a specific named graph within a {RDF::Repository}
@@ -250,6 +250,36 @@ def statement?(*args)
250250
end
251251
alias_method :has_statement?, :statement?
252252

253+
##
254+
# Returns `true` if `self` contains the given RDF subject term.
255+
#
256+
# @param [RDF::Resource] value
257+
# @return [Boolean]
258+
def subject? value
259+
!@data.query({ subject: value, graph_name: graph_name || false }).empty?
260+
end
261+
alias_method :has_subject?, :subject?
262+
263+
##
264+
# Returns `true` if `self` contains the given RDF predicate term.
265+
#
266+
# @param [RDF::URI] value
267+
# @return [Boolean]
268+
def predicate? value
269+
!@data.query({ predicate: value, graph_name: graph_name || false }).empty?
270+
end
271+
alias_method :has_predicate?, :predicate?
272+
273+
##
274+
# Returns `true` if `self` contains the given RDF object term.
275+
#
276+
# @param [RDF::Term] value
277+
# @return [Boolean]
278+
def object? value
279+
!@data.query({ object: value, graph_name: graph_name || false }).empty?
280+
end
281+
alias_method :has_object?, :object?
282+
253283
##
254284
# Enumerates each RDF statement in this graph.
255285
#

lib/rdf/model/literal/date.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def initialize(value, datatype: nil, lexical: nil, **options)
2626
# Use midnight as midpoint of the interval
2727
::DateTime.parse(value.strftime('%FT00:00:00'))
2828
when value.respond_to?(:to_datetime)
29-
dt = value.to_datetime
30-
@zone = dt.zone
31-
dt
29+
value.to_datetime
3230
else
3331
md = value.to_s.match(GRAMMAR)
3432
_, dt, tz = Array(md)

lib/rdf/model/literal/decimal.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ module RDF; class Literal
1212
# @since 0.2.1
1313
class Decimal < Numeric
1414
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#decimal")
15-
GRAMMAR = /^[\+\-]?\d+(\.\d*)?$/.freeze
15+
GRAMMAR = /^[\+\-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))$/.freeze
1616

1717
##
18-
# @param [String, BidDecimal, Numeric] value
18+
# @param [String, BigDecimal, Numeric] value
1919
# @param (see Literal#initialize)
2020
def initialize(value, datatype: nil, lexical: nil, **options)
2121
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))

lib/rdf/model/literal/double.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module RDF; class Literal
1212
# @since 0.2.1
1313
class Double < Numeric
1414
DATATYPE = RDF::URI("http://www.w3.org/2001/XMLSchema#double")
15-
GRAMMAR = /^(?:NaN|\-?INF|[+\-]?(?:\d+(:?\.\d*)?|\.\d+)(?:[eE][\+\-]?\d+)?)$/.freeze
15+
GRAMMAR = /^(?:NaN|[+\-]?INF|[+\-]?(?:\d+(:?\.\d*)?|\.\d+)(?:[eE][\+\-]?\d+)?)$/.freeze
1616

1717
##
1818
# @param [String, Float, #to_f] value
@@ -26,7 +26,7 @@ def initialize(value, datatype: nil, lexical: nil, **options)
2626
when 'INF' then 1/0.0
2727
when '-INF' then -1/0.0
2828
when 'NAN' then 0/0.0
29-
else Float(value.sub(/\.[eE]/, '.0E')) rescue nil
29+
else Float(value.sub(/\.[eE]/, '.0E').sub(/\.$/, '.0')) rescue nil
3030
end
3131
when value.is_a?(::Float) then value
3232
when value.respond_to?(:to_f) then value.to_f

lib/rdf/model/statement.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def to_h(subject_key = :subject, predicate_key = :predicate, object_key = :objec
476476
def to_s
477477
(graph_name ? to_quad : to_triple).map do |term|
478478
if term.is_a?(Statement)
479-
"<<#{term.to_s[0..-3]}>>"
479+
"<<(#{term.to_s[0..-3]})>>"
480480
elsif term.respond_to?(:to_base)
481481
term.to_base
482482
else

0 commit comments

Comments
 (0)