Skip to content

Commit b3a258f

Browse files
committed
Finish 3.1.10
2 parents e3c20c8 + 5251d69 commit b3a258f

33 files changed

+275
-167
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ group :test do
3232
gem "equivalent-xml"
3333
gem 'fasterer'
3434
gem 'simplecov', require: false, platforms: :mri
35-
gem 'coveralls', require: false, platforms: :mri
35+
gem 'coveralls', '~> 0.8', require: false, platforms: :mri
3636
end

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This is a pure-Ruby library for working with [Resource Description Framework
77

88
[![Gem Version](https://badge.fury.io/rb/rdf.png)](https://badge.fury.io/rb/rdf)
99
[![Build Status](https://github.com/ruby-rdf/rdf/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf/actions?query=workflow%3ACI)
10-
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf/badge.svg)](https://coveralls.io/github/ruby-rdf/rdf)
10+
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf/badge.svg?branch=develop)](https://coveralls.io/github/ruby-rdf/rdf?branch=develop)
1111
[![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
1212

1313
## Features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.9
1+
3.1.10

etc/n-triples-star.ebnf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?
2+
[2] triple ::= subject predicate object '.'
3+
[3] subject ::= IRIREF | BLANK_NODE_LABEL | embTriple
4+
[4] predicate ::= IRIREF
5+
[5] object ::= IRIREF | BLANK_NODE_LABEL | literal | embTriple
6+
[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?
7+
[7] embTriple ::= '<<' subject predicate object '>>'

etc/n-triples.ebnf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?
2+
[2] triple ::= subject predicate object '.'
3+
[3] subject ::= IRIREF | BLANK_NODE_LABEL
4+
[4] predicate ::= IRIREF
5+
[5] object ::= IRIREF | BLANK_NODE_LABEL | literal
6+
[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?

lib/rdf/cli.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def to_hash
333333

334334
# Add format-specific reader options
335335
reader.options.each do |cli_opt|
336-
next if options.options.has_key?(cli_opt.symbol)
336+
next if options.options.key?(cli_opt.symbol)
337337
on_args = cli_opt.on || []
338338
on_args << cli_opt.description if cli_opt.description
339339
options.on(*on_args) do |opt_arg|
@@ -355,7 +355,7 @@ def to_hash
355355

356356
# Add format-specific writer options
357357
writer.options.each do |cli_opt|
358-
next if options.options.has_key?(cli_opt.symbol)
358+
next if options.options.key?(cli_opt.symbol)
359359
on_args = cli_opt.on || []
360360
on_args << cli_opt.description if cli_opt.description
361361
options.on(*on_args) do |opt_arg|
@@ -419,7 +419,7 @@ def self.options(argv, format: nil)
419419
end
420420

421421
cli_opts.each do |cli_opt|
422-
next if opts.has_key?(cli_opt.symbol)
422+
next if opts.key?(cli_opt.symbol)
423423
on_args = cli_opt.on || []
424424
on_args << cli_opt.description if cli_opt.description
425425
options.on(*on_args) do |arg|

lib/rdf/mixin/enumerable.rb

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ module RDF
1212
# enumerable.count
1313
#
1414
# @example Checking whether a specific statement exists
15-
# enumerable.has_statement?(RDF::Statement(subject, predicate, object))
16-
# enumerable.has_triple?([subject, predicate, object])
17-
# enumerable.has_quad?([subject, predicate, object, graph_name])
15+
# enumerable.statement?(RDF::Statement(subject, predicate, object))
16+
# enumerable.triple?([subject, predicate, object])
17+
# enumerable.quad?([subject, predicate, object, graph_name])
1818
#
1919
# @example Checking whether a specific value exists
20-
# enumerable.has_subject?(RDF::URI("https://rubygems.org/gems/rdf"))
21-
# enumerable.has_predicate?(RDF::RDFS.label)
22-
# enumerable.has_object?(RDF::Literal("A Ruby library for working with Resource Description Framework (RDF) data.", language: :en))
23-
# enumerable.has_graph?(RDF::URI("http://ar.to/#self"))
20+
# enumerable.subject?(RDF::URI("https://rubygems.org/gems/rdf"))
21+
# enumerable.predicate?(RDF::RDFS.label)
22+
# enumerable.object?(RDF::Literal("A Ruby library for working with Resource Description Framework (RDF) data.", language: :en))
23+
# enumerable.graph?(RDF::URI("http://ar.to/#self"))
2424
#
2525
# @example Enumerating all statements
2626
# enumerable.each_statement do |statement|
@@ -127,14 +127,20 @@ def statements(**options)
127127
end
128128

129129
##
130-
# Returns `true` if `self` contains the given RDF statement.
130+
# @overload statement?
131+
# Returns `false` indicating this is not an RDF::Statemenet.
132+
# @return [Boolean]
133+
# @see RDF::Value#statement?
134+
# @overload statement?(statement)
135+
# Returns `true` if `self` contains the given RDF statement.
131136
#
132-
# @param [RDF::Statement] statement
133-
# @return [Boolean]
134-
def has_statement?(statement)
135-
!enum_statement.find { |s| s.eql?(statement) }.nil?
137+
# @param [RDF::Statement] statement
138+
# @return [Boolean]
139+
def statement?(statement = nil)
140+
statement && !enum_statement.find { |s| s.eql?(statement) }.nil?
136141
end
137-
alias_method :include?, :has_statement?
142+
alias_method :has_statement?, :statement?
143+
alias_method :include?, :statement?
138144

139145
##
140146
# Iterates the given block for each RDF statement.
@@ -194,9 +200,10 @@ def triples(**options)
194200
#
195201
# @param [Array(RDF::Resource, RDF::URI, RDF::Term)] triple
196202
# @return [Boolean]
197-
def has_triple?(triple)
203+
def triple?(triple)
198204
triples.include?(triple)
199205
end
206+
alias_method :has_triple?, :triple?
200207

201208
##
202209
# Iterates the given block for each RDF triple.
@@ -255,9 +262,10 @@ def quads(**options)
255262
#
256263
# @param [Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)] quad
257264
# @return [Boolean]
258-
def has_quad?(quad)
265+
def quad?(quad)
259266
quads.include?(quad)
260267
end
268+
alias_method :has_quad?, :quad?
261269

262270
##
263271
# Iterates the given block for each RDF quad.
@@ -321,9 +329,10 @@ def subjects(unique: true)
321329
#
322330
# @param [RDF::Resource] value
323331
# @return [Boolean]
324-
def has_subject?(value)
332+
def subject?(value)
325333
enum_subject.include?(value)
326334
end
335+
alias_method :has_subject?, :subject?
327336

328337
##
329338
# Iterates the given block for each unique RDF subject term.
@@ -386,9 +395,10 @@ def predicates(unique: true)
386395
#
387396
# @param [RDF::URI] value
388397
# @return [Boolean]
389-
def has_predicate?(value)
398+
def predicate?(value)
390399
enum_predicate.include?(value)
391400
end
401+
alias_method :has_predicate?, :predicate?
392402

393403
##
394404
# Iterates the given block for each unique RDF predicate term.
@@ -451,9 +461,10 @@ def objects(unique: true)
451461
#
452462
# @param [RDF::Term] value
453463
# @return [Boolean]
454-
def has_object?(value)
464+
def object?(value)
455465
enum_object.include?(value)
456466
end
467+
alias_method :has_object?, :object?
457468

458469
##
459470
# Iterates the given block for each unique RDF object term.
@@ -511,7 +522,7 @@ def enum_object
511522
def terms(unique: true)
512523
unless unique
513524
enum_statement.
514-
map(&:to_quad).
525+
map(&:terms).
515526
flatten.
516527
compact
517528
else
@@ -520,14 +531,20 @@ def terms(unique: true)
520531
end
521532

522533
##
523-
# Returns `true` if `self` contains the given RDF subject term.
534+
# @overload term?
535+
# Returns `false` indicating this is not an RDF::Statemenet.
536+
# @see RDF::Value#statement?
537+
# @return [Boolean]
538+
# @overload term?(value)
539+
# Returns `true` if `self` contains the given RDF subject term.
524540
#
525-
# @param [RDF::Resource] value
526-
# @return [Boolean]
527-
# @since 2.0
528-
def has_term?(value)
529-
enum_term.include?(value)
541+
# @param [RDF::Resource] value
542+
# @return [Boolean]
543+
# @since 2.0
544+
def term?(value = nil)
545+
value && enum_term.include?(value)
530546
end
547+
alias_method :has_term?, :term?
531548

532549
##
533550
# Iterates the given block for each unique RDF term (subject, predicate, object, or graph_name).
@@ -551,8 +568,8 @@ def each_term
551568
if block_given?
552569
values = {}
553570
each_statement do |statement|
554-
statement.to_quad.each do |value|
555-
unless value.nil? || values.include?(value.hash)
571+
statement.terms.each do |value|
572+
unless values.include?(value.hash)
556573
values[value.hash] = true
557574
yield value
558575
end
@@ -595,9 +612,10 @@ def graph_names(unique: true)
595612
# @param [RDF::Resource, false] graph_name
596613
# Use value `false` to query for the default graph_name
597614
# @return [Boolean]
598-
def has_graph?(graph_name)
615+
def graph?(graph_name)
599616
enum_statement.any? {|s| s.graph_name == graph_name}
600617
end
618+
alias_method :has_graph?, :graph?
601619

602620
##
603621
# Limits statements to be from a specific graph.

lib/rdf/mixin/mutable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def update(*statements)
122122

123123
statements.each do |statement|
124124
if (statement = Statement.from(statement))
125-
if statement.has_object?
125+
if statement.object?
126126
delete_insert([[statement.subject, statement.predicate, nil]], [statement])
127127
else
128128
delete([statement.subject, statement.predicate, nil])

lib/rdf/model/dataset.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def isolation_level
104104
# @private
105105
# @see RDF::Enumerable#supports?
106106
def supports?(feature)
107-
return true if [:graph_name, :rdfstar].include?(feature)
107+
return true if %i(graph_name rdfstar).include?(feature)
108108
super
109109
end
110110

lib/rdf/model/graph.rb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,25 @@ def count
215215
end
216216

217217
##
218-
# Returns `true` if this graph contains the given RDF statement.
218+
# @overload statement?
219+
# Returns `false` indicating this is not an RDF::Statemenet.
220+
# @see RDF::Value#statement?
221+
# @return [Boolean]
222+
# @overload statement?(statement)
223+
# Returns `true` if this graph contains the given RDF statement.
219224
#
220-
# A statement is in a graph if the statement if it has the same triples without regard to graph_name.
225+
# A statement is in a graph if the statement if it has the same triples without regard to graph_name.
221226
#
222-
# @param [Statement] statement
223-
# @return [Boolean]
224-
# @see RDF::Enumerable#has_statement?
225-
def has_statement?(statement)
227+
# @param [Statement] statement
228+
# @return [Boolean]
229+
# @see RDF::Enumerable#statement?
230+
def statement?(statement = nil)
231+
return false if statement.nil?
226232
statement = statement.dup
227233
statement.graph_name = graph_name
228-
@data.has_statement?(statement)
234+
@data.statement?(statement)
229235
end
236+
alias_method :has_statement?, :statement?
230237

231238
##
232239
# Enumerates each RDF statement in this graph.

lib/rdf/model/literal.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module RDF
2525
#
2626
# @example Creating a language-tagged literal (1)
2727
# value = RDF::Literal.new("Hello!", language: :en)
28-
# value.has_language? #=> true
28+
# value.language? #=> true
2929
# value.language #=> :en
3030
#
3131
# @example Creating a language-tagged literal (2)
@@ -35,12 +35,12 @@ module RDF
3535
#
3636
# @example Creating an explicitly datatyped literal
3737
# value = RDF::Literal.new("2009-12-31", datatype: RDF::XSD.date)
38-
# value.has_datatype? #=> true
38+
# value.datatype? #=> true
3939
# value.datatype #=> RDF::XSD.date
4040
#
4141
# @example Creating an implicitly datatyped literal
4242
# value = RDF::Literal.new(Date.today)
43-
# value.has_datatype? #=> true
43+
# value.datatype? #=> true
4444
# value.datatype #=> RDF::XSD.date
4545
#
4646
# @example Creating implicitly datatyped literals
@@ -225,7 +225,7 @@ def compatible?(other)
225225
# * The arguments are simple literals or literals typed as xsd:string
226226
# * The arguments are plain literals with identical language tags
227227
# * 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-
has_language? ?
228+
language? ?
229229
(language == other.language || other.datatype == RDF::URI("http://www.w3.org/2001/XMLSchema#string")) :
230230
other.datatype == RDF::URI("http://www.w3.org/2001/XMLSchema#string")
231231
end
@@ -289,7 +289,7 @@ def ==(other)
289289
case
290290
when self.eql?(other)
291291
true
292-
when self.has_language? && self.language.to_s == other.language.to_s
292+
when self.language? && self.language.to_s == other.language.to_s
293293
# Literals with languages can compare if languages are identical
294294
self.value_hash == other.value_hash && self.value == other.value
295295
when self.simple? && other.simple?
@@ -335,10 +335,10 @@ def simple?
335335
#
336336
# @return [Boolean] `true` or `false`
337337
# @see http://www.w3.org/TR/rdf-concepts/#dfn-plain-literal
338-
def has_language?
338+
def language?
339339
datatype == RDF.langString
340340
end
341-
alias_method :language?, :has_language?
341+
alias_method :has_language?, :language?
342342

343343
##
344344
# Returns `true` if this is a datatyped literal.
@@ -347,12 +347,12 @@ def has_language?
347347
#
348348
# @return [Boolean] `true` or `false`
349349
# @see http://www.w3.org/TR/rdf-concepts/#dfn-typed-literal
350-
def has_datatype?
350+
def datatype?
351351
!plain? && !language?
352352
end
353-
alias_method :datatype?, :has_datatype?
354-
alias_method :typed?, :has_datatype?
355-
alias_method :datatyped?, :has_datatype?
353+
alias_method :has_datatype?, :datatype?
354+
alias_method :typed?, :datatype?
355+
alias_method :datatyped?, :datatype?
356356

357357
##
358358
# Returns `true` if the value adheres to the defined grammar of the
@@ -386,16 +386,16 @@ def validate!
386386
# This behavior is intuited from SPARQL data-r2/expr-equal/eq-2-2
387387
# @return [Boolean]
388388
def comperable_datatype?(other)
389-
return false unless self.plain? || self.has_language?
389+
return false unless self.plain? || self.language?
390390

391391
case other
392392
when RDF::Literal::Numeric, RDF::Literal::Boolean,
393393
RDF::Literal::Date, RDF::Literal::Time, RDF::Literal::DateTime
394394
# Invald types can be compared without raising a TypeError if literal has a language (open-eq-08)
395-
!other.valid? && self.has_language?
395+
!other.valid? && self.language?
396396
else
397397
# An unknown datatype may not be used for comparison, unless it has a language? (open-eq-8)
398-
self.has_language?
398+
self.language?
399399
end
400400
end
401401

lib/rdf/model/literal/date.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ def valid?
5151
#
5252
# @return [Boolean]
5353
# @since 1.1.6
54-
def has_timezone?
54+
def timezone?
5555
md = self.to_s.match(GRAMMAR)
5656
md && !!md[2]
5757
end
58-
alias_method :has_tz?, :has_timezone?
58+
alias_method :tz?, :timezone?
59+
alias_method :has_tz?, :timezone?
60+
alias_method :has_timezone?, :timezone?
5961

6062
##
6163
# Returns the value as a string.
@@ -72,7 +74,7 @@ def to_s
7274
# @since 1.1.6
7375
def humanize(lang = :en)
7476
d = object.strftime("%A, %d %B %Y")
75-
if has_timezone?
77+
if timezone?
7678
d += if self.tz == 'Z'
7779
" UTC"
7880
else

0 commit comments

Comments
 (0)