rdf 3.1.6 → 3.1.11

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: 4a2f065f2ef318b5183512ee7cbe816d3c86cf497a1822d886d1a5cb12ae7c7c
4
- data.tar.gz: b51e9e8d120f8441da1cc4478a4a8bf470010cd8009eef992fb91d39fce2aeea
3
+ metadata.gz: fb4903dd836362f2ba5883f4af56b2276d879e60c0be2b740fcfd946c2b9bc29
4
+ data.tar.gz: e0abcd40f798fa08955649dda90a53f10e775d74d95f4fbbb7680cb8223594a8
5
5
  SHA512:
6
- metadata.gz: efe71f0a3278321dacffe85afac3b9fad8fd9c0be2736689ced8fcfa27164cf1f9a0221438c851fe8d61f375889ab6ca124f026a6a675b64b38792aa5c9f7e91
7
- data.tar.gz: c9228398f6a2e3236bdfc878bbe083713648acee8e26c72a1bed358deea5041420667167976607b2942f24b026ab3d6aae03c046632ca41e6fa9760f997d752e
6
+ metadata.gz: fa91bd5cc0daa34b2055bf0504dd05a67ad433320d316247eee7ecc7e34c4b26a60be3dd944f2b480a3282b6f1175b4af03a740a6697d5a1848e14279093d025
7
+ data.tar.gz: b30eea12865c58960d3ee942ff89e6e0cfb1b5bc3d1cc66187356709c389450c03e1d397715c4a807902deacfd10916a1db7c054f03ed289253986b42fefc0e3
data/README.md CHANGED
@@ -6,9 +6,29 @@ This is a pure-Ruby library for working with [Resource Description Framework
6
6
  * <https://ruby-rdf.github.com/rdf>
7
7
 
8
8
  [![Gem Version](https://badge.fury.io/rb/rdf.png)](https://badge.fury.io/rb/rdf)
9
- [![Build Status](https://travis-ci.org/ruby-rdf/rdf.png?branch=master)](https://travis-ci.org/ruby-rdf/rdf)
10
- [![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf/badge.svg)](https://coveralls.io/r/ruby-rdf/rdf)
11
- [![Join the chat at https://gitter.im/ruby-rdf/rdf](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ruby-rdf/rdf?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
9
+ [![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?branch=develop)](https://coveralls.io/github/ruby-rdf/rdf?branch=develop)
11
+ [![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
12
+
13
+ ## Table of contents
14
+
15
+ 1. [Features](#features)
16
+ 2. [Differences between RDF 1.0 and RDF 1.1](#differences-between-rdf-1-0-and-rdf-1-1)
17
+ 3. [Tutorials](#tutorials)
18
+ 4. [Command Line](#command-line)
19
+ 5. [Examples](#examples)
20
+ 6. [Reader/Writer convenience methods](#reader/writer-convenience-methods)
21
+ 7. [RDF* (RDFStar)](#rdf*-(rdfstar))
22
+ 8. [Documentation](#documentation)
23
+ 9. [Dependencies](#dependencies)
24
+ 10. [Installation](#installation)
25
+ 11. [Download](#download)
26
+ 12. [Resources](#resources)
27
+ 13. [Mailing List](#mailing-list)
28
+ 14. [Authors](#authors)
29
+ 15. [Contributors](#contributors)
30
+ 16. [Contributing](#contributing)
31
+ 17. [License](#license)
12
32
 
13
33
  ## Features
14
34
 
@@ -39,6 +59,22 @@ resources. Clients may also consider using [RestClient Components][] to enable
39
59
  client-side caching of HTTP results using [Rack::Cache][] or other Rack
40
60
  middleware.
41
61
 
62
+ See {RDF::Util::File} for configuring other mechanisms for retrieving resources.
63
+
64
+ ### Term caching and configuration
65
+
66
+ RDF.rb uses a weak-reference cache for storing internalized versions of URIs and Nodes. This is particularly useful for Nodes as two nodes are equivalent only if they're the same node.
67
+
68
+ By default, each cache can grow to an unlimited size, but this can be configured using {RDF.config}, for general limits, along with URI- or Node-specific limits.
69
+
70
+ For example, to limit the size of the URI intern cache only:
71
+
72
+ RDF.config.uri_cache_size = 10_000
73
+
74
+ The default for creating new caches without a specific initialization size can be set using:
75
+
76
+ RDF.config.cache_size = 100_000
77
+
42
78
  ## Differences between RDF 1.0 and RDF 1.1
43
79
 
44
80
  This version of RDF.rb is fully compatible with [RDF 1.1][], but it creates some
@@ -60,7 +96,7 @@ the 1.1 release of RDF.rb:
60
96
  * {RDF::Util::File.open\_file} now performs redirects and manages `base_uri` based on W3C recommendations:
61
97
  * `base_uri` is set to the original URI if a status 303 is provided, otherwise any other redirect will set `base_uri` to the redirected location.
62
98
  * `base_uri` is set to the content of the `Location` header if status is _success_.
63
- * Additionally, {RDF::Util::File.open\_file} sets the result encoding from `charset` if provided, defaulting to `UTF-8`. Other access methods include `last_modified` and `content_type`,
99
+ * Additionally, {RDF::Util::File.open\_file} sets the result encoding from `charset` if provided, defaulting to `UTF-8`. Other access methods include `last_modified` and `content_type`,
64
100
  * {RDF::StrictVocabulary} added with an easy way to keep vocabulary definitions up to date based on their OWL or RDFS definitions. Most vocabularies are now StrictVocabularies meaning that an attempt to resolve a particular term in that vocabulary will error if the term is not defined in the vocabulary.
65
101
  * New vocabulary definitions have been added for [ICal](http://www.w3.org/2002/12/cal/icaltzd#), [Media Annotations (MA)](http://www.w3.org/ns/ma-ont#), [Facebook OpenGraph (OG)](http://ogp.me/ns#), [PROV](http://www.w3.org/ns/prov#), [SKOS-XL (SKOSXL)](http://www.w3.org/2008/05/skos-xl#), [Data Vocabulary (V)](http://rdf.data-vocabulary.org/), [VCard](http://www.w3.org/2006/vcard/ns#), [VOID](http://rdfs.org/ns/void#http://rdfs.org/ns/void#), [Powder-S (WDRS)](http://www.w3.org/2007/05/powder-s#), and [XHV](http://www.w3.org/1999/xhtml/vocab#).
66
102
 
@@ -73,6 +109,7 @@ Notably, {RDF::Queryable#query} and {RDF::Query#execute} are now completely symm
73
109
  * [Getting started with RDF and SPARQL using 4store and RDF.rb](https://www.jenitennison.com/blog/node/152)
74
110
 
75
111
  ## Command Line
112
+
76
113
  When installed, RDF.rb includes a `rdf` shell script which acts as a wrapper to perform a number of different
77
114
  operations on RDF files using available readers and writers.
78
115
 
@@ -96,7 +133,7 @@ Different RDF gems will augment the `rdf` script with more capabilities, which m
96
133
  require 'rdf/ntriples'
97
134
  graph = RDF::Graph.new << [:hello, RDF::RDFS.label, "Hello, world!"]
98
135
  graph.dump(:ntriples)
99
-
136
+
100
137
  or
101
138
 
102
139
  RDF::Writer.open("hello.nt") { |writer| writer << graph }
@@ -105,7 +142,7 @@ or
105
142
 
106
143
  require 'rdf/ntriples'
107
144
  graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nt")
108
-
145
+
109
146
  or
110
147
 
111
148
  RDF::Reader.open("https://ruby-rdf.github.com/rdf/etc/doap.nt") do |reader|
@@ -115,19 +152,20 @@ or
115
152
  end
116
153
 
117
154
  ### Reading RDF data in other formats
155
+
118
156
  {RDF::Reader.open} and {RDF::Repository.load} use a number of mechanisms to determine the appropriate reader
119
157
  to use when loading a file. The specific format to use can be forced using, e.g. `format: :ntriples`
120
158
  option where the specific format symbol is determined by the available readers. Both also use
121
159
  MimeType or file extension, where available.
122
160
 
123
161
  require 'rdf/nquads'
124
-
162
+
125
163
  graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nq", format: :nquads)
126
164
 
127
165
  A specific sub-type of Reader can also be invoked directly:
128
166
 
129
167
  require 'rdf/nquads'
130
-
168
+
131
169
  RDF::NQuads::Reader.open("https://ruby-rdf.github.com/rdf/etc/doap.nq") do |reader|
132
170
  reader.each_statement do |statement|
133
171
  puts statement.inspect
@@ -141,6 +179,7 @@ be detected from filename or other options, or that more than one format is iden
141
179
  match will be used to read the input.
142
180
 
143
181
  ### Writing RDF data using other formats
182
+
144
183
  {RDF::Writer.open}, {RDF::Enumerable#dump}, {RDF::Writer.dump} take similar options to {RDF::Reader.open} to determine the
145
184
  appropriate writer to use.
146
185
 
@@ -160,6 +199,7 @@ A specific sub-type of Writer can also be invoked directly:
160
199
  File.open("hello.nq", "w") {|f| f << repo.dump(:nquads)}
161
200
 
162
201
  ## Reader/Writer convenience methods
202
+
163
203
  {RDF::Enumerable} implements `to_{format}` for each available instance of {RDF::Reader}.
164
204
  For example, if `rdf/turtle` is loaded, this allows the following:
165
205
 
@@ -179,7 +219,7 @@ Note that no prefixes are loaded automatically, however they can be provided as
179
219
  ### Querying RDF data using basic graph patterns (BGPs)
180
220
 
181
221
  require 'rdf/ntriples'
182
-
222
+
183
223
  graph = RDF::Graph.load("https://ruby-rdf.github.com/rdf/etc/doap.nt")
184
224
  query = RDF::Query.new({
185
225
  person: {
@@ -188,7 +228,7 @@ Note that no prefixes are loaded automatically, however they can be provided as
188
228
  FOAF.mbox => :email,
189
229
  }
190
230
  }, **{})
191
-
231
+
192
232
  query.execute(graph) do |solution|
193
233
  puts "name=#{solution.name} email=#{solution.email}"
194
234
  end
@@ -246,17 +286,10 @@ By default, the N-Triples reader will reject a document containing a subject res
246
286
  end
247
287
  # => RDF::ReaderError
248
288
 
249
- Readers support a `rdfstar` option with either `:PG` (Property Graph) or `:SA` (Separate Assertions) modes. In `:PG` mode, statements that are used in the subject or object positions are also implicitly added to the graph:
250
-
251
- graph = RDF::Graph.new do |graph|
252
- RDF::NTriples::Reader.new(nt, rdfstar: :PG) {|reader| graph << reader}
253
- end
254
- graph.count #=> 2
255
-
256
- When using the `:SA` mode, only one statement is asserted, although the reified statement is contained within the graph.
289
+ Readers support a boolean valued `rdfstar` option.
257
290
 
258
291
  graph = RDF::Graph.new do |graph|
259
- RDF::NTriples::Reader.new(nt, rdfstar: :SA) {|reader| graph << reader}
292
+ RDF::NTriples::Reader.new(nt, rdfstar: true) {|reader| graph << reader}
260
293
  end
261
294
  graph.count #=> 1
262
295
 
@@ -438,7 +471,9 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
438
471
  enough, be assured we will eventually add you in there.
439
472
  * Do note that in order for us to merge any non-trivial changes (as a rule
440
473
  of thumb, additions larger than about 15 lines of code), we need an
441
- explicit [public domain dedication][PDD] on record from you.
474
+ explicit [public domain dedication][PDD] on record from you,
475
+ which you will be asked to agree to on the first commit to a repo within the organization.
476
+ Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
442
477
 
443
478
  ## License
444
479
 
@@ -450,7 +485,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
450
485
  [N-Quads]: https://www.w3.org/TR/n-quads/
451
486
  [YARD]: https://yardoc.org/
452
487
  [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
453
- [PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
488
+ [PDD]: https://unlicense.org/#unlicensing-contributions
454
489
  [JSONLD doc]: https://rubydoc.info/github/ruby-rdf/json-ld
455
490
  [LinkedData doc]: https://rubydoc.info/github/ruby-rdf/linkeddata
456
491
  [Microdata doc]: https://rubydoc.info/github/ruby-rdf/rdf-microdata
@@ -475,9 +510,9 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
475
510
  [RDF::TriX]: https://ruby-rdf.github.com/rdf-trix
476
511
  [RDF::Turtle]: https://ruby-rdf.github.com/rdf-turtle
477
512
  [RDF::Raptor]: https://ruby-rdf.github.com/rdf-raptor
478
- [RDF*]: https://lists.w3.org/Archives/Public/public-rdf-star/
513
+ [RDF*]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html
479
514
  [LinkedData]: https://ruby-rdf.github.com/linkeddata
480
515
  [JSON::LD]: https://ruby-rdf.github.com/json-ld
481
516
  [RestClient]: https://rubygems.org/gems/rest-client
482
517
  [RestClient Components]: https://rubygems.org/gems/rest-client-components
483
- [Rack::Cache]: https://rtomayko.github.io/rack-cache/
518
+ [Rack::Cache]: https://rtomayko.github.io/rack-cache/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.6
1
+ 3.1.11
data/lib/rdf.rb CHANGED
@@ -2,6 +2,7 @@ require 'stringio'
2
2
  require 'bigdecimal'
3
3
  require 'date'
4
4
  require 'time'
5
+ require "ostruct"
5
6
 
6
7
  require 'rdf/version'
7
8
  require 'rdf/extensions'
@@ -79,6 +80,29 @@ module RDF
79
80
  # CLI
80
81
  autoload :CLI, 'rdf/cli'
81
82
 
83
+ ##
84
+ # Configuration, used open for configuring constants used within the codebase.
85
+ #
86
+ # @example set default cache size to be at most 10,000 entries
87
+ #
88
+ # RDF.config.cache_size = 10_000
89
+ #
90
+ # @example set cache size for interned URIs to 5,000 entries
91
+ #
92
+ # RDF.config.uri_cache_size = 5_000
93
+ #
94
+ # Defaults:
95
+ # * `cache_size`: -1
96
+ # * `uri_cache_size`: `cache_size`
97
+ # * `node_cache_size`: `cache_size`
98
+ #
99
+ # @note cache configurations must be set before initial use, when the caches are allocated.
100
+ # @see RDF::Util::Cache.new
101
+ # @return [Object]
102
+ def self.config
103
+ @config ||= OpenStruct.new(cache_size: -1, uri_cache_size: nil, node_cache_size: nil)
104
+ end
105
+
82
106
  ##
83
107
  # Alias for `RDF::Resource.new`.
84
108
  #
data/lib/rdf/cli.rb CHANGED
@@ -8,9 +8,26 @@ begin
8
8
  require 'linkeddata'
9
9
  rescue LoadError
10
10
  # Silently load without linkeddata, but try some others
11
- %w(microdata n3 rdfa rdfxml reasoner tabular trig trix turtle vocab xsd json/ld ld/patch).each do |ser|
11
+ %w(
12
+ json/ld
13
+ ld/patch
14
+ rdf/microdata
15
+ rdf/n3
16
+ rdf/ordered_repo
17
+ rdf/rdfa
18
+ rdf/rdfxml
19
+ rdf/reasoner
20
+ rdf/tabular
21
+ rdf/trig
22
+ rdf/trix
23
+ rdf/turtle
24
+ rdf/vocab
25
+ rdf/xsd
26
+ shacl
27
+ shex
28
+ ).each do |ser|
12
29
  begin
13
- require ser.include?('/') ? ser : "rdf/#{ser}"
30
+ require ser
14
31
  rescue LoadError
15
32
  end
16
33
  end
@@ -162,6 +179,7 @@ module RDF
162
179
  # * `lambda` code run to execute command.
163
180
  # * `filter` Option values that must match for command to be used
164
181
  # * `control` Used to indicate how (if) command is displayed
182
+ # * `repository` Use this repository, if set
165
183
  # * `options` an optional array of `RDF::CLI::Option` describing command-specific options.
166
184
  # * `option_use`: A hash of option symbol to option usage, used for overriding the default status of an option for this command.
167
185
  # @return [Hash{Symbol => Hash{Symbol => Object}}]
@@ -315,7 +333,7 @@ module RDF
315
333
 
316
334
  # Add format-specific reader options
317
335
  reader.options.each do |cli_opt|
318
- next if options.options.has_key?(cli_opt.symbol)
336
+ next if options.options.key?(cli_opt.symbol)
319
337
  on_args = cli_opt.on || []
320
338
  on_args << cli_opt.description if cli_opt.description
321
339
  options.on(*on_args) do |opt_arg|
@@ -337,7 +355,7 @@ module RDF
337
355
 
338
356
  # Add format-specific writer options
339
357
  writer.options.each do |cli_opt|
340
- next if options.options.has_key?(cli_opt.symbol)
358
+ next if options.options.key?(cli_opt.symbol)
341
359
  on_args = cli_opt.on || []
342
360
  on_args << cli_opt.description if cli_opt.description
343
361
  options.on(*on_args) do |opt_arg|
@@ -401,7 +419,7 @@ module RDF
401
419
  end
402
420
 
403
421
  cli_opts.each do |cli_opt|
404
- next if opts.has_key?(cli_opt.symbol)
422
+ next if opts.key?(cli_opt.symbol)
405
423
  on_args = cli_opt.on || []
406
424
  on_args << cli_opt.description if cli_opt.description
407
425
  options.on(*on_args) do |arg|
@@ -456,7 +474,7 @@ module RDF
456
474
  # @param [Array<String>] args
457
475
  # @param [IO] output
458
476
  # @param [OptionParser] option_parser
459
- # @param [Hash{Symbol => Hash{Symbol => Array[String]}}] messages used for confeying non primary-output which is structured.
477
+ # @param [Hash{Symbol => Hash{Symbol => Array[String]}}] messages used for conveying non primary-output which is structured.
460
478
  # @param [Hash{Symbol => Object}] options
461
479
  # @return [Boolean]
462
480
  def self.exec(args, output: $stdout, option_parser: nil, messages: {}, **options)
@@ -493,6 +511,9 @@ module RDF
493
511
  raise ArgumentError, "Incompatible command #{c} used with option #{opt}=#{options[opt]}"
494
512
  end
495
513
  end
514
+
515
+ # The command may specify a repository instance to use
516
+ options[:repository] ||= COMMANDS[c.to_sym][:repository]
496
517
  end
497
518
 
498
519
  # Hacks for specific options
@@ -501,9 +522,13 @@ module RDF
501
522
  options[:format] = options[:format].to_sym if options[:format]
502
523
  options[:output_format] = options[:output_format].to_sym if options[:output_format]
503
524
 
504
- @repository = options[:ordered] ?
505
- [].extend(RDF::Enumerable, RDF::Queryable) :
506
- RDF::Repository.new
525
+ # Allow repository to be set via option.
526
+ # If RDF::OrderedRepo is present, use it if the `ordered` option is specified, otherwise extend an Array.
527
+ @repository = options[:repository] || case
528
+ when RDF.const_defined?(:OrderedRepo) then RDF::OrderedRepo.new
529
+ when options[:ordered] then [].extend(RDF::Enumerable, RDF::Queryable)
530
+ else RDF::Repository.new
531
+ end
507
532
 
508
533
  # Parse input files if any command requires it
509
534
  if cmds.any? {|c| COMMANDS[c.to_sym][:parse]}
@@ -518,7 +543,10 @@ module RDF
518
543
 
519
544
  # Run each command in sequence
520
545
  cmds.each do |command|
521
- COMMANDS[command.to_sym][:lambda].call(args, output: output, **options.merge(messages: messages))
546
+ COMMANDS[command.to_sym][:lambda].call(args,
547
+ output: output,
548
+ messages: messages,
549
+ **options.merge(repository: repository))
522
550
  end
523
551
 
524
552
  # Normalize messages
@@ -12,15 +12,15 @@ module RDF
12
12
  # enumerable.count
13
13
  #
14
14
  # @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])
18
18
  #
19
19
  # @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"))
24
24
  #
25
25
  # @example Enumerating all statements
26
26
  # enumerable.each_statement do |statement|
@@ -127,14 +127,20 @@ module RDF
127
127
  end
128
128
 
129
129
  ##
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.
131
136
  #
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?
136
141
  end
137
- alias_method :include?, :has_statement?
142
+ alias_method :has_statement?, :statement?
143
+ alias_method :include?, :statement?
138
144
 
139
145
  ##
140
146
  # Iterates the given block for each RDF statement.
@@ -194,9 +200,10 @@ module RDF
194
200
  #
195
201
  # @param [Array(RDF::Resource, RDF::URI, RDF::Term)] triple
196
202
  # @return [Boolean]
197
- def has_triple?(triple)
203
+ def triple?(triple)
198
204
  triples.include?(triple)
199
205
  end
206
+ alias_method :has_triple?, :triple?
200
207
 
201
208
  ##
202
209
  # Iterates the given block for each RDF triple.
@@ -255,9 +262,10 @@ module RDF
255
262
  #
256
263
  # @param [Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)] quad
257
264
  # @return [Boolean]
258
- def has_quad?(quad)
265
+ def quad?(quad)
259
266
  quads.include?(quad)
260
267
  end
268
+ alias_method :has_quad?, :quad?
261
269
 
262
270
  ##
263
271
  # Iterates the given block for each RDF quad.
@@ -321,9 +329,10 @@ module RDF
321
329
  #
322
330
  # @param [RDF::Resource] value
323
331
  # @return [Boolean]
324
- def has_subject?(value)
332
+ def subject?(value)
325
333
  enum_subject.include?(value)
326
334
  end
335
+ alias_method :has_subject?, :subject?
327
336
 
328
337
  ##
329
338
  # Iterates the given block for each unique RDF subject term.
@@ -386,9 +395,10 @@ module RDF
386
395
  #
387
396
  # @param [RDF::URI] value
388
397
  # @return [Boolean]
389
- def has_predicate?(value)
398
+ def predicate?(value)
390
399
  enum_predicate.include?(value)
391
400
  end
401
+ alias_method :has_predicate?, :predicate?
392
402
 
393
403
  ##
394
404
  # Iterates the given block for each unique RDF predicate term.
@@ -451,9 +461,10 @@ module RDF
451
461
  #
452
462
  # @param [RDF::Term] value
453
463
  # @return [Boolean]
454
- def has_object?(value)
464
+ def object?(value)
455
465
  enum_object.include?(value)
456
466
  end
467
+ alias_method :has_object?, :object?
457
468
 
458
469
  ##
459
470
  # Iterates the given block for each unique RDF object term.
@@ -511,7 +522,7 @@ module RDF
511
522
  def terms(unique: true)
512
523
  unless unique
513
524
  enum_statement.
514
- map(&:to_quad).
525
+ map(&:terms).
515
526
  flatten.
516
527
  compact
517
528
  else
@@ -520,14 +531,20 @@ module RDF
520
531
  end
521
532
 
522
533
  ##
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.
524
540
  #
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)
530
546
  end
547
+ alias_method :has_term?, :term?
531
548
 
532
549
  ##
533
550
  # Iterates the given block for each unique RDF term (subject, predicate, object, or graph_name).
@@ -551,8 +568,8 @@ module RDF
551
568
  if block_given?
552
569
  values = {}
553
570
  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)
556
573
  values[value.hash] = true
557
574
  yield value
558
575
  end
@@ -595,9 +612,10 @@ module RDF
595
612
  # @param [RDF::Resource, false] graph_name
596
613
  # Use value `false` to query for the default graph_name
597
614
  # @return [Boolean]
598
- def has_graph?(graph_name)
615
+ def graph?(graph_name)
599
616
  enum_statement.any? {|s| s.graph_name == graph_name}
600
617
  end
618
+ alias_method :has_graph?, :graph?
601
619
 
602
620
  ##
603
621
  # Limits statements to be from a specific graph.