doc/rdoc/classes/SparqlAdapter.src/M000004.html in activerdf_sparql-1.3.1 vs doc/rdoc/classes/SparqlAdapter.src/M000004.html in activerdf_sparql-1.3.2
- old
+ new
@@ -8,45 +8,48 @@
<title>execute_sparql_query (SparqlAdapter)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre> <span class="ruby-comment cmt"># File lib/activerdf_sparql/sparql.rb, line 46</span>
-46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute_sparql_query</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">header</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
-47: <span class="ruby-identifier">header</span> = <span class="ruby-identifier">header</span>(<span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">header</span>.<span class="ruby-identifier">nil?</span>
-48:
-49: <span class="ruby-comment cmt"># encoding query string in URL</span>
-50: <span class="ruby-identifier">url</span> = <span class="ruby-node">"#@url?query=#{CGI.escape(qs)}"</span>
-51: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"executing: requesting #{url}"</span>
-52:
-53: <span class="ruby-comment cmt"># querying sparql endpoint</span>
-54: <span class="ruby-identifier">response</span> = <span class="ruby-value str">''</span>
-55: <span class="ruby-keyword kw">begin</span>
-56: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">header</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
-57: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>
-58: <span class="ruby-keyword kw">end</span>
-59: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OpenURI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
-60: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-node">"could not query SPARQL endpoint, server said: #{e}"</span>
-61: <span class="ruby-keyword kw">return</span> []
-62: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNREFUSED</span>
-63: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-value str">"connection refused on SPARQL endpoint #@url"</span>
-64: <span class="ruby-keyword kw">return</span> []
-65: <span class="ruby-keyword kw">end</span>
-66:
-67: <span class="ruby-comment cmt"># we parse content depending on the result format</span>
-68: <span class="ruby-identifier">results</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@result_format</span>
-69: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:json</span>
-70: <span class="ruby-identifier">parse_json</span>(<span class="ruby-identifier">response</span>)
-71: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:xml</span>, <span class="ruby-identifier">:sparql_xml</span>
-72: <span class="ruby-identifier">parse_xml</span>(<span class="ruby-identifier">response</span>)
-73: <span class="ruby-keyword kw">end</span>
-74:
-75: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
-76: <span class="ruby-identifier">results</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">clauses</span><span class="ruby-operator">|</span>
-77: <span class="ruby-keyword kw">yield</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">clauses</span>)
-78: <span class="ruby-keyword kw">end</span>
-79: <span class="ruby-keyword kw">else</span>
-80: <span class="ruby-identifier">results</span>
-81: <span class="ruby-keyword kw">end</span>
-82: <span class="ruby-keyword kw">end</span></pre>
+ <pre> <span class="ruby-comment cmt"># File lib/activerdf_sparql/sparql.rb, line 49</span>
+49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute_sparql_query</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">header</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
+50: <span class="ruby-identifier">header</span> = <span class="ruby-identifier">header</span>(<span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">header</span>.<span class="ruby-identifier">nil?</span>
+51:
+52: <span class="ruby-comment cmt"># encoding query string in URL</span>
+53: <span class="ruby-identifier">url</span> = <span class="ruby-node">"#@url?query=#{CGI.escape(qs)}"</span>
+54: <span class="ruby-comment cmt">#url += "&content-type=#{CGI.escape('application/sparql-results+xml')}" if @yars2</span>
+55: <span class="ruby-identifier">url</span> = <span class="ruby-identifier">url</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">"DISTINCT"</span>, <span class="ruby-value str">""</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@yars2</span>
+56: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"executing: requesting #{url}"</span>
+57:
+58: <span class="ruby-comment cmt"># querying sparql endpoint</span>
+59: <span class="ruby-identifier">response</span> = <span class="ruby-value str">''</span>
+60: <span class="ruby-keyword kw">begin</span>
+61: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">header</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
+62: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>
+63: <span class="ruby-keyword kw">end</span>
+64: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OpenURI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
+65: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-node">"could not query SPARQL endpoint, server said: #{e}"</span>
+66: <span class="ruby-keyword kw">return</span> []
+67: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNREFUSED</span>
+68: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-value str">"connection refused on SPARQL endpoint #@url"</span>
+69: <span class="ruby-keyword kw">return</span> []
+70: <span class="ruby-keyword kw">end</span>
+71: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"response:\n#{response}"</span>
+72:
+73: <span class="ruby-comment cmt"># we parse content depending on the result format</span>
+74: <span class="ruby-identifier">results</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@result_format</span>
+75: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:json</span>
+76: <span class="ruby-identifier">parse_json</span>(<span class="ruby-identifier">response</span>)
+77: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:xml</span>, <span class="ruby-identifier">:sparql_xml</span>
+78: <span class="ruby-identifier">parse_xml</span>(<span class="ruby-identifier">response</span>)
+79: <span class="ruby-keyword kw">end</span>
+80:
+81: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
+82: <span class="ruby-identifier">results</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">clauses</span><span class="ruby-operator">|</span>
+83: <span class="ruby-keyword kw">yield</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">clauses</span>)
+84: <span class="ruby-keyword kw">end</span>
+85: <span class="ruby-keyword kw">else</span>
+86: <span class="ruby-identifier">results</span>
+87: <span class="ruby-keyword kw">end</span>
+88: <span class="ruby-keyword kw">end</span></pre>
</body>
</html>
\ No newline at end of file