rdf 1.1.0.p2 → 1.1.0.p3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzZkZDE2NTczM2Q1MGRjYjM1ZjJmYzNkNWY4YTY3MWMxZmJjNzZlZQ==
5
+ data.tar.gz: !binary |-
6
+ ODM4ZmFlMThiYjRiNTI5YTk3MGI0ODg4NTIwODhkZWRlMGNiYTA1ZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MTYyYjUwMDc4YTIyMDBhM2JiZDhhYTMwN2E4NjQxNGU3NDM1ZDhhZmVmOWNj
10
+ NjBiNWI3ZDUxZTdlNjI4ZDY0NTJlOWNhMTEwN2I3OWVjMzg4NTc3YTQ5YzU2
11
+ NTU3ZDk1ZmQ0ZDY2ZWUzM2U0YzQ3YjAzNjhiODVhNjgwMjVmYTA=
12
+ data.tar.gz: !binary |-
13
+ NDQ0MTRiYzNjMmQ3NTk3NTU1NDIzMWIwYzgxNzcxYmI4MWRmYzRiM2U0MmQw
14
+ YTdjZmEzZGUzOWRiMWU3YmRlODhjYjZkOGJlOTZlMzM3OGI5ZGYzMzA4NGJh
15
+ ZGI0MWIyNjU0MTljYmZhNGEwYWRlNzMwNjFlNWRmOTk5YzBmZWU=
data/CREDITS CHANGED
@@ -8,3 +8,4 @@
8
8
  * John Fieber <jrf@ursamaris.org>
9
9
  * Keita Urashima <ursm@ursm.jp>
10
10
  * Pius Uzamere <pius@alum.mit.edu>
