sparql-client 0.0.3 → 0.0.4
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.
- data/CONTRIBUTORS +1 -0
- data/README +6 -2
- data/VERSION +1 -1
- data/lib/sparql/client/repository.rb +36 -9
- data/lib/sparql/client/version.rb +1 -1
- metadata +16 -15
data/CONTRIBUTORS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* Nicholas Humfrey <njh@aelius.com>
|
data/README
CHANGED
@@ -68,8 +68,8 @@ Documentation
|
|
68
68
|
Dependencies
|
69
69
|
------------
|
70
70
|
|
71
|
-
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.1.
|
72
|
-
* [JSON](http://rubygems.org/gems/json_pure) (>= 1.
|
71
|
+
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.1.10)
|
72
|
+
* [JSON](http://rubygems.org/gems/json_pure) (>= 1.4.0)
|
73
73
|
|
74
74
|
Installation
|
75
75
|
------------
|
@@ -107,6 +107,10 @@ Authors
|
|
107
107
|
* [Arto Bendiken](mailto:arto.bendiken@gmail.com) - <http://ar.to/>
|
108
108
|
* [Ben Lavender](mailto:blavender@gmail.com) - <http://bhuga.net/>
|
109
109
|
|
110
|
+
Contributors
|
111
|
+
------------
|
112
|
+
* [Nicholas Humfrey](mailto:njh@aelius.com) - <http://www.aelius.com/njh/>
|
113
|
+
|
110
114
|
License
|
111
115
|
-------
|
112
116
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -3,7 +3,7 @@ module SPARQL; class Client
|
|
3
3
|
# A read-only repository view of a SPARQL endpoint.
|
4
4
|
#
|
5
5
|
# @see RDF::Repository
|
6
|
-
class Repository <
|
6
|
+
class Repository < RDF::Repository
|
7
7
|
# @return [SPARQL::Client]
|
8
8
|
attr_reader :client
|
9
9
|
|
@@ -24,8 +24,7 @@ module SPARQL; class Client
|
|
24
24
|
# @see RDF::Repository#each
|
25
25
|
def each(&block)
|
26
26
|
unless block_given?
|
27
|
-
|
28
|
-
::Enumerable::Enumerator.new(self, :each)
|
27
|
+
RDF::Enumerator.new(self, :each)
|
29
28
|
else
|
30
29
|
client.construct([:s, :p, :o]).where([:s, :p, :o]).each_statement(&block)
|
31
30
|
end
|
@@ -70,8 +69,7 @@ module SPARQL; class Client
|
|
70
69
|
# @see RDF::Repository#each_subject?
|
71
70
|
def each_subject(&block)
|
72
71
|
unless block_given?
|
73
|
-
|
74
|
-
::Enumerable::Enumerator.new(self, :each_subject)
|
72
|
+
RDF::Enumerator.new(self, :each_subject)
|
75
73
|
else
|
76
74
|
client.select(:s, :distinct => true).where([:s, :p, :o]).each { |solution| block.call(solution[:s]) }
|
77
75
|
end
|
@@ -86,8 +84,7 @@ module SPARQL; class Client
|
|
86
84
|
# @see RDF::Repository#each_predicate?
|
87
85
|
def each_predicate(&block)
|
88
86
|
unless block_given?
|
89
|
-
|
90
|
-
::Enumerable::Enumerator.new(self, :each_predicate)
|
87
|
+
RDF::Enumerator.new(self, :each_predicate)
|
91
88
|
else
|
92
89
|
client.select(:p, :distinct => true).where([:s, :p, :o]).each { |solution| block.call(solution[:p]) }
|
93
90
|
end
|
@@ -102,8 +99,7 @@ module SPARQL; class Client
|
|
102
99
|
# @see RDF::Repository#each_object?
|
103
100
|
def each_object(&block)
|
104
101
|
unless block_given?
|
105
|
-
|
106
|
-
::Enumerable::Enumerator.new(self, :each_object)
|
102
|
+
RDF::Enumerator.new(self, :each_object)
|
107
103
|
else
|
108
104
|
client.select(:o, :distinct => true).where([:s, :p, :o]).each { |solution| block.call(solution[:o]) }
|
109
105
|
end
|
@@ -158,6 +154,37 @@ module SPARQL; class Client
|
|
158
154
|
client.ask.whether([:s, :p, :o]).false?
|
159
155
|
end
|
160
156
|
|
157
|
+
##
|
158
|
+
# Queries `self` for RDF statements matching the given `pattern`.
|
159
|
+
#
|
160
|
+
# @example
|
161
|
+
# repository.query([nil, RDF::DOAP.developer, nil])
|
162
|
+
# repository.query(:predicate => RDF::DOAP.developer)
|
163
|
+
#
|
164
|
+
# @param [Query, Statement, Array(Value), Hash] pattern
|
165
|
+
# @yield [statement]
|
166
|
+
# @yieldparam [Statement]
|
167
|
+
# @return [Enumerable<Statement>]
|
168
|
+
def query(pattern, &block)
|
169
|
+
case pattern
|
170
|
+
when RDF::Query::Pattern
|
171
|
+
query = client.construct(pattern).where(pattern)
|
172
|
+
if block_given?
|
173
|
+
query.each_statement(&block)
|
174
|
+
else
|
175
|
+
query.solutions.to_a.extend(RDF::Enumerable, RDF::Queryable)
|
176
|
+
end
|
177
|
+
when RDF::Statement
|
178
|
+
query(RDF::Query::Pattern.new({
|
179
|
+
:subject => pattern.subject || :s,
|
180
|
+
:predicate => pattern.predicate || :p,
|
181
|
+
:object => pattern.object || :o,
|
182
|
+
}), &block)
|
183
|
+
else
|
184
|
+
super(pattern, &block)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
161
188
|
##
|
162
189
|
# Returns `false` to indicate that this is a read-only repository.
|
163
190
|
#
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Arto Bendiken
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-05-21 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -23,13 +23,13 @@ dependencies:
|
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 0
|
30
30
|
- 1
|
31
|
-
-
|
32
|
-
version: 0.1.
|
31
|
+
- 10
|
32
|
+
version: 0.1.10
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -56,8 +56,8 @@ dependencies:
|
|
56
56
|
segments:
|
57
57
|
- 0
|
58
58
|
- 5
|
59
|
-
-
|
60
|
-
version: 0.5.
|
59
|
+
- 4
|
60
|
+
version: 0.5.4
|
61
61
|
type: :development
|
62
62
|
version_requirements: *id003
|
63
63
|
- !ruby/object:Gem::Dependency
|
@@ -65,13 +65,13 @@ dependencies:
|
|
65
65
|
prerelease: false
|
66
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
segments:
|
71
71
|
- 0
|
72
72
|
- 1
|
73
|
-
-
|
74
|
-
version: 0.1.
|
73
|
+
- 10
|
74
|
+
version: 0.1.10
|
75
75
|
type: :runtime
|
76
76
|
version_requirements: *id004
|
77
77
|
- !ruby/object:Gem::Dependency
|
@@ -79,13 +79,13 @@ dependencies:
|
|
79
79
|
prerelease: false
|
80
80
|
requirement: &id005 !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ~>
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
segments:
|
85
85
|
- 1
|
86
|
-
-
|
87
|
-
-
|
88
|
-
version: 1.
|
86
|
+
- 4
|
87
|
+
- 0
|
88
|
+
version: 1.4.0
|
89
89
|
type: :runtime
|
90
90
|
version_requirements: *id005
|
91
91
|
description: SPARQL client for RDF.rb.
|
@@ -98,6 +98,7 @@ extra_rdoc_files: []
|
|
98
98
|
|
99
99
|
files:
|
100
100
|
- AUTHORS
|
101
|
+
- CONTRIBUTORS
|
101
102
|
- README
|
102
103
|
- UNLICENSE
|
103
104
|
- VERSION
|