rdf 1.1.11 → 1.1.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7d765dce315d0c9f719adae387e1cec7f945958
4
- data.tar.gz: 9446ae5e871f78abf5a43e783e4a90d193160984
3
+ metadata.gz: 424861a5701eb72e91b109582c0fa5a822a55077
4
+ data.tar.gz: 6e3bb83de003042827fc25fd5b77522fa957c6a8
5
5
  SHA512:
6
- metadata.gz: 0b9b5e08ba70b4574a955c30154bc4702ba0ca5767b734aafdeb2d1919da2fe961ab93c74122d1ab89e023bb710943e5dbfc5a2072141db5f219a4d9756f91ca
7
- data.tar.gz: 1dd2bae743a05599b83ddaa860817aa9afd2a4bc1e47dc6606a79aaf9b01e87583ef61ac3e9c0cba89fc0fbd31bd4c78be85e8c2e3c3bab9b260f72d75e8a83e
6
+ metadata.gz: cab68b2efe3db88ea4f11b71818c2966ccda4f41a3a41aeff008d41535bec2798c4e03e9db39219f767b3255974291243f14aeb5798b5733629e829a5a1bc74d
7
+ data.tar.gz: e7edd05ebdeec991a7403d26debf884a98ff94dbf74985c77b092aafe61f53bdc7f937b6ac77266d6506cebc01f0de1bbf2b832811ef6a3e9afecd4a55247239
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.11
1
+ 1.1.12
data/lib/rdf.rb CHANGED
@@ -44,7 +44,7 @@ module RDF
44
44
  autoload :NQuads, 'rdf/nquads'
45
45
 
46
46
  # RDF storage
47
- autoload :Dataset, 'rdf/model/dataset'
47
+ autoload :Dataset, 'rdf/model/repository'
48
48
  autoload :Repository, 'rdf/repository'
49
49
  autoload :Transaction, 'rdf/transaction'
50
50
 
@@ -37,7 +37,7 @@ module RDF
37
37
  end
38
38
 
39
39
  ##
40
- # Returns `true` if `self` is a {RDF::Statement}.
40
+ # Is this a {RDF::Statement}?
41
41
  #
42
42
  # @return [Boolean]
43
43
  def statement?
@@ -45,7 +45,7 @@ module RDF
45
45
  end
46
46
 
47
47
  ##
48
- # Returns `true` if `self` is a {RDF::List}.
48
+ # Is this a {RDF::List}?
49
49
  #
50
50
  # @return [Boolean]
51
51
  def list?
@@ -53,7 +53,7 @@ module RDF
53
53
  end
54
54
 
55
55
  ##
56
- # Returns `true` if `self` is a {RDF::Term}.
56
+ # Is this a {RDF::Term}?
57
57
  #
58
58
  # @return [Boolean]
59
59
  def term?
@@ -61,7 +61,7 @@ module RDF
61
61
  end
62
62
 
63
63
  ##
64
- # Returns `true` if `self` is a {RDF::Resource}.
64
+ # Is this a {RDF::Resource}?
65
65
  #
66
66
  # @return [Boolean]
67
67
  def resource?
@@ -69,7 +69,7 @@ module RDF
69
69
  end
70
70
 
71
71
  ##
72
- # Returns `true` if `self` is a {RDF::Literal}.
72
+ # Is this a {RDF::Literal}?
73
73
  #
74
74
  # @return [Boolean]
75
75
  def literal?
@@ -77,7 +77,7 @@ module RDF
77
77
  end
78
78
 
79
79
  ##
80
- # Returns `true` if `self` is a {RDF::Node}.
80
+ # Is this a {RDF::Node}, or does it contain a node?
81
81
  #
82
82
  # @return [Boolean]
83
83
  def node?
@@ -85,7 +85,7 @@ module RDF
85
85
  end
86
86
 
87
87
  ##
88
- # Returns `true` if `self` is an IRI reference.
88
+ # Is this an {RDF::IRI}?
89
89
  #
90
90
  # By default this is simply an alias for {RDF::Value#uri?}.
91
91
  #
@@ -95,7 +95,7 @@ module RDF
95
95
  end
96
96
 
97
97
  ##
98
- # Returns `true` if `self` is a {RDF::URI}.
98
+ # Is this an {RDF::URI}?
99
99
  #
100
100
  # @return [Boolean]
101
101
  def uri?
@@ -103,7 +103,7 @@ module RDF
103
103
  end
104
104
 
105
105
  ##
106
- # Returns `true` this value is a {RDF::Query::Variable}, or is contains a variable.
106
+ # Is this a {RDF::Query::Variable}, or does it contain a variable?
107
107
  #
108
108
  # @return [Boolean]
109
109
  # @since 0.1.7
@@ -112,7 +112,9 @@ module RDF
112
112
  end
113
113
 
114
114
  ##
