pho 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/README +9 -1
- data/Rakefile +1 -1
- data/doc/index.html +3 -1
- data/doc/rdoc/classes/Pho/Analyzers.html +310 -0
- data/doc/rdoc/classes/Pho/CommandLine.html +770 -0
- data/doc/rdoc/classes/Pho/DatatypeProperty.html +241 -0
- data/doc/rdoc/classes/Pho/Enrichment/StoreEnricher.html +410 -0
- data/doc/rdoc/classes/Pho/Enrichment.html +119 -0
- data/doc/rdoc/classes/Pho/Etags.html +310 -0
- data/doc/rdoc/classes/Pho/Facet/Results.html +299 -0
- data/doc/rdoc/classes/Pho/Facet/Term.html +177 -0
- data/doc/rdoc/classes/Pho/Facet.html +119 -0
- data/doc/rdoc/classes/Pho/FieldPredicateMap.html +695 -0
- data/doc/rdoc/classes/Pho/FieldWeighting.html +230 -0
- data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +478 -0
- data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +264 -0
- data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +259 -0
- data/doc/rdoc/classes/Pho/FileManagement.html +121 -0
- data/doc/rdoc/classes/Pho/Job.html +627 -0
- data/doc/rdoc/classes/Pho/JobUpdate.html +141 -0
- data/doc/rdoc/classes/Pho/Jobs.html +538 -0
- data/doc/rdoc/classes/Pho/Namespaces.html +164 -0
- data/doc/rdoc/classes/Pho/OAI/Record.html +165 -0
- data/doc/rdoc/classes/Pho/OAI/Records.html +331 -0
- data/doc/rdoc/classes/Pho/OAI.html +118 -0
- data/doc/rdoc/classes/Pho/QueryProfile.html +524 -0
- data/doc/rdoc/classes/Pho/RDF/Parser.html +279 -0
- data/doc/rdoc/classes/Pho/RDF.html +120 -0
- data/doc/rdoc/classes/Pho/RDFCollection.html +119 -0
- data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +325 -0
- data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +241 -0
- data/doc/rdoc/classes/Pho/ResourceHash.html +123 -0
- data/doc/rdoc/classes/Pho/Snapshot.html +402 -0
- data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +594 -0
- data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +696 -0
- data/doc/rdoc/classes/Pho/Sparql.html +187 -0
- data/doc/rdoc/classes/Pho/Status.html +296 -0
- data/doc/rdoc/classes/Pho/Store.html +1569 -0
- data/doc/rdoc/classes/Pho/StoreSparqlClient.html +183 -0
- data/doc/rdoc/classes/Pho/Update/Changeset.html +521 -0
- data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +330 -0
- data/doc/rdoc/classes/Pho/Update/ChangesetHelper.html +159 -0
- data/doc/rdoc/classes/Pho/Update/Changesets.html +205 -0
- data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +257 -0
- data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +237 -0
- data/doc/rdoc/classes/Pho/Update/Statement.html +303 -0
- data/doc/rdoc/classes/Pho/Update.html +128 -0
- data/doc/rdoc/classes/Pho.html +283 -0
- data/doc/rdoc/classes/String.html +146 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/CHANGES.html +373 -0
- data/doc/rdoc/files/README.html +204 -0
- data/doc/rdoc/files/lib/pho/changeset_builder_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/changeset_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/command_line_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/converter_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/enrichment_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/etags_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/facet_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/file_management_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/file_manager_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/job_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/oai_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/query_profile_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/rdf_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/resource_hash_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/snapshot_rb.html +109 -0
- data/doc/rdoc/files/lib/pho/sparql_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/status_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/store_rb.html +108 -0
- data/doc/rdoc/files/lib/pho_rb.html +133 -0
- data/doc/rdoc/fr_class_index.html +72 -0
- data/doc/rdoc/fr_file_index.html +49 -0
- data/doc/rdoc/fr_method_index.html +239 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/lib/pho/enrichment.rb +1 -0
- data/lib/pho/field_predicate_map.rb +5 -0
- data/lib/pho/query_profile.rb +5 -0
- data/lib/pho/store.rb +4 -1
- data/tests/tc_field_predicate_map.rb +7 -1
- data/tests/tc_query_profile.rb +6 -0
- data/tests/tc_store_util.rb +7 -0
- metadata +134 -21
@@ -0,0 +1,696 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Pho::Sparql::SparqlHelper</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Pho::Sparql::SparqlHelper</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/pho/sparql_rb.html">
|
59
|
+
lib/pho/sparql.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
Simple helper class for manipulating and executing SPARQL queries and
|
84
|
+
manipulating the results
|
85
|
+
</p>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
|
90
|
+
</div>
|
91
|
+
|
92
|
+
<div id="method-list">
|
93
|
+
<h3 class="section-bar">Methods</h3>
|
94
|
+
|
95
|
+
<div class="name-list">
|
96
|
+
<a href="#M000057">apply_initial_bindings</a>
|
97
|
+
<a href="#M000061">ask</a>
|
98
|
+
<a href="#M000065">construct_to_resource_hash</a>
|
99
|
+
<a href="#M000066">describe_to_resource_hash</a>
|
100
|
+
<a href="#M000068">describe_uri</a>
|
101
|
+
<a href="#M000062">exists</a>
|
102
|
+
<a href="#M000067">multi_describe</a>
|
103
|
+
<a href="#M000058">result_to_query_binding</a>
|
104
|
+
<a href="#M000059">results_to_query_bindings</a>
|
105
|
+
<a href="#M000060">select</a>
|
106
|
+
<a href="#M000064">select_single_value</a>
|
107
|
+
<a href="#M000063">select_values</a>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
|
114
|
+
<!-- if includes -->
|
115
|
+
|
116
|
+
<div id="section">
|
117
|
+
|
118
|
+
|
119
|
+
<div id="constants-list">
|
120
|
+
<h3 class="section-bar">Constants</h3>
|
121
|
+
|
122
|
+
<div class="name-list">
|
123
|
+
<table summary="Constants">
|
124
|
+
<tr class="top-aligned-row context-row">
|
125
|
+
<td class="context-item-name">VARIABLE_MATCHER</td>
|
126
|
+
<td>=</td>
|
127
|
+
<td class="context-item-value">/(\?|\$)([a-zA-Z]+)/</td>
|
128
|
+
</tr>
|
129
|
+
</table>
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
<!-- if method_list -->
|
139
|
+
<div id="methods">
|
140
|
+
<h3 class="section-bar">Public Class methods</h3>
|
141
|
+
|
142
|
+
<div id="method-M000057" class="method-detail">
|
143
|
+
<a name="M000057"></a>
|
144
|
+
|
145
|
+
<div class="method-heading">
|
146
|
+
<a href="#M000057" class="method-signature">
|
147
|
+
<span class="method-name">apply_initial_bindings</span><span class="method-args">(query, bindings={})</span>
|
148
|
+
</a>
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div class="method-description">
|
152
|
+
<p>
|
153
|
+
Apply some initial bindings to parameters in a query
|
154
|
+
</p>
|
155
|
+
<p>
|
156
|
+
The keys in the values hash are used to replace variables in a query The
|
157
|
+
values are supplied as is, allowing them to be provided as URIs, or typed
|
158
|
+
literals according to Turtle syntax.
|
159
|
+
</p>
|
160
|
+
<p>
|
161
|
+
Any keys in the hash that are not in the query are ignored. Any variables
|
162
|
+
not found in the hash remain unbound.
|
163
|
+
</p>
|
164
|
+
<table>
|
165
|
+
<tr><td valign="top">query:</td><td>the query whose initial bindings are to be set
|
166
|
+
|
167
|
+
</td></tr>
|
168
|
+
<tr><td valign="top">values:</td><td>hash of query name to value
|
169
|
+
|
170
|
+
</td></tr>
|
171
|
+
</table>
|
172
|
+
<p><a class="source-toggle" href="#"
|
173
|
+
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
174
|
+
<div class="method-source-code" id="M000057-source">
|
175
|
+
<pre>
|
176
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 260</span>
|
177
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">apply_initial_bindings</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">bindings</span>={})
|
178
|
+
<span class="ruby-identifier">copy</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">clone</span>()
|
179
|
+
<span class="ruby-identifier">copy</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-constant">VARIABLE_MATCHER</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pattern</span><span class="ruby-operator">|</span>
|
180
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">$2</span>
|
181
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bindings</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>)
|
182
|
+
<span class="ruby-identifier">bindings</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">to_s</span>
|
183
|
+
<span class="ruby-keyword kw">else</span>
|
184
|
+
<span class="ruby-identifier">pattern</span>
|
185
|
+
<span class="ruby-keyword kw">end</span>
|
186
|
+
<span class="ruby-keyword kw">end</span>
|
187
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">copy</span>
|
188
|
+
<span class="ruby-keyword kw">end</span>
|
189
|
+
</pre>
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div id="method-M000061" class="method-detail">
|
195
|
+
<a name="M000061"></a>
|
196
|
+
|
197
|
+
<div class="method-heading">
|
198
|
+
<a href="#M000061" class="method-signature">
|
199
|
+
<span class="method-name">ask</span><span class="method-args">(query, sparql_client)</span>
|
200
|
+
</a>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<div class="method-description">
|
204
|
+
<p>
|
205
|
+
Performs an ASK query on an endpoint, returing a boolean true/false
|
206
|
+
response
|
207
|
+
</p>
|
208
|
+
<p>
|
209
|
+
Will request the results using the SPARQL JSON results format, parse the
|
210
|
+
resulting JSON results, and extract the true/false response.
|
211
|
+
</p>
|
212
|
+
<table>
|
213
|
+
<tr><td valign="top">query:</td><td>the SPARQL SELECT query
|
214
|
+
|
215
|
+
</td></tr>
|
216
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> object
|
217
|
+
|
218
|
+
</td></tr>
|
219
|
+
</table>
|
220
|
+
<p><a class="source-toggle" href="#"
|
221
|
+
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
|
222
|
+
<div class="method-source-code" id="M000061-source">
|
223
|
+
<pre>
|
224
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 343</span>
|
225
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">ask</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
226
|
+
<span class="ruby-identifier">json</span> = <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
227
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">json</span>[<span class="ruby-value str">"boolean"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"true"</span>
|
228
|
+
<span class="ruby-keyword kw">end</span>
|
229
|
+
</pre>
|
230
|
+
</div>
|
231
|
+
</div>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
<div id="method-M000065" class="method-detail">
|
235
|
+
<a name="M000065"></a>
|
236
|
+
|
237
|
+
<div class="method-heading">
|
238
|
+
<a href="#M000065" class="method-signature">
|
239
|
+
<span class="method-name">construct_to_resource_hash</span><span class="method-args">(query, sparql_client)</span>
|
240
|
+
</a>
|
241
|
+
</div>
|
242
|
+
|
243
|
+
<div class="method-description">
|
244
|
+
<p>
|
245
|
+
Perform a SPARQL CONSTRUCT query against an endpoint, requesting the
|
246
|
+
results in JSON
|
247
|
+
</p>
|
248
|
+
<p>
|
249
|
+
Will request the results as application/json (with the expectation that it
|
250
|
+
returns RDF_JSON), and parses the resulting JSON document.
|
251
|
+
</p>
|
252
|
+
<table>
|
253
|
+
<tr><td valign="top">query:</td><td>the SPARQL SELECT query
|
254
|
+
|
255
|
+
</td></tr>
|
256
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> object
|
257
|
+
|
258
|
+
</td></tr>
|
259
|
+
</table>
|
260
|
+
<p><a class="source-toggle" href="#"
|
261
|
+
onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
|
262
|
+
<div class="method-source-code" id="M000065-source">
|
263
|
+
<pre>
|
264
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 403</span>
|
265
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">construct_to_resource_hash</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
266
|
+
<span class="ruby-comment cmt">#TODO: test whether endpoint supports json, and if not, switch to parsing XML</span>
|
267
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-identifier">sparql_client</span>.<span class="ruby-identifier">construct</span>(<span class="ruby-identifier">query</span>, <span class="ruby-value str">"application/json"</span>)
|
268
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">200</span>
|
269
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Error performing sparql query: #{resp.status} #{resp.reason}\n#{resp.content}"</span>
|
270
|
+
<span class="ruby-keyword kw">end</span>
|
271
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">ResourceHash</span><span class="ruby-operator">::</span><span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_json</span>( <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span> )
|
272
|
+
<span class="ruby-keyword kw">end</span>
|
273
|
+
</pre>
|
274
|
+
</div>
|
275
|
+
</div>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
<div id="method-M000066" class="method-detail">
|
279
|
+
<a name="M000066"></a>
|
280
|
+
|
281
|
+
<div class="method-heading">
|
282
|
+
<a href="#M000066" class="method-signature">
|
283
|
+
<span class="method-name">describe_to_resource_hash</span><span class="method-args">(query, sparql_client)</span>
|
284
|
+
</a>
|
285
|
+
</div>
|
286
|
+
|
287
|
+
<div class="method-description">
|
288
|
+
<p>
|
289
|
+
Perform a SPARQL DESCRIBE query against an endpoint, requesting the results
|
290
|
+
in JSON
|
291
|
+
</p>
|
292
|
+
<p>
|
293
|
+
Will request the results as application/json (with the expectation that it
|
294
|
+
returns RDF_JSON), and parses the resulting JSON document.
|
295
|
+
</p>
|
296
|
+
<table>
|
297
|
+
<tr><td valign="top">query:</td><td>the SPARQL SELECT query
|
298
|
+
|
299
|
+
</td></tr>
|
300
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> object
|
301
|
+
|
302
|
+
</td></tr>
|
303
|
+
</table>
|
304
|
+
<p><a class="source-toggle" href="#"
|
305
|
+
onclick="toggleCode('M000066-source');return false;">[Source]</a></p>
|
306
|
+
<div class="method-source-code" id="M000066-source">
|
307
|
+
<pre>
|
308
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 419</span>
|
309
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">describe_to_resource_hash</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
310
|
+
<span class="ruby-comment cmt">#TODO: test whether endpoint supports json, and if not, switch to parsing XML</span>
|
311
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-identifier">sparql_client</span>.<span class="ruby-identifier">describe</span>(<span class="ruby-identifier">query</span>, <span class="ruby-value str">"application/json"</span>)
|
312
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">200</span>
|
313
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Error performing sparql query: #{resp.status} #{resp.reason}\n#{resp.content}"</span>
|
314
|
+
<span class="ruby-keyword kw">end</span>
|
315
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">ResourceHash</span><span class="ruby-operator">::</span><span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_json</span>( <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span> )
|
316
|
+
<span class="ruby-keyword kw">end</span>
|
317
|
+
</pre>
|
318
|
+
</div>
|
319
|
+
</div>
|
320
|
+
</div>
|
321
|
+
|
322
|
+
<div id="method-M000068" class="method-detail">
|
323
|
+
<a name="M000068"></a>
|
324
|
+
|
325
|
+
<div class="method-heading">
|
326
|
+
<a href="#M000068" class="method-signature">
|
327
|
+
<span class="method-name">describe_uri</span><span class="method-args">(uri, sparql_client, type=:cbd)</span>
|
328
|
+
</a>
|
329
|
+
</div>
|
330
|
+
|
331
|
+
<div class="method-description">
|
332
|
+
<p>
|
333
|
+
Describe a single URI using one of several forms of Bounded Description See
|
334
|
+
<a href="SparqlClient.html#M000051">SparqlClient.describe_uri</a>
|
335
|
+
</p>
|
336
|
+
<table>
|
337
|
+
<tr><td valign="top">uri:</td><td>resource to describe
|
338
|
+
|
339
|
+
</td></tr>
|
340
|
+
<tr><td valign="top">sparql_client:</td><td>configured SPARQL client
|
341
|
+
|
342
|
+
</td></tr>
|
343
|
+
<tr><td valign="top">type:</td><td>form of bounded description to generate
|
344
|
+
|
345
|
+
</td></tr>
|
346
|
+
</table>
|
347
|
+
<p><a class="source-toggle" href="#"
|
348
|
+
onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
|
349
|
+
<div class="method-source-code" id="M000068-source">
|
350
|
+
<pre>
|
351
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 447</span>
|
352
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">describe_uri</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">sparql_client</span>, <span class="ruby-identifier">type</span>=<span class="ruby-identifier">:cbd</span>)
|
353
|
+
<span class="ruby-comment cmt">#TODO: test whether endpoint supports json, and if not, switch to parsing XML</span>
|
354
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-identifier">sparql_client</span>.<span class="ruby-identifier">describe_uri</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-value str">"application/json"</span>, <span class="ruby-identifier">type</span>)
|
355
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">200</span>
|
356
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Error performing sparql query: #{resp.status} #{resp.reason}\n#{resp.content}"</span>
|
357
|
+
<span class="ruby-keyword kw">end</span>
|
358
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">ResourceHash</span><span class="ruby-operator">::</span><span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_json</span>( <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span> )
|
359
|
+
<span class="ruby-keyword kw">end</span>
|
360
|
+
</pre>
|
361
|
+
</div>
|
362
|
+
</div>
|
363
|
+
</div>
|
364
|
+
|
365
|
+
<div id="method-M000062" class="method-detail">
|
366
|
+
<a name="M000062"></a>
|
367
|
+
|
368
|
+
<div class="method-heading">
|
369
|
+
<a href="#M000062" class="method-signature">
|
370
|
+
<span class="method-name">exists</span><span class="method-args">(uri, sparql_client)</span>
|
371
|
+
</a>
|
372
|
+
</div>
|
373
|
+
|
374
|
+
<div class="method-description">
|
375
|
+
<p>
|
376
|
+
Performs an ASK query on the SPARQL endpoint to test whether there are any
|
377
|
+
statements in the triple store about the specified uri.
|
378
|
+
</p>
|
379
|
+
<table>
|
380
|
+
<tr><td valign="top">uri:</td><td>the uri to test for
|
381
|
+
|
382
|
+
</td></tr>
|
383
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> object
|
384
|
+
|
385
|
+
</td></tr>
|
386
|
+
</table>
|
387
|
+
<p><a class="source-toggle" href="#"
|
388
|
+
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
|
389
|
+
<div class="method-source-code" id="M000062-source">
|
390
|
+
<pre>
|
391
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 353</span>
|
392
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">exists</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">sparql_client</span>)
|
393
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">ask</span>(<span class="ruby-node">"ASK { <#{uri}> ?p ?o }"</span>, <span class="ruby-identifier">sparql_client</span>)
|
394
|
+
<span class="ruby-keyword kw">end</span>
|
395
|
+
</pre>
|
396
|
+
</div>
|
397
|
+
</div>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
<div id="method-M000067" class="method-detail">
|
401
|
+
<a name="M000067"></a>
|
402
|
+
|
403
|
+
<div class="method-heading">
|
404
|
+
<a href="#M000067" class="method-signature">
|
405
|
+
<span class="method-name">multi_describe</span><span class="method-args">(uris, sparql_client)</span>
|
406
|
+
</a>
|
407
|
+
</div>
|
408
|
+
|
409
|
+
<div class="method-description">
|
410
|
+
<p>
|
411
|
+
DESCRIBE multiple resources in a single SPARQL request
|
412
|
+
</p>
|
413
|
+
<table>
|
414
|
+
<tr><td valign="top">uris:</td><td>an array of URIs
|
415
|
+
|
416
|
+
</td></tr>
|
417
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> objec
|
418
|
+
|
419
|
+
</td></tr>
|
420
|
+
</table>
|
421
|
+
<p><a class="source-toggle" href="#"
|
422
|
+
onclick="toggleCode('M000067-source');return false;">[Source]</a></p>
|
423
|
+
<div class="method-source-code" id="M000067-source">
|
424
|
+
<pre>
|
425
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 432</span>
|
426
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">multi_describe</span>(<span class="ruby-identifier">uris</span>, <span class="ruby-identifier">sparql_client</span>)
|
427
|
+
<span class="ruby-comment cmt">#TODO: test whether endpoint supports json, and if not, switch to parsing XML</span>
|
428
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-identifier">sparql_client</span>.<span class="ruby-identifier">multi_describe</span>(<span class="ruby-identifier">uris</span>, <span class="ruby-value str">"application/json"</span>)
|
429
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">200</span>
|
430
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Error performing sparql query: #{resp.status} #{resp.reason}\n#{resp.content}"</span>
|
431
|
+
<span class="ruby-keyword kw">end</span>
|
432
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">ResourceHash</span><span class="ruby-operator">::</span><span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_json</span>( <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span> )
|
433
|
+
<span class="ruby-keyword kw">end</span>
|
434
|
+
</pre>
|
435
|
+
</div>
|
436
|
+
</div>
|
437
|
+
</div>
|
438
|
+
|
439
|
+
<div id="method-M000058" class="method-detail">
|
440
|
+
<a name="M000058"></a>
|
441
|
+
|
442
|
+
<div class="method-heading">
|
443
|
+
<a href="#M000058" class="method-signature">
|
444
|
+
<span class="method-name">result_to_query_binding</span><span class="method-args">(result)</span>
|
445
|
+
</a>
|
446
|
+
</div>
|
447
|
+
|
448
|
+
<div class="method-description">
|
449
|
+
<p>
|
450
|
+
Convert a SPARQL query result binding into a hash suitable for passing to
|
451
|
+
the <a href="SparqlHelper.html#M000057">apply_initial_bindings</a> method.
|
452
|
+
</p>
|
453
|
+
<p>
|
454
|
+
The result param is assumed to be a Ruby hash that reflects the structure
|
455
|
+
of a binding in a SELECT query result (i.e. the result of parsing the
|
456
|
+
<tt>application/sparql-results+json</tt> format and extracting an specific
|
457
|
+
result binding.
|
458
|
+
</p>
|
459
|
+
<p>
|
460
|
+
The method is intended to be used to support cases where an initial <a
|
461
|
+
href="SparqlHelper.html#M000060">select</a> query is performed to extract
|
462
|
+
some variables that can later be plugged into a subsequent query
|
463
|
+
</p>
|
464
|
+
<table>
|
465
|
+
<tr><td valign="top">result:</td><td>hash conforming to structure of a <tt>binding</tt> in the SPARQL JSON
|
466
|
+
format
|
467
|
+
|
468
|
+
</td></tr>
|
469
|
+
</table>
|
470
|
+
<p><a class="source-toggle" href="#"
|
471
|
+
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
|
472
|
+
<div class="method-source-code" id="M000058-source">
|
473
|
+
<pre>
|
474
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 285</span>
|
475
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">result_to_query_binding</span>(<span class="ruby-identifier">result</span>)
|
476
|
+
<span class="ruby-identifier">hash</span> = {}
|
477
|
+
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
478
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"uri"</span>
|
479
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-node">"<#{value["value"]}>"</span>
|
480
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">value</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"literal"</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value str">"datatype"</span>))
|
481
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-node">"\"#{value["value"]}\""</span>
|
482
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">value</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"literal"</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value str">"datatype"</span>))
|
483
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-node">"\"#{value["value"]}\"^^#{value["datatype"]}"</span>
|
484
|
+
<span class="ruby-keyword kw">else</span>
|
485
|
+
<span class="ruby-comment cmt">#do nothing for bnodes</span>
|
486
|
+
<span class="ruby-keyword kw">end</span>
|
487
|
+
<span class="ruby-keyword kw">end</span>
|
488
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">hash</span>
|
489
|
+
<span class="ruby-keyword kw">end</span>
|
490
|
+
</pre>
|
491
|
+
</div>
|
492
|
+
</div>
|
493
|
+
</div>
|
494
|
+
|
495
|
+
<div id="method-M000059" class="method-detail">
|
496
|
+
<a name="M000059"></a>
|
497
|
+
|
498
|
+
<div class="method-heading">
|
499
|
+
<a href="#M000059" class="method-signature">
|
500
|
+
<span class="method-name">results_to_query_bindings</span><span class="method-args">(results)</span>
|
501
|
+
</a>
|
502
|
+
</div>
|
503
|
+
|
504
|
+
<div class="method-description">
|
505
|
+
<p>
|
506
|
+
Convert Ruby hash structured according to SPARQL JSON format into an array
|
507
|
+
of hashes by calling <a
|
508
|
+
href="SparqlHelper.html#M000058">result_to_query_binding</a> on each
|
509
|
+
binding into the results.
|
510
|
+
</p>
|
511
|
+
<p>
|
512
|
+
E.g: <tt>results = <a
|
513
|
+
href="SparqlHelper.html#M000060">Pho::Sparql::SparqlHelper.select</a>(query,
|
514
|
+
sparql_client)</tt> <tt>bindings = <a
|
515
|
+
href="SparqlHelper.html#M000059">Pho::Sparql::SparqlHelper.results_to_query_bindings(results)</a></tt>
|
516
|
+
</p>
|
517
|
+
<table>
|
518
|
+
<tr><td valign="top">results:</td><td>hash conforming to SPARQL SELECT structure
|
519
|
+
|
520
|
+
</td></tr>
|
521
|
+
</table>
|
522
|
+
<p><a class="source-toggle" href="#"
|
523
|
+
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
|
524
|
+
<div class="method-source-code" id="M000059-source">
|
525
|
+
<pre>
|
526
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 310</span>
|
527
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">results_to_query_bindings</span>(<span class="ruby-identifier">results</span>)
|
528
|
+
<span class="ruby-identifier">bindings</span> = []
|
529
|
+
|
530
|
+
<span class="ruby-identifier">results</span>[<span class="ruby-value str">"results"</span>][<span class="ruby-value str">"bindings"</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">result</span><span class="ruby-operator">|</span>
|
531
|
+
<span class="ruby-identifier">bindings</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">result_to_query_binding</span>(<span class="ruby-identifier">result</span>)
|
532
|
+
<span class="ruby-keyword kw">end</span>
|
533
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">bindings</span>
|
534
|
+
<span class="ruby-keyword kw">end</span>
|
535
|
+
</pre>
|
536
|
+
</div>
|
537
|
+
</div>
|
538
|
+
</div>
|
539
|
+
|
540
|
+
<div id="method-M000060" class="method-detail">
|
541
|
+
<a name="M000060"></a>
|
542
|
+
|
543
|
+
<div class="method-heading">
|
544
|
+
<a href="#M000060" class="method-signature">
|
545
|
+
<span class="method-name">select</span><span class="method-args">(query, sparql_client)</span>
|
546
|
+
</a>
|
547
|
+
</div>
|
548
|
+
|
549
|
+
<div class="method-description">
|
550
|
+
<p>
|
551
|
+
Perform a simple SELECT query on an endpoint. Will request the results
|
552
|
+
using the SPARQL JSON results format, and parse the resulting JSON results.
|
553
|
+
The result will therefore be a simple ruby hash of the results
|
554
|
+
</p>
|
555
|
+
<p>
|
556
|
+
An error will be raised if the response is HTTP OK.
|
557
|
+
</p>
|
558
|
+
<table>
|
559
|
+
<tr><td valign="top">query:</td><td>the SPARQL SELECT query
|
560
|
+
|
561
|
+
</td></tr>
|
562
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> object
|
563
|
+
|
564
|
+
</td></tr>
|
565
|
+
</table>
|
566
|
+
<p><a class="source-toggle" href="#"
|
567
|
+
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
|
568
|
+
<div class="method-source-code" id="M000060-source">
|
569
|
+
<pre>
|
570
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 327</span>
|
571
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
572
|
+
<span class="ruby-comment cmt">#TODO: test whether endpoint supports json, and if not, switch to parsing XML</span>
|
573
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-identifier">sparql_client</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">query</span>, <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Sparql</span><span class="ruby-operator">::</span><span class="ruby-constant">SPARQL_RESULTS_JSON</span>)
|
574
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">200</span>
|
575
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Error performing sparql query: #{resp.status} #{resp.reason}\n#{resp.content}"</span>
|
576
|
+
<span class="ruby-keyword kw">end</span>
|
577
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>( <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span> )
|
578
|
+
<span class="ruby-keyword kw">end</span>
|
579
|
+
</pre>
|
580
|
+
</div>
|
581
|
+
</div>
|
582
|
+
</div>
|
583
|
+
|
584
|
+
<div id="method-M000064" class="method-detail">
|
585
|
+
<a name="M000064"></a>
|
586
|
+
|
587
|
+
<div class="method-heading">
|
588
|
+
<a href="#M000064" class="method-signature">
|
589
|
+
<span class="method-name">select_single_value</span><span class="method-args">(query, sparql_client)</span>
|
590
|
+
</a>
|
591
|
+
</div>
|
592
|
+
|
593
|
+
<div class="method-description">
|
594
|
+
<p>
|
595
|
+
Perform a simple SELECT query on an endpoint and return a single result
|
596
|
+
</p>
|
597
|
+
<p>
|
598
|
+
Will request the results using the SPARQL JSON results format, and parse
|
599
|
+
the resulting JSON results. The assumption is that the SELECT query returns
|
600
|
+
a single value (i.e single variable, with single binding)
|
601
|
+
</p>
|
602
|
+
<p>
|
603
|
+
Note this will lose any type information, only the value of the binding is
|
604
|
+
returned
|
605
|
+
</p>
|
606
|
+
<table>
|
607
|
+
<tr><td valign="top">query:</td><td>the SPARQL SELECT query
|
608
|
+
|
609
|
+
</td></tr>
|
610
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> object
|
611
|
+
|
612
|
+
</td></tr>
|
613
|
+
</table>
|
614
|
+
<p><a class="source-toggle" href="#"
|
615
|
+
onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
|
616
|
+
<div class="method-source-code" id="M000064-source">
|
617
|
+
<pre>
|
618
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 390</span>
|
619
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select_single_value</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
620
|
+
<span class="ruby-identifier">results</span> = <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
621
|
+
<span class="ruby-identifier">v</span> = <span class="ruby-identifier">results</span>[<span class="ruby-value str">"head"</span>][<span class="ruby-value str">"vars"</span>][<span class="ruby-value">0</span>];
|
622
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">results</span>[<span class="ruby-value str">"results"</span>][<span class="ruby-value str">"bindings"</span>][<span class="ruby-value">0</span>][<span class="ruby-identifier">v</span>][<span class="ruby-value str">"value"</span>]
|
623
|
+
<span class="ruby-keyword kw">end</span>
|
624
|
+
</pre>
|
625
|
+
</div>
|
626
|
+
</div>
|
627
|
+
</div>
|
628
|
+
|
629
|
+
<div id="method-M000063" class="method-detail">
|
630
|
+
<a name="M000063"></a>
|
631
|
+
|
632
|
+
<div class="method-heading">
|
633
|
+
<a href="#M000063" class="method-signature">
|
634
|
+
<span class="method-name">select_values</span><span class="method-args">(query, sparql_client)</span>
|
635
|
+
</a>
|
636
|
+
</div>
|
637
|
+
|
638
|
+
<div class="method-description">
|
639
|
+
<p>
|
640
|
+
Perform a simple SELECT query on an endpoint and return a simple array of
|
641
|
+
values
|
642
|
+
</p>
|
643
|
+
<p>
|
644
|
+
Will request the results using the SPARQL JSON results format, and parse
|
645
|
+
the resulting JSON results. The assumption is that the SELECT query
|
646
|
+
contains a single "column" of values, which will be returned as
|
647
|
+
an array
|
648
|
+
</p>
|
649
|
+
<p>
|
650
|
+
Note this will lose any type information, only the value of the bindings
|
651
|
+
are returned
|
652
|
+
</p>
|
653
|
+
<p>
|
654
|
+
Also note that if row has an empty binding for the selected variable, then
|
655
|
+
this row will be dropped from the resulting array
|
656
|
+
</p>
|
657
|
+
<table>
|
658
|
+
<tr><td valign="top">query:</td><td>the SPARQL SELECT query
|
659
|
+
|
660
|
+
</td></tr>
|
661
|
+
<tr><td valign="top">sparql_client:</td><td>a configured <a href="SparqlClient.html">SparqlClient</a> object
|
662
|
+
|
663
|
+
</td></tr>
|
664
|
+
</table>
|
665
|
+
<p><a class="source-toggle" href="#"
|
666
|
+
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
|
667
|
+
<div class="method-source-code" id="M000063-source">
|
668
|
+
<pre>
|
669
|
+
<span class="ruby-comment cmt"># File lib/pho/sparql.rb, line 370</span>
|
670
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select_values</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
671
|
+
<span class="ruby-identifier">results</span> = <span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">query</span>, <span class="ruby-identifier">sparql_client</span>)
|
672
|
+
<span class="ruby-identifier">v</span> = <span class="ruby-identifier">results</span>[<span class="ruby-value str">"head"</span>][<span class="ruby-value str">"vars"</span>][<span class="ruby-value">0</span>];
|
673
|
+
<span class="ruby-identifier">values</span> = [];
|
674
|
+
<span class="ruby-identifier">results</span>[<span class="ruby-value str">"results"</span>][<span class="ruby-value str">"bindings"</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">binding</span><span class="ruby-operator">|</span>
|
675
|
+
<span class="ruby-identifier">values</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">binding</span>[<span class="ruby-identifier">v</span>][<span class="ruby-value str">"value"</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">binding</span>[<span class="ruby-identifier">v</span>]
|
676
|
+
<span class="ruby-keyword kw">end</span>
|
677
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">values</span>
|
678
|
+
<span class="ruby-keyword kw">end</span>
|
679
|
+
</pre>
|
680
|
+
</div>
|
681
|
+
</div>
|
682
|
+
</div>
|
683
|
+
|
684
|
+
|
685
|
+
</div>
|
686
|
+
|
687
|
+
|
688
|
+
</div>
|
689
|
+
|
690
|
+
|
691
|
+
<div id="validator-badges">
|
692
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
693
|
+
</div>
|
694
|
+
|
695
|
+
</body>
|
696
|
+
</html>
|