11
+ * Judson Lester <nyarly@gmail.com>
data/README CHANGED
@@ -387,6 +387,7 @@ follows:
387
387
  * [John Fieber](http://github.com/jfieber) - <http://github.com/jfieber>
388
388
  * [Keita Urashima](http://github.com/ursm) - <http://ursm.jp/>
389
389
  * [Pius Uzamere](http://github.com/pius) - <http://pius.me/>
390
+ * [Judson Lester](https://github.com/nyarly) - <https://github.com/nyarly>
390
391
 
391
392
  ## Contributing
392
393
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0.p2
1
+ 1.1.0.p3
@@ -39,10 +39,12 @@ module RDF
39
39
  # @yield [list]
40
40
  # @yieldparam [RDF::List] list
41
41
  def initialize(subject = nil, graph = nil, values = nil, &block)
42
- @subject = subject || RDF::Node.new
42
+ @subject = subject || RDF.nil
43
43
  @graph = graph || RDF::Graph.new
44
44
 
45
- values.each { |value| self << value } unless values.nil? || values.empty?
45
+ unless values.to_a.empty?
46
+ values.reverse_each {|value| self.unshift(value)}
47
+ end
46
48
 
47
49
  if block_given?
48
50
  case block.arity
@@ -71,6 +73,7 @@ module RDF
71
73
  rest = nil
72
74
  firsts = rests = 0
73
75
  @graph.query(:subject => li) do |st|
76
+ return false unless st.subject.node?
74
77
  case st.predicate
75
78
  when RDF.first
76
79
  firsts += 1
@@ -202,6 +205,70 @@ module RDF
202
205
  at(index)
203
206
  end
204
207
 
208
+ ##
209
+ # Appends an element to the head of this list. Existing references are not updated, as the list subject changes as a side-effect.
210
+ #
211
+ # @example
212
+ # RDF::List[].unshift(1).unshift(2).unshift(3) #=> RDF::List[3, 2, 1]
213
+ #
214
+ # @param [RDF::Term] value
215
+ # @return [RDF::List]
216
+ # @see http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-unshift
217
+ #
218
+ def unshift(value)
219
+ value = case value
220
+ when nil then RDF.nil
221
+ when RDF::Value then value
222
+ when Array then RDF::List.new(nil, graph, value)
223
+ else value
224
+ end
225
+
226
+ new_subject, old_subject = RDF::Node.new, subject
227
+
228
+ graph.insert([new_subject, RDF.first, value.is_a?(RDF::List) ? value.subject : value])
229
+ graph.insert([new_subject, RDF.rest, old_subject])
230
+
231
+ @subject = new_subject
232
+
233
+ return self
234
+ end
235
+
236
+ ##
237
+ # Removes and returns the element at the head of this list.
238
+ #
239
+ # @example
240
+ # RDF::List[1,2,3].shift #=> 1
241
+ #
242
+ # @return [RDF::Term]
243
+ # @see http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-shift
244
+ def shift
245
+ return nil if empty?
246
+
247
+ value = first
248
+ old_subject, new_subject = subject, rest_subject
249
+ graph.delete([old_subject, RDF.type, RDF.List])
250
+ graph.delete([old_subject, RDF.first, value])
251
+ graph.delete([old_subject, RDF.rest, new_subject])
252
+
253
+ @subject = new_subject
254
+ return value
255
+ end
256
+
257
+ ##
258
+ # Empties this list
259
+ #
260
+ # @example
261
+ # RDF::List[1, 2, 2, 3].clear #=> RDF::List[]
262
+ #
263
+ # @return [RDF::List]
264
+ # @see http://ruby-doc.org/core-1.9.3/classes/Array.html#method-i-clear
265
+ def clear
266
+ until empty?
267
+ shift
268
+ end
269
+ return self
270
+ end
271
+
205
272
  ##
206
273
  # Appends an element to the tail of this list.
207
274
  #
@@ -220,7 +287,7 @@ module RDF
220
287
  end
221
288
 
222
289
  if empty?
223
- new_subject = subject
290
+ @subject = new_subject = RDF::Node.new
224
291
  else
225
292
  old_subject, new_subject = last_subject, RDF::Node.new
226
293
  graph.delete([old_subject, RDF.rest, RDF.nil])
@@ -182,12 +182,11 @@ module RDF
182
182
  end
183
183
 
184
184
  ##
185
- # Returns `true` if the subject or object of this statement is a blank
186
- # node.
185
+ # Returns `true` if any resource of this statement is a blank node.
187
186
  #
188
187
  # @return [Boolean]
189
188
  def has_blank_nodes?
190
- (has_object? && object.node?) || (has_subject? && subject.node?)
189
+ to_quad.compact.any?(&:node?)
191
190
  end
192
191
 
193
192
  ##
@@ -38,12 +38,14 @@ module RDF
38
38
  def self.detect(sample)
39
39
  !!sample.match(%r(
40
40
  (?:\s*(?:<[^>]*>) | (?:_:\w+)) # Subject
41
+ \s*
41
42
  (?:\s*<[^>]*>) # Predicate
42
43
  \s*
43
44
  (?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"\n]*"(?:^^|@\S+)?)) # Object
44
- (?:\s*<[^>]*>) # Context
45
+ \s*
46
+ (?:\s*(?:<[^>]*>) | (?:_:\w+)) # Context
45
47
  \s*\.
46
- )mx) && !(
48
+ )x) && !(
47
49
  sample.match(%r(@(base|prefix|keywords)|\{)) || # Not Turtle/N3/TriG
48
50
  sample.match(%r(<(html|rdf))i) # Not HTML or XML
49
51
  )
@@ -40,7 +40,7 @@ module RDF::NTriples
40
40
  \s*
41
41
  (?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"\n]*"(?:^^|@\S+)?)) # Object
42
42
  \s*\.
43
- )mx) && !(
43
+ )x) && !(
44
44
  sample.match(%r(@(base|prefix|keywords)|\{)) || # Not Turtle/N3/TriG
45
45
  sample.match(%r(<(html|rdf))i) # Not HTML or XML
46
46
  ) && !RDF::NQuads::Format.detect(sample)
@@ -182,17 +182,33 @@ class RDF::Query
182
182
 
183
183
  ##
184
184
  # Compatible Mappings
185
+ #
185
186
  # Two solution mappings u1 and u2 are compatible if, for every variable v in dom(u1) and in dom(u2), u1(v) = u2(v).
186
187
  #
187
188
  # @param [RDF::Query::Solution, #to_hash] other
188
189
  # another query solution or hash bindings
189
190
  # @return [Boolean]
191
+ # @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algCompatibleMapping
190
192
  def compatible?(other)
191
193
  @bindings.all? do |k, v|
192
194
  !other.to_hash.has_key?(k) || other[k].eql?(v)
193
195
  end
194
196
  end
195
-
197
+
198
+ ##
199
+ # Disjoint mapping
200
+ #
201
+ # A solution is disjoint with another solution if it shares no common variables in their domains.
202
+ #
203
+ # @param [RDF::Query::Solution] other
204
+ # @return [Boolean]
205
+ # @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algMinus
206
+ def disjoint?(other)
207
+ @bindings.none? do |k, v|
208
+ v && other.to_hash.has_key?(k) && other[k].eql?(v)
209
+ end
210
+ end
211
+
196
212
  ##
197
213
  # Isomorphic Mappings
198
214
  # Two solution mappings u1 and u2 are isomorphic if,
@@ -106,6 +106,20 @@ module RDF; class Query
106
106
  end
107
107
  alias_method :filter!, :filter
108
108
 
109
+ ##
110
+ # Difference between solution sets, from SPARQL 1.1.
111
+ #
112
+ # The `minus` operation on solutions returns those solutions which either have no compatible solution in `other`, or the solution domains are disjoint.
113
+ #
114
+ # @param [RDF::Query::Solutions] other
115
+ # @return [RDF::Query::Solutions] a new solution set
116
+ # @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algMinus
117
+ def -(other)
118
+ self.dup.filter! do |soln|
119
+ !other.any? {|soln2| soln.compatible?(soln2) && !soln.disjoint?(soln2)}
120
+ end
121
+ end
122
+
109
123
  ##
110
124
  # Reorders this solution sequence by the given `variables`.
111
125
  #
metadata CHANGED
@@ -1,85 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.p2
5
- prerelease: 6
4
+ version: 1.1.0.p3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Arto Bendiken
9
8
  - Ben Lavender
10
9
  - Gregg Kellogg
11
- autorequire:
10
+ autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-05-01 00:00:00.000000000 Z
13
+ date: 2013-06-16 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rdf-spec
18
- version_requirements: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - "~>"
21
- - !ruby/object:Gem::Version
22
- version: 1.1.0
23
- none: false
24
17
  requirement: !ruby/object:Gem::Requirement
25
18
  requirements:
26
- - - "~>"
19
+ - - ~>
27
20
  - !ruby/object:Gem::Version
28
21
  version: 1.1.0
29
- none: false
30
- prerelease: false
31
22
  type: :development
32
- - !ruby/object:Gem::Dependency
33
- name: rdf-rdfxml
23
+ prerelease: false
34
24
  version_requirements: !ruby/object:Gem::Requirement
35
25
  requirements:
36
- - - ">="
26
+ - - ~>
37
27
  - !ruby/object:Gem::Version
38
- version: !binary |-
39
- MA==
40
- none: false
28
+ version: 1.1.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: rdf-rdfxml
41
31
  requirement: !ruby/object:Gem::Requirement
42
32
  requirements:
43
- - - ">="
33
+ - - ! '>='
44
34
  - !ruby/object:Gem::Version
45
- version: !binary |-
46
- MA==
47
- none: false
48
- prerelease: false
35
+ version: '0'
49
36
  type: :development
50
- - !ruby/object:Gem::Dependency
51
- name: rspec
37
+ prerelease: false
52
38
  version_requirements: !ruby/object:Gem::Requirement
53
39
  requirements:
54
- - - ">="
40
+ - - ! '>='
55
41
  - !ruby/object:Gem::Version
56
- version: '2.12'
57
- none: false
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rspec
58
45
  requirement: !ruby/object:Gem::Requirement
59
46
  requirements:
60
- - - ">="
47
+ - - ! '>='
61
48
  - !ruby/object:Gem::Version
62
49
  version: '2.12'
63
- none: false
64
- prerelease: false
65
50
  type: :development
66
- - !ruby/object:Gem::Dependency
67
- name: yard
51
+ prerelease: false
68
52
  version_requirements: !ruby/object:Gem::Requirement
69
53
  requirements:
70
- - - ">="
54
+ - - ! '>='
71
55
  - !ruby/object:Gem::Version
72
- version: '0.8'
73
- none: false
56
+ version: '2.12'
57
+ - !ruby/object:Gem::Dependency
58
+ name: yard
74
59
  requirement: !ruby/object:Gem::Requirement
75
60
  requirements:
76
- - - ">="
61
+ - - ! '>='
77
62
  - !ruby/object:Gem::Version
78
63
  version: '0.8'
79
- none: false
80
- prerelease: false
81
64
  type: :development
82
- description: RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data.
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0.8'
71
+ description: RDF.rb is a pure-Ruby library for working with Resource Description Framework
72
+ (RDF) data.
83
73
  email: public-rdf-ruby@w3.org
84
74
  executables:
85
75
  - rdf
@@ -94,19 +84,8 @@ files:
94
84
  - bin/rdf
95
85
  - etc/doap.nt
96
86
  - lib/df.rb
97
- - lib/rdf.rb
98
87
  - lib/rdf/cli.rb
99
88
  - lib/rdf/format.rb
100
- - lib/rdf/nquads.rb
101
- - lib/rdf/ntriples.rb
102
- - lib/rdf/query.rb
103
- - lib/rdf/reader.rb
104
- - lib/rdf/repository.rb
105
- - lib/rdf/transaction.rb
106
- - lib/rdf/util.rb
107
- - lib/rdf/version.rb
108
- - lib/rdf/vocab.rb
109
- - lib/rdf/writer.rb
110
89
  - lib/rdf/mixin/countable.rb
111
90
  - lib/rdf/mixin/durable.rb
112
91
  - lib/rdf/mixin/enumerable.rb
@@ -119,13 +98,6 @@ files:
119
98
  - lib/rdf/mixin/writable.rb
120
99
  - lib/rdf/model/graph.rb
121
100
  - lib/rdf/model/list.rb
122
- - lib/rdf/model/literal.rb
123
- - lib/rdf/model/node.rb
124
- - lib/rdf/model/resource.rb
125
- - lib/rdf/model/statement.rb
126
- - lib/rdf/model/term.rb
127
- - lib/rdf/model/uri.rb
128
- - lib/rdf/model/value.rb
129
101
  - lib/rdf/model/literal/boolean.rb
130
102
  - lib/rdf/model/literal/date.rb
131
103
  - lib/rdf/model/literal/datetime.rb
@@ -135,18 +107,33 @@ files:
135
107
  - lib/rdf/model/literal/numeric.rb
136
108
  - lib/rdf/model/literal/time.rb
137
109
  - lib/rdf/model/literal/token.rb
110
+ - lib/rdf/model/literal.rb
111
+ - lib/rdf/model/node.rb
112
+ - lib/rdf/model/resource.rb
113
+ - lib/rdf/model/statement.rb
114
+ - lib/rdf/model/term.rb
115
+ - lib/rdf/model/uri.rb
116
+ - lib/rdf/model/value.rb
117
+ - lib/rdf/nquads.rb
138
118
  - lib/rdf/ntriples/format.rb
139
119
  - lib/rdf/ntriples/reader.rb
140
120
  - lib/rdf/ntriples/writer.rb
121
+ - lib/rdf/ntriples.rb
141
122
  - lib/rdf/query/hash_pattern_normalizer.rb
142
123
  - lib/rdf/query/pattern.rb
143
124
  - lib/rdf/query/solution.rb
144
125
  - lib/rdf/query/solutions.rb
145
126
  - lib/rdf/query/variable.rb
127
+ - lib/rdf/query.rb
128
+ - lib/rdf/reader.rb
129
+ - lib/rdf/repository.rb
130
+ - lib/rdf/transaction.rb
146
131
  - lib/rdf/util/aliasing.rb
147
132
  - lib/rdf/util/cache.rb
148
133
  - lib/rdf/util/file.rb
149
134
  - lib/rdf/util/uuid.rb
135
+ - lib/rdf/util.rb
136
+ - lib/rdf/version.rb
150
137
  - lib/rdf/vocab/cc.rb
151
138
  - lib/rdf/vocab/cert.rb
152
139
  - lib/rdf/vocab/dc.rb
@@ -166,31 +153,32 @@ files:
166
153
  - lib/rdf/vocab/wot.rb
167
154
  - lib/rdf/vocab/xhtml.rb
168
155
  - lib/rdf/vocab/xsd.rb
156
+ - lib/rdf/vocab.rb
157
+ - lib/rdf/writer.rb
158
+ - lib/rdf.rb
169
159
  homepage: http://ruby-rdf.github.com/
170
160
  licenses:
171
161
  - Public Domain
172
- post_install_message:
162
+ metadata: {}
163
+ post_install_message:
173
164
  rdoc_options: []
174
165
  require_paths:
175
166
  - lib
176
167
  required_ruby_version: !ruby/object:Gem::Requirement
177
168
  requirements:
178
- - - ">="
169
+ - - ! '>='
179
170
  - !ruby/object:Gem::Version
180
171
  version: 1.9.2
181
- none: false
182
172
  required_rubygems_version: !ruby/object:Gem::Requirement
183
173
  requirements:
184
- - - !binary |-
185
- Pg==
174
+ - - ! '>'
186
175
  - !ruby/object:Gem::Version
187
176
  version: 1.3.1
188
- none: false
189
177
  requirements: []
190
178
  rubyforge_project: rdf
191
- rubygems_version: 1.8.24
192
- signing_key:
193
- specification_version: 3
179
+ rubygems_version: 2.0.3
180
+ signing_key:
181
+ specification_version: 4
194
182
  summary: A Ruby library for working with Resource Description Framework (RDF) data.
195
183
  test_files: []
196
184
  has_rdoc: false