rdf 1.99.1 → 2.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/{README → README.md} +9 -44
  3. data/VERSION +1 -1
  4. data/bin/rdf +1 -1
  5. data/lib/rdf.rb +40 -49
  6. data/lib/rdf/changeset.rb +161 -0
  7. data/lib/rdf/cli.rb +195 -33
  8. data/lib/rdf/cli/vocab-loader.rb +13 -3
  9. data/lib/rdf/format.rb +44 -26
  10. data/lib/rdf/mixin/enumerable.rb +133 -97
  11. data/lib/rdf/mixin/enumerator.rb +8 -0
  12. data/lib/rdf/mixin/indexable.rb +1 -1
  13. data/lib/rdf/mixin/mutable.rb +101 -22
  14. data/lib/rdf/mixin/queryable.rb +21 -32
  15. data/lib/rdf/mixin/transactable.rb +94 -0
  16. data/lib/rdf/mixin/writable.rb +12 -3
  17. data/lib/rdf/model/dataset.rb +48 -0
  18. data/lib/rdf/model/graph.rb +73 -43
  19. data/lib/rdf/model/list.rb +61 -33
  20. data/lib/rdf/model/literal.rb +20 -19
  21. data/lib/rdf/model/literal/double.rb +20 -4
  22. data/lib/rdf/model/literal/numeric.rb +15 -13
  23. data/lib/rdf/model/node.rb +15 -16
  24. data/lib/rdf/model/statement.rb +1 -43
  25. data/lib/rdf/model/term.rb +10 -8
  26. data/lib/rdf/model/uri.rb +35 -34
  27. data/lib/rdf/model/value.rb +1 -1
  28. data/lib/rdf/nquads.rb +2 -11
  29. data/lib/rdf/ntriples.rb +1 -1
  30. data/lib/rdf/ntriples/reader.rb +33 -46
  31. data/lib/rdf/ntriples/writer.rb +42 -5
  32. data/lib/rdf/query.rb +6 -40
  33. data/lib/rdf/query/pattern.rb +4 -17
  34. data/lib/rdf/query/solutions.rb +6 -6
  35. data/lib/rdf/reader.rb +65 -14
  36. data/lib/rdf/repository.rb +365 -229
  37. data/lib/rdf/transaction.rb +211 -84
  38. data/lib/rdf/util.rb +1 -0
  39. data/lib/rdf/util/cache.rb +5 -5
  40. data/lib/rdf/util/file.rb +12 -9
  41. data/lib/rdf/util/logger.rb +272 -0
  42. data/lib/rdf/version.rb +2 -2
  43. data/lib/rdf/vocab/owl.rb +82 -77
  44. data/lib/rdf/vocab/rdfs.rb +22 -17
  45. data/lib/rdf/vocab/xsd.rb +5 -0
  46. data/lib/rdf/vocabulary.rb +50 -56
  47. data/lib/rdf/writer.rb +104 -52
  48. metadata +45 -90
  49. data/lib/rdf/mixin/inferable.rb +0 -5
  50. data/lib/rdf/vocab/cc.rb +0 -128
  51. data/lib/rdf/vocab/cert.rb +0 -245
  52. data/lib/rdf/vocab/dc.rb +0 -948
  53. data/lib/rdf/vocab/dc11.rb +0 -167
  54. data/lib/rdf/vocab/dcat.rb +0 -214
  55. data/lib/rdf/vocab/doap.rb +0 -337
  56. data/lib/rdf/vocab/exif.rb +0 -941
  57. data/lib/rdf/vocab/foaf.rb +0 -614
  58. data/lib/rdf/vocab/geo.rb +0 -157
  59. data/lib/rdf/vocab/gr.rb +0 -1501
  60. data/lib/rdf/vocab/ht.rb +0 -236
  61. data/lib/rdf/vocab/ical.rb +0 -528
  62. data/lib/rdf/vocab/ma.rb +0 -513
  63. data/lib/rdf/vocab/mo.rb +0 -2412
  64. data/lib/rdf/vocab/og.rb +0 -222
  65. data/lib/rdf/vocab/ogc.rb +0 -58
  66. data/lib/rdf/vocab/prov.rb +0 -1550
  67. data/lib/rdf/vocab/rsa.rb +0 -72
  68. data/lib/rdf/vocab/rss.rb +0 -66
  69. data/lib/rdf/vocab/schema.rb +0 -10569
  70. data/lib/rdf/vocab/sioc.rb +0 -669
  71. data/lib/rdf/vocab/skos.rb +0 -238
  72. data/lib/rdf/vocab/skosxl.rb +0 -57
  73. data/lib/rdf/vocab/v.rb +0 -383
  74. data/lib/rdf/vocab/vcard.rb +0 -841
  75. data/lib/rdf/vocab/vmd.rb +0 -383
  76. data/lib/rdf/vocab/void.rb +0 -186
  77. data/lib/rdf/vocab/vs.rb +0 -28
  78. data/lib/rdf/vocab/wdrs.rb +0 -134
  79. data/lib/rdf/vocab/wot.rb +0 -167
  80. data/lib/rdf/vocab/xhtml.rb +0 -8
  81. data/lib/rdf/vocab/xhv.rb +0 -505
