Skip to content

Commit b3a258f

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

33 files changed

Lines changed: 275 additions & 167 deletions

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.

0 commit comments

Comments
 (0)