115
- # Returns `true` if this value is constant.
115
+ # Is this constant, or are all of its components constant?
116
+ #
117
+ # Same as `!variable?`
116
118
  #
117
119
  # @return [Boolean] `true` or `false`
118
120
  # @see #variable?
@@ -121,7 +123,7 @@ module RDF
121
123
  end
122
124
 
123
125
  ##
124
- # Is this an anonymous value?
126
+ # Is this value named?
125
127
  #
126
128
  # @return [Boolean] `true` or `false`
127
129
  def anonymous?
@@ -129,7 +131,7 @@ module RDF
129
131
  end
130
132
 
131
133
  ##
132
- # Returns `true` if the value has a valid representation
134
+ # Is this value valid, and composed only of valid components?
133
135
  #
134
136
  # @return [Boolean] `true` or `false`
135
137
  # @since 0.3.9
@@ -138,7 +140,7 @@ module RDF
138
140
  end
139
141
 
140
142
  ##
141
- # Returns `true` if value is not valid
143
+ # Is this value invalid, or is it composed of any invalid components?
142
144
  #
143
145
  # @return [Boolean] `true` or `false`
144
146
  # @since 0.2.1
@@ -64,10 +64,10 @@ module RDF
64
64
  # _:a foaf:name "Alice" .
65
65
  # _:a foaf:mbox <mailto:[email protected]> .
66
66
  #
67
- #
68
67
  # @see http://www.w3.org/TR/rdf-sparql-query/#rdfDataset
69
68
  # @since 0.3.0
70
69
  class Query
70
+ include Enumerable
71
71
  autoload :Pattern, 'rdf/query/pattern'
72
72
  autoload :Solution, 'rdf/query/solution'
73
73
  autoload :Solutions, 'rdf/query/solutions'
@@ -313,8 +313,8 @@ module RDF
313
313
  unless context.nil?
314
314
  if patterns.empty?
315
315
  patterns = [Pattern.new(nil, nil, nil, :context => context)]
316
- elsif patterns.first.context.nil?
317
- patterns.first.context = context
316
+ else
317
+ apply_context(context)
318
318
  end
319
319
  end
320
320
 
@@ -431,6 +431,28 @@ module RDF
431
431
  options[:context]
432
432
  end
433
433
 
434
+ # Apply the context specified (or configured) to all patterns that have no context
435
+ # @param [RDF::IRI, RDF::Query::Variable] context (self.context)
436
+ def apply_context(context = options[:context])
437
+ patterns.each {|pattern| pattern.context = context if pattern.context.nil?} unless context.nil?
438
+ end
439
+
440
+ ##
441
+ # Returns `true` if any pattern contains a variable.
442
+ #
443
+ # @return [Boolean]
444
+ def variable?
445
+ patterns.any?(&:variable?) || context && context.variable?
446
+ end
447
+
448
+ ##
449
+ # Returns `true` if any pattern contains a blank node.
450
+ #
451
+ # @return [Boolean]
452
+ def has_blank_nodes?
453
+ patterns.any?(&:has_blank_nodes?) || context && context.node?
454
+ end
455
+
434
456
  # Query has no patterns
435
457
  # @return [Boolean]
436
458
  def empty?
@@ -448,6 +470,17 @@ module RDF
448
470
  end
449
471
  alias_method :each, :each_solution
450
472
 
473
+ ##
474
+ # Enumerates over each statement (pattern).
475
+ #
476
+ # @yield [RDF::Query::Pattern]
477
+ # @yieldparam [::Query::Pattern] pattern
478
+ # @return [Enumerator]
479
+ def each_statement(&block)
480
+ apply_context
481
+ patterns.each(&block)
482
+ end
483
+
451
484
  ##
452
485
  # Duplicate query, including patterns and solutions
453
486
  # @return [RDF::Query]
@@ -231,6 +231,20 @@ module RDF; class Query
231
231
  variables
232
232
  end
233
233
 
234
+ ##
235
+ # Binds the pattern to a solution, making it no longer variable if all variables are resolved to bound variables
236
+ #
237
+ # @param [RDF::Query::Solution] solution
238
+ # @return [self]
239
+ def bind(solution)
240
+ self.to_quad.each_with_index do |term, index|
241
+ if term && term.variable? && solution[term]
242
+ self[index] = solution[term]
243
+ end
244
+ end
245
+ self
246
+ end
247
+
234
248
  ##
235
249
  # Returns `true` if this pattern contains bindings.
236
250
  #
@@ -228,7 +228,7 @@ module RDF; module Util
228
228
 
229
229
  remote_document = RemoteDocument.new(response.body, document_options)
230
230
  else
231
- raise IOError, "<#{base_uri}>: #{response.code}"
231
+ raise IOError, "<#{base_uri}>: #{response.status}"
232
232
  end
233
233
  end
234
234
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-05 00:00:00.000000000 Z
13
+ date: 2015-05-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: link_header
OSZAR »