@@ -0,0 +1,48 @@
1
+ module RDF
2
+ ##
3
+ # An RDF Dataset
4
+ #
5
+ # Datasets are immutable by default. {RDF::Repository} provides an interface
6
+ # for mutable Datasets.
7
+ #
8
+ # @see https://www.w3.org/TR/rdf11-concepts/#section-dataset
9
+ # @see https://www.w3.org/TR/rdf11-datasets/
10
+ class Dataset
11
+ include RDF::Countable
12
+ include RDF::Enumerable
13
+ include RDF::Durable
14
+ include RDF::Queryable
15
+
16
+ ISOLATION_LEVELS = [ :read_uncommitted,
17
+ :read_committed,
18
+ :repeatable_read,
19
+ :snapshot,
20
+ :serializable].freeze
21
+
22
+ ##
23
+ # Returns a developer-friendly representation of this object.
24
+ #
25
+ # @return [String]
26
+ def inspect
27
+ sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, uri.to_s)
28
+ end
29
+
30
+ ##
31
+ # Outputs a developer-friendly representation of this object to
32
+ # `stderr`.
33
+ #
34
+ # @return [void]
35
+ def inspect!
36
+ each_statement { |statement| statement.inspect! }
37
+ nil
38
+ end
39
+
40
+ ##
41
+ # @return [Symbol] a representation of the isolation level for reads of this
42
+ # Dataset. One of `:read_uncommitted`, `:read_committed`, `:repeatable_read`,
43
+ # `:snapshot`, or `:serializable`.
44
+ def isolation_level
45
+ :read_committed
46
+ end
47
+ end
48
+ end
@@ -27,7 +27,7 @@ module RDF
27
27
  # require 'rdf/trig' # for TriG support
28
28
  #
29
29
  # repository = graph = RDF::Repository.load("https://raw.githubusercontent.com/ruby-rdf/rdf-trig/develop/etc/doap.trig", format: :trig))
30
- # graph = RDF::Graph.new(RDF::URI("http://greggkellogg.net/foaf#me"), data: repository)
30
+ # graph = RDF::Graph.new(graph_name: RDF::URI("http://greggkellogg.net/foaf#me"), data: repository)
31
31
  class Graph
32
32
  include RDF::Value
33
33
  include RDF::Countable
@@ -35,6 +35,7 @@ module RDF
35
35
  include RDF::Enumerable
36
36
  include RDF::Queryable
37
37
  include RDF::Mutable
38
+ include RDF::Transactable
38
39
 
39
40
  ##
40
41
  # Returns the options passed to this graph when it was constructed.
@@ -51,17 +52,7 @@ module RDF
51
52
  attr_accessor :graph_name
52
53
 
53
54
  alias_method :name, :graph_name
54
-
55
- ##
56
- # Name of this graph, if it is part of an {RDF::Repository}
57
- # @!attribute [rw] graph_name
58
- # @return [RDF::Resource]
59
- # @since 1.1.0
60
- # @deprecated Use {#graph_name} instead.
61
- def context
62
- warn "[DEPRECATION] Graph#context is being replaced with Graph@graph_name in RDF.rb 2.0. Called from #{Gem.location_of_caller.join(':')}"
63
- graph_name
64
- end
55
+ alias_method :name=, :graph_name=
65
56
 
