rdf-virtuoso 0.1.5 → 0.1.6
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/lib/rdf/virtuoso/query.rb +2 -13
- data/lib/rdf/virtuoso/repository.rb +6 -7
- data/lib/rdf/virtuoso/version.rb +1 -1
- data/spec/query_spec.rb +6 -6
- data/spec/repository_spec.rb +6 -7
- data/spec/spec_helper.rb +5 -1
- metadata +17 -15
data/lib/rdf/virtuoso/query.rb
CHANGED
@@ -228,13 +228,6 @@ module RDF::Virtuoso
|
|
228
228
|
self
|
229
229
|
end
|
230
230
|
|
231
|
-
# def delete(*variables)
|
232
|
-
# @values = variables.map { |var|
|
233
|
-
# [var, var.is_a?(RDF::URI) ? var : RDF::Query::Variable.new(var)]
|
234
|
-
# }
|
235
|
-
# self
|
236
|
-
# end
|
237
|
-
|
238
231
|
def create(uri)
|
239
232
|
options[:graph] = uri
|
240
233
|
self
|
@@ -271,8 +264,6 @@ module RDF::Virtuoso
|
|
271
264
|
def from_named(uri)
|
272
265
|
(options[:from_named] ||= []) << uri
|
273
266
|
self
|
274
|
-
#options[:from_named] = uri
|
275
|
-
#self
|
276
267
|
end
|
277
268
|
|
278
269
|
# @param RDF::URI uri
|
@@ -350,7 +341,6 @@ module RDF::Virtuoso
|
|
350
341
|
|
351
342
|
AGG_METHODS.each do |m|
|
352
343
|
define_method m do |*variables|
|
353
|
-
#options[m.to_sym] = variables
|
354
344
|
options[m.to_sym] ||= []
|
355
345
|
options[m.to_sym] += variables
|
356
346
|
self
|
@@ -486,10 +476,10 @@ module RDF::Virtuoso
|
|
486
476
|
|
487
477
|
##
|
488
478
|
# @return [Object]
|
489
|
-
def execute
|
479
|
+
# def execute
|
490
480
|
#query
|
491
481
|
#raise NotImplementedError
|
492
|
-
end
|
482
|
+
# end
|
493
483
|
|
494
484
|
##
|
495
485
|
# Returns the string representation of this query.
|
@@ -507,7 +497,6 @@ module RDF::Virtuoso
|
|
507
497
|
aggregates = [:count, :min, :max, :avg, :sum, :sample, :group_concat, :group_digest]
|
508
498
|
if (options.keys & aggregates).any?
|
509
499
|
(options.keys & aggregates).each do |agg|
|
510
|
-
#p options[agg]
|
511
500
|
case agg
|
512
501
|
when :sample
|
513
502
|
# multiple samples splits to individual sample expressions
|
@@ -5,7 +5,7 @@ require 'timeout'
|
|
5
5
|
|
6
6
|
module RDF
|
7
7
|
module Virtuoso
|
8
|
-
class Repository
|
8
|
+
class Repository < ::RDF::Repository
|
9
9
|
include APISmith::Client
|
10
10
|
|
11
11
|
RESULT_JSON = 'application/sparql-results+json'.freeze
|
@@ -20,13 +20,12 @@ module RDF
|
|
20
20
|
class NotAuthorized < ClientError; end
|
21
21
|
class ServerError < StandardError; end
|
22
22
|
|
23
|
-
# TODO: Look at issues with HTTParty Connection reset
|
24
23
|
#persistent
|
25
24
|
maintain_method_across_redirects true
|
26
25
|
|
27
26
|
attr_reader :uri, :update_uri, :username, :password, :auth_method
|
28
27
|
|
29
|
-
def initialize(uri, opts={})
|
28
|
+
def initialize(uri, opts={}, &block)
|
30
29
|
@uri = URI.parse(uri)
|
31
30
|
@update_uri = URI.parse(opts[:update_uri]) if opts[:update_uri]
|
32
31
|
@base_uri = "#{@uri.scheme}://#{@uri.host}"
|
@@ -41,8 +40,8 @@ module RDF
|
|
41
40
|
self.class.base_uri @base_uri
|
42
41
|
end
|
43
42
|
|
44
|
-
READ_METHODS = %w(select ask construct describe)
|
45
|
-
WRITE_METHODS = %w(
|
43
|
+
READ_METHODS = %w(query select ask construct describe)
|
44
|
+
WRITE_METHODS = %w(insert insert_data update delete delete_data create drop clear)
|
46
45
|
|
47
46
|
READ_METHODS.each do |m|
|
48
47
|
define_method m do |*args|
|
@@ -55,7 +54,7 @@ module RDF
|
|
55
54
|
response = api_post *args
|
56
55
|
end
|
57
56
|
end
|
58
|
-
|
57
|
+
|
59
58
|
private
|
60
59
|
|
61
60
|
def check_response_errors(response)
|
@@ -74,7 +73,6 @@ module RDF
|
|
74
73
|
end
|
75
74
|
|
76
75
|
def base_query_options
|
77
|
-
#{ :format => 'json' }
|
78
76
|
{ :format => RESULT_JSON }
|
79
77
|
end
|
80
78
|
|
@@ -107,6 +105,7 @@ module RDF
|
|
107
105
|
else
|
108
106
|
self.class.endpoint @sparql_endpoint
|
109
107
|
Timeout::timeout(@timeout) {
|
108
|
+
puts self.inspect
|
110
109
|
get '/', :extra_query => { :query => query }.merge(options),
|
111
110
|
:transform => RDF::Virtuoso::Parser::JSON
|
112
111
|
}
|
data/lib/rdf/virtuoso/version.rb
CHANGED
data/spec/query_spec.rb
CHANGED
@@ -149,16 +149,16 @@ describe RDF::Virtuoso::Query do
|
|
149
149
|
it "should support SELECT with complex WHERE patterns" do
|
150
150
|
@query.select.where(
|
151
151
|
[:s, :p, :o],
|
152
|
-
[:s, RDF.type, RDF::DC.
|
152
|
+
[:s, RDF.type, RDF::DC.BibliographicResource]
|
153
153
|
).to_s.should ==
|
154
|
-
"SELECT * WHERE { ?s ?p ?o . ?s <#{RDF.type}> <#{RDF::DC.
|
154
|
+
"SELECT * WHERE { ?s ?p ?o . ?s <#{RDF.type}> <#{RDF::DC.BibliographicResource}> . }"
|
155
155
|
end
|
156
156
|
|
157
157
|
it "should support SELECT WHERE patterns from different GRAPH contexts" do
|
158
158
|
@graph1 = "http://example1.org/"
|
159
159
|
@graph2 = "http://example2.org/"
|
160
|
-
@query.select.where([:s, :p, :o, :context => @graph1],[:s, RDF.type, RDF::DC.
|
161
|
-
"SELECT * WHERE { GRAPH <#{@graph1}> { ?s ?p ?o . } GRAPH <#{@graph2}> { ?s <#{RDF.type}> <#{RDF::DC.
|
160
|
+
@query.select.where([:s, :p, :o, :context => @graph1],[:s, RDF.type, RDF::DC.BibliographicResource, :context => @graph2]).to_s.should ==
|
161
|
+
"SELECT * WHERE { GRAPH <#{@graph1}> { ?s ?p ?o . } GRAPH <#{@graph2}> { ?s <#{RDF.type}> <#{RDF::DC.BibliographicResource}> . } }"
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should support string objects in SPARQL queries" do
|
@@ -291,8 +291,8 @@ describe RDF::Virtuoso::Query do
|
|
291
291
|
it "should support OPTIONAL with GRAPH contexts" do
|
292
292
|
@graph1 = "http://example1.org/"
|
293
293
|
@graph2 = "http://example2.org/"
|
294
|
-
@query.select.where([:s, :p, :o, :context => @graph1]).optional([:s, RDF.type, RDF::DC.
|
295
|
-
"SELECT * WHERE { GRAPH <#{@graph1}> { ?s ?p ?o . } OPTIONAL { GRAPH <#{@graph2}> { ?s <#{RDF.type}> <#{RDF::DC.
|
294
|
+
@query.select.where([:s, :p, :o, :context => @graph1]).optional([:s, RDF.type, RDF::DC.BibliographicResource, :context => @graph2]).to_s.should ==
|
295
|
+
"SELECT * WHERE { GRAPH <#{@graph1}> { ?s ?p ?o . } OPTIONAL { GRAPH <#{@graph2}> { ?s <#{RDF.type}> <#{RDF::DC.BibliographicResource}> . } } }"
|
296
296
|
end
|
297
297
|
|
298
298
|
it "should support multiple OPTIONALs" do
|
data/spec/repository_spec.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
$:.unshift "."
|
2
|
-
require 'spec_helper'
|
2
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
3
|
require 'rdf/spec/repository'
|
4
|
-
|
4
|
+
|
5
5
|
describe RDF::Virtuoso::Repository do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
@uri = "http://localhost:8890/sparql"
|
9
9
|
@update_uri = "http://localhost:8890/sparql-auth"
|
10
|
+
@repository = RDF::Virtuoso::Repository.new(@uri)
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
#it_should_behave_like RDF_Repository # not working!
|
15
|
-
end
|
16
|
-
|
13
|
+
#include RDF_Repository # not implemented
|
14
|
+
|
17
15
|
it "should support connecting to a Virtuoso SPARQL endpoint" do
|
18
16
|
repo = RDF::Virtuoso::Repository.new(@uri)
|
19
17
|
repo.instance_variable_get("@sparul_endpoint").should == "/sparql"
|
@@ -38,4 +36,5 @@ describe RDF::Virtuoso::Repository do
|
|
38
36
|
repo = RDF::Virtuoso::Repository.new(@uri, :timeout => 10)
|
39
37
|
repo.instance_variable_get("@timeout").should == 10
|
40
38
|
end
|
39
|
+
|
41
40
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-virtuoso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
requirements:
|
36
36
|
- - ~>
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 1.0
|
38
|
+
version: 1.1.0
|
39
39
|
type: :development
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.0
|
46
|
+
version: 1.1.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdf
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0
|
54
|
+
version: 1.1.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.0
|
62
|
+
version: 1.1.0
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: httparty
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
requirements:
|
68
68
|
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 0.
|
70
|
+
version: 0.12.0
|
71
71
|
type: :runtime
|
72
72
|
prerelease: false
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
requirements:
|
76
76
|
- - ~>
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: 0.
|
78
|
+
version: 0.12.0
|
79
79
|
- !ruby/object:Gem::Dependency
|
80
80
|
name: api_smith
|
81
81
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +92,8 @@ dependencies:
|
|
92
92
|
- - ~>
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: 1.3.0
|
95
|
-
description: An RDF.rb extension library for interacting with a Virtuoso rdf store
|
95
|
+
description: An RDF.rb extension library for interacting with a Virtuoso rdf store.\nSupports
|
96
|
+
SPARQL 1.1 UPDATE extensions and some Virtuoso specific commands.
|
96
97
|
email:
|
97
98
|
- benjamin.rokseth@kul.oslo.kommune.no
|
98
99
|
executables: []
|
@@ -100,18 +101,19 @@ extensions: []
|
|
100
101
|
extra_rdoc_files: []
|
101
102
|
files:
|
102
103
|
- README.md
|
103
|
-
- lib/rdf/virtuoso/prefixes.rb
|
104
104
|
- lib/rdf/virtuoso/query.rb
|
105
|
-
- lib/rdf/virtuoso/
|
105
|
+
- lib/rdf/virtuoso/prefixes.rb
|
106
106
|
- lib/rdf/virtuoso/version.rb
|
107
|
+
- lib/rdf/virtuoso/repository.rb
|
107
108
|
- lib/rdf/virtuoso/parser.rb
|
108
109
|
- lib/rdf/virtuoso.rb
|
109
|
-
- spec/prefixes_spec.rb
|
110
|
-
- spec/query_spec.rb
|
111
110
|
- spec/repository_spec.rb
|
112
111
|
- spec/spec_helper.rb
|
112
|
+
- spec/prefixes_spec.rb
|
113
|
+
- spec/query_spec.rb
|
113
114
|
homepage: https://github.com/digibib/rdf-virtuoso
|
114
|
-
licenses:
|
115
|
+
licenses:
|
116
|
+
- GPL-3
|
115
117
|
post_install_message:
|
116
118
|
rdoc_options: []
|
117
119
|
require_paths:
|
@@ -130,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
132
|
version: '0'
|
131
133
|
requirements: []
|
132
134
|
rubyforge_project: rdf-virtuoso
|
133
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.23
|
134
136
|
signing_key:
|
135
137
|
specification_version: 3
|
136
138
|
summary: An RDF.rb extension library for interacting with a Virtuoso rdf store
|