66
57
  ##
67
58
  # {RDF::Queryable} backing this graph.
@@ -73,16 +64,18 @@ module RDF
73
64
  # Creates a new `Graph` instance populated by the RDF data returned by
74
65
  # dereferencing the given graph_name Resource.
75
66
  #
76
- # @param [String, #to_s] url
67
+ # @param [String, #to_s] url
68
+ # @param [RDF::Resource] graph_name
69
+ # Set set graph name of each loaded statement
77
70
  # @param [Hash{Symbol => Object}] options
78
- # Options from {RDF::Graph#initialize} and {RDF::Mutable#load}
71
+ # Options from {RDF::Reader.open}
79
72
  # @yield [graph]
80
73
  # @yieldparam [Graph] graph
81
74
  # @return [Graph]
82
75
  # @since 0.1.7
83
- def self.load(url, options = {}, &block)
84
- self.new(options) do |graph|
85
- graph.load(url, options)
76
+ def self.load(url, graph_name: nil, **options, &block)
77
+ self.new(graph_name: graph_name, **options) do |graph|
78
+ graph.load(url, graph_name: graph_name, **options)
86
79
 
87
80
  if block_given?
88
81
  case block.arity
@@ -103,21 +96,31 @@ module RDF
103
96
  # @param [Hash{Symbol => Object}] options
104
97
  # @option options [RDF::Queryable] :data (RDF::Repository.new)
105
98
  # Storage behind this graph.
106
- # @raise [ArgumentError] if a `data` does not support named graphs.
107
- # @note
108
- # Contexts are only useful when used as a projection
109
- # on a `:data` which supports named graphs. Otherwise, there is no
110
- # such thing as a named graph in RDF 1.1, a repository may have
111
- # graphs which are named, but the name is not a property of the graph.
112
- # @overload initialize(options)
113
- # @param [Hash{Symbol => Object}] options
114
- # @option options [RDF::Queryable] :data (RDF::Repository.new)
99
+ # @deprecated This form is deprecated in version 2.0.
100
+ #
101
+ # @overload initialize(graph_name: nil, data: nil)
102
+ # @param [RDF::Resource] graph_name
103
+ # The graph_name from the associated {RDF::Queryable} associated
104
+ # with this graph as provided with the `:data` option
105
+ # (only for {RDF::Queryable} instances supporting
106
+ # named graphs).
107
+ # @param [RDF::Queryable] :data (RDF::Repository.new)
115
108
  # Storage behind this graph.
109
+ #
110
+ # @raise [ArgumentError] if a `data` does not support named graphs.
111
+ # @note
112
+ # Graph names are only useful when used as a projection
113
+ # on a `:data` which supports named graphs. Otherwise, there is no
114
+ # such thing as a named graph in RDF 1.1, a repository may have
115
+ # graphs which are named, but the name is not a property of the graph.
116
116
  # @yield [graph]
117
117
  # @yieldparam [Graph]
118
- def initialize(*args, &block)
119
- graph_name = args.shift unless args.first.is_a?(Hash)
120
- options = args.first || {}
118
+ def initialize(*args, graph_name: nil, data: nil, **options, &block)
119
+ unless args.empty?
120
+ warn "[DEPRECATION] Graph#initialize now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
121
+ graph_name ||= args.first
122
+ end
123
+
121
124
  @graph_name = case graph_name
122
125
  when nil then nil
123
126
  when RDF::Resource then graph_name
@@ -125,7 +128,7 @@ module RDF
125
128
  end
126
129
 
127
130
  @options = options.dup
128
- @data = @options.delete(:data) || RDF::Repository.new(with_graph_name: false)
131
+ @data = data || RDF::Repository.new(with_graph_name: false)
129
132
 
130
133
  raise ArgumentError, "Can't apply graph_name unless initialized with `data` supporting graph_names" if
131
134
  @graph_name && !@data.supports?(:graph_name)
@@ -146,7 +149,7 @@ module RDF
146
149
  case
147
150
  when args.empty?
148
151
  raise ArgumentError, "Can't reload graph without a graph_name" unless graph_name.is_a?(RDF::URI)
149
- load(graph_name.to_s, {base_uri: graph_name}.merge(@options))
152
+ load(graph_name.to_s, base_uri: graph_name)
150
153
  else super
151
154
  end
152
155
  end
@@ -186,21 +189,11 @@ module RDF
186
189
  @data.durable?
187
190
  end
188
191
 
189
- ##
190
- # Returns all unique RDF contexts for this graph.
191
- #
192
- # @return [Enumerator<RDF::Resource>]
193
- # @deprecated Use {#graph_names} instead.
194
- def contexts(options = {})
195
- warn "[DEPRECATION] Graph#contexts is being replaced with Graph#graph_names in RDF.rb 2.0. Called from #{Gem.location_of_caller.join(':')}"
196
- (named? ? [context] : []).to_enum.extend(RDF::Countable)
197
- end
198
-
199
192
  ##
200
193
  # Returns all unique RDF names for this graph.
201
194
  #
202
195
  # @return [Enumerator<RDF::Resource>]
203
- def graph_names(options = {})
196
+ def graph_names(unique: true)
204
197
  (named? ? [graph_name] : []).extend(RDF::Countable)
205
198
  end
206
199
 
@@ -241,6 +234,8 @@ module RDF
241
234
  ##
242
235
  # Returns `true` if this graph contains the given RDF statement.
243
236
  #
237
+ # A statement is in a graph if the statement if it has the same triples without regard to graph_name.
238
+ #
244
239
  # @param [Statement] statement
245
240
  # @return [Boolean]
246
241
  # @see RDF::Enumerable#has_statement?
@@ -267,6 +262,17 @@ module RDF
267
262
  end
268
263
  end
269
264
 
265
+ ##
266
+ # @private
267
+ # @see RDF::Enumerable#project_graph
268
+ def project_graph(graph_name, &block)
269
+ if block_given?
270
+ self.each(&block) if graph_name == self.graph_name
271
+ else
272
+ graph_name == self.graph_name ? self : RDF::Graph.new
273
+ end
274
+ end
275
+
270
276
  ##
271
277
  # Graph equivalence based on the contents of each graph being _exactly_
272
278
  # the same. To determine if the have the same _meaning_, consider
@@ -299,6 +305,21 @@ module RDF
299
305
  @data.insert(statement)
300
306
  end
301
307
 
308
+ ##
309
+ # @private
310
+ # @see RDF::Mutable#insert_statements
311
+ def insert_statements(statements)
312
+ enum = Enumerable::Enumerator.new do |yielder|
313
+
314
+ statements.send(method = statements.respond_to?(:each_statement) ? :each_statement : :each) do |s|
315
+ s = s.dup
316
+ s.graph_name = graph_name
317
+ yielder << s
318
+ end
319
+ end
320
+ @data.insert(enum)
321
+ end
322
+
302
323
  ##
303
324
  # @private
304
325
  # @see RDF::Mutable#delete
@@ -315,17 +336,26 @@ module RDF
315
336
  @data.delete(graph_name: graph_name || false)
316
337
  end
317
338
 
339
+ ##
340
+ # @private
341
+ # Opens a transaction over the graph
342
+ # @see RDF::Transactable#begin_transaction
343
+ def begin_transaction(mutable: false, graph_name: @graph_name)
344
+ @data.send(:begin_transaction, mutable: mutable, graph_name: graph_name)
345
+ end
346
+
318
347
  protected :query_pattern
319
348
  protected :insert_statement
320
349
  protected :delete_statement
321
350
  protected :clear_statements
351
+ protected :begin_transaction
322
352
 
323
353
  ##
324
354
  # @private
325
355
  # @see RDF::Enumerable#graphs
326
356
  # @since 0.2.0
327
357
  def graphs
328
- enum_graph
358
+ Array(enum_graph)
329
359
  end
330
360
 
331
361
  ##
@@ -27,7 +27,7 @@ module RDF
27
27
  # @param [Array<RDF::Term>] values
28
28
  # @return [RDF::List]
29
29
  def self.[](*values)
30
- self.new(nil, nil, values)
30
+ self.new(subject: nil, graph: nil, values: values)
31
31
  end
32
32
 
33
33
  ##
@@ -49,21 +49,28 @@ module RDF
49
49
  # g.count # => l.count
50
50
  #
51
51
  # @overload initialize(subject = nil, graph = nil, values = nil, &block)
52
- # @param [RDF::URI] subject
52
+ # @param [RDF::Resource] subject
53
+ # Subject should be an {RDF::Node}, not a {RDF::URI}. A list with an IRI head will not validate, but is commonly used to detect if a list is valid.
53
54
  # @param [RDF::Graph] graph
54
55
  # @param [Array<RDF::Term>] values
55
56
  # Any values which are not terms are coerced to `RDF::Literal`.
56
57
  # @yield [list]
57
58
  # @yieldparam [RDF::List] list
58
- # @deprecated Subject should be an {RDF::Node}, not a {RDF::URI}. A list with an IRI head will not validate, but is commonly used to detect if a list is valid.
59
- # @overload initialize(subject = nil, graph = nil, values = nil, &block)
60
- # @param [RDF::Node] subject (RDF.nil)
59
+ # @deprecated This form is deprecated in version 2.0
60
+ #
61
+ # @overload initialize(subject: nil, graph: nil, values: nil, &block)
62
+ # @param [RDF::Resource] subject (RDF.nil)
63
+ # Subject should be an {RDF::Node}, not a {RDF::URI}. A list with an IRI head will not validate, but is commonly used to detect if a list is valid.
61
64
  # @param [RDF::Graph] graph (RDF::Graph.new)
62
65
  # @param [Array<RDF::Term>] values
63
66
  # Any values which are not terms are coerced to `RDF::Literal`.
64
67
  # @yield [list]
65
68
  # @yieldparam [RDF::List] list
66
- def initialize(subject = nil, graph = nil, values = nil, &block)
69
+ #
70
+ def initialize(*args, subject: nil, graph: nil, values: nil, &block)
71
+ unless args.empty?
72
+ raise ArgumentError, "[FATAL DEPRECATION] List#initialize now uses keyword arguments. Called from #{Gem.location_of_caller.join(':')}"
73
+ end
67
74
  @subject = subject || RDF.nil
68
75
  @graph = graph || RDF::Graph.new
69
76
  is_empty = @graph.query(subject: subject, predicate: RDF.first).empty?
@@ -95,7 +102,15 @@ module RDF
95
102
  UNSET = Object.new.freeze # @private
96
103
 
97
104
  # The canonical empty list.
98
- NIL = RDF::List.new(RDF.nil).freeze
105
+ NIL = RDF::List.new(subject: RDF.nil).freeze
106
+
107
+ ##
108
+ # Is this a {RDF::List}?
109
+ #
110
+ # @return [Boolean]
111
+ def list?
112
+ true
113
+ end
99
114
 
100
115
  ##
101
116
  # Validate the list ensuring that
@@ -151,7 +166,7 @@ module RDF
151
166
  #
152
167
  # @param [RDF::List] other
153
168
  # @return [RDF::List]
154
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000469
169
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-26
155
170
  def &(other)
156
171
  RDF::List[*(to_a & other.to_a)]
157
172
  end
@@ -169,7 +184,7 @@ module RDF
169
184
  #
170
185
  # @param [RDF::List] other
171
186
  # @return [RDF::List]
172
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000470
187
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-7C
173
188
  def |(other)
174
189
  RDF::List[*(to_a | other.to_a)]
175
190
  end
@@ -182,7 +197,7 @@ module RDF
182
197
  #
183
198
  # @param [RDF::List] other
184
199
  # @return [RDF::List]
185
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000466
200
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-2B
186
201
  def +(other)
187
202
  RDF::List[*(to_a + other.to_a)]
188
203
  end
@@ -196,7 +211,7 @@ module RDF
196
211
  #
197
212
  # @param [RDF::List] other
198
213
  # @return [RDF::List]
199
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000468
214
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-2D
200
215
  def -(other)
201
216
  RDF::List[*(to_a - other.to_a)]
202
217
  end
@@ -225,7 +240,7 @@ module RDF
225
240
  # @return [RDF::List]
226
241
  #
227
242
  # @return [RDF::List]
228
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000467
243
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-2A
229
244
  def *(int_or_str)
230
245
  case int_or_str
231
246
  when Integer then RDF::List[*(to_a * int_or_str)]
@@ -233,6 +248,19 @@ module RDF
233
248
  end
234
249
  end
235
250
 
251
+ ##
252
+ # Returns the element at `index`.
253
+ #
254
+ # @example
255
+ # RDF::List[1, 2, 3][0] #=> RDF::Literal(1)
256
+ #
257
+ # @param [Integer] index
258
+ # @return [RDF::Term]
259
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-5B-5D
260
+ def [](index)
261
+ at(index)
262
+ end
263
+
236
264
  ##
237
265
  # Element Assignment — Sets the element at `index`, or replaces a subarray from the `start` index for `length` elements, or replaces a subarray specified by the `range` of indices.
238
266
  #
@@ -314,7 +342,7 @@ module RDF
314
342
  # Clear the list and create a new list using the existing subject
315
343
  subject = @subject unless ary.empty? || @subject == RDF.nil
316
344
  self.clear
317
- new_list = RDF::List.new(subject, @graph, ary)
345
+ new_list = RDF::List.new(subject: subject, graph: @graph, values: ary)
318
346
  @subject = new_list.subject
319
347
  ret # Returns inserted values
320
348
  end
@@ -328,13 +356,13 @@ module RDF
328
356
  # @param [RDF::Term, Array<RDF::Term>, RDF::List] value
329
357
  # A non-RDF::Term is coerced to a Literal
330
358
  # @return [RDF::List]
331
- # @see http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-unshift
359
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-unshift
332
360
  #
333
361
  def unshift(value)
334
362
  value = case value
335
363
  when nil then RDF.nil
336
364
  when RDF::Term then value
337
- when Array then RDF::List.new(nil, graph, value)
365
+ when Array then RDF::List.new(subject: nil, graph: graph, values: value)
338
366
  else value
339
367
  end
340
368
 
@@ -355,7 +383,7 @@ module RDF
355
383
  # RDF::List[1,2,3].shift #=> 1
356
384
  #
357
385
  # @return [RDF::Term]
358
- # @see http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-shift
386
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-shift
359
387
  def shift
360
388
  return nil if empty?
361
389
 
@@ -376,7 +404,7 @@ module RDF
376
404
  # RDF::List[1, 2, 2, 3].clear #=> RDF::List[]
377
405
  #
378
406
  # @return [RDF::List]
379
- # @see http://ruby-doc.org/core-1.9.3/classes/Array.html#method-i-clear
407
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-clear
380
408
  def clear
381
409
  until empty?
382
410
  shift
@@ -392,12 +420,12 @@ module RDF
392
420
  #
393
421
  # @param [RDF::Term] value
394
422
  # @return [RDF::List]
395
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000424
423
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-3C-3C
396
424
  def <<(value)
397
425
  value = case value
398
426
  when nil then RDF.nil
399
427
  when RDF::Value then value
400
- when Array then RDF::List.new(nil, graph, value)
428
+ when Array then RDF::List.new(subject: nil, graph: graph, values: value)
401
429
  else value
402
430
  end
403
431
 
@@ -439,7 +467,7 @@ module RDF
439
467
  #
440
468
  # @param [RDF::List] other
441
469
  # @return [Integer]
442
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000461
470
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-3C-3D-3E
443
471
  def <=>(other)
444
472
  to_a <=> other.to_a # TODO: optimize this
445
473
  end
@@ -452,7 +480,7 @@ module RDF
452
480
  # RDF::List[1, 2, 3].empty? #=> false
453
481
  #
454
482
  # @return [Boolean]
455
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000434
483
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-empty-3F
456
484
  def empty?
457
485
  graph.query(subject: subject, predicate: RDF.first).empty?
458
486
  end
@@ -465,7 +493,7 @@ module RDF
465
493
  # RDF::List[1, 2, 3].length #=> 3
466
494
  #
467
495
  # @return [Integer]
468
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000433
496
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-length
469
497
  def length
470
498
  each.count
471
499
  end
@@ -482,7 +510,7 @@ module RDF
482
510
  #
483
511
  # @param [RDF::Term] value
484
512
  # @return [Integer]
485
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000436
513
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-index
486
514
  def index(value)
487
515
  each.with_index do |v, i|
488
516
  return i if v == value
@@ -499,7 +527,7 @@ module RDF
499
527
  # RDF::List[1, 2, 3].slice(0..2) #=> RDF::List[1, 2, 3]
500
528
  #
501
529
  # @return [RDF::Term]
502
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000462
530
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-slice
503
531
  def slice(*args)
504
532
  case argc = args.size
505
533
  when 2 then slice_with_start_and_length(*args)
@@ -556,7 +584,7 @@ module RDF
556
584
  # RDF::List[1, 2, 3].at(4) #=> nil
557
585
  #
558
586
  # @return [RDF::Term]
559
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000419
587
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-at
560
588
  def at(index)
561
589
  each.with_index do |v, i|
562
590
  return v if i == index
@@ -683,7 +711,7 @@ module RDF
683
711
  # RDF::List[*(1..10)].last #=> RDF::Literal(10)
684
712
  #
685
713
  # @return [RDF::Term]
686
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000422
714
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-last
687
715
  def last
688
716
  graph.first_object(subject: last_subject, predicate: RDF.first)
689
717
  end
@@ -696,7 +724,7 @@ module RDF
696
724
  #
697
725
  # @return [RDF::List]
698
726
  def rest
699
- (subject = rest_subject).eql?(RDF.nil) ? nil : self.class.new(subject, graph)
727
+ (subject = rest_subject).eql?(RDF.nil) ? nil : self.class.new(subject: subject, graph: graph)
700
728
  end
701
729
 
702
730
  ##
@@ -707,7 +735,7 @@ module RDF
707
735
  #
708
736
  # @return [RDF::List]
709
737
  def tail
710
- (subject = last_subject).eql?(RDF.nil) ? nil : self.class.new(subject, graph)
738
+ (subject = last_subject).eql?(RDF.nil) ? nil : self.class.new(subject: subject, graph: graph)
711
739
  end
712
740
 
713
741
  ##
@@ -815,7 +843,7 @@ module RDF
815
843
  #
816
844
  # @param [String] sep
817
845
  # @return [String]
818
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000438
846
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-join
819
847
  def join(sep = $,)
820
848
  map(&:to_s).join(sep)
821
849
  end
@@ -827,7 +855,7 @@ module RDF
827
855
  # RDF::List[1, 2, 3].reverse #=> RDF::List[3, 2, 1]
828
856
  #
829
857
  # @return [RDF::List]
830
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000439
858
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-reverse
831
859
  def reverse
832
860
  RDF::List[*to_a.reverse]
833
861
  end
@@ -839,7 +867,7 @@ module RDF
839
867
  # RDF::List[2, 3, 1].sort #=> RDF::List[1, 2, 3]
840
868
  #
841
869
  # @return [RDF::List]
842
- # @see http://ruby-doc.org/core-1.9/classes/Enumerable.html#M003038
870
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-sort
843
871
  def sort(&block)
844
872
  RDF::List[*super]
845
873
  end
@@ -851,7 +879,7 @@ module RDF
851
879
  # RDF::List[2, 3, 1].sort_by(&:to_i) #=> RDF::List[1, 2, 3]
852
880
  #
853
881
  # @return [RDF::List]
854
- # @see http://ruby-doc.org/core-1.9/classes/Enumerable.html#M003039
882
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-sort_by
855
883
  def sort_by(&block)
856
884
  RDF::List[*super]
857
885
  end
@@ -863,7 +891,7 @@ module RDF
863
891
  # RDF::List[1, 2, 2, 3].uniq #=> RDF::List[1, 2, 3]
864
892
  #
865
893
  # @return [RDF::List]
866
- # @see http://ruby-doc.org/core-1.9/classes/Array.html#M000471
894
+ # @see http://ruby-doc.org/core-2.2.2/Array.html#method-i-uniq
867
895
  def uniq
868
896
  RDF::List[*to_a.uniq]
869
897
  end