rdf-virtuoso 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  require 'api_smith'
2
2
  require 'rdf'
3
3
  require 'uri'
4
+ require 'timeout'
4
5
 
5
6
  module RDF
6
7
  module Virtuoso
@@ -30,9 +31,10 @@ module RDF
30
31
  @update_uri = URI.parse(opts[:update_uri]) if opts[:update_uri]
31
32
  @base_uri = "#{@uri.scheme}://#{@uri.host}"
32
33
  @base_uri += ":" + @uri.port.to_s if @uri.port
33
- @username = opts[:username] || nil
34
+ @username = opts[:username] || nil
34
35
  @password = opts[:password] || nil
35
36
  @auth_method = opts[:auth_method] || 'digest'
37
+ @timeout = opts[:timeout] || 5 # default timeout 5 seconds
36
38
 
37
39
  @sparql_endpoint = @uri.request_uri
38
40
  @sparul_endpoint = @update_uri.nil? ? @sparql_endpoint : @update_uri.request_uri
@@ -72,7 +74,8 @@ module RDF
72
74
  end
73
75
 
74
76
  def base_query_options
75
- { :format => 'json' }
77
+ #{ :format => 'json' }
78
+ { :format => RESULT_JSON }
76
79
  end
77
80
 
78
81
  def base_request_options
@@ -87,31 +90,37 @@ module RDF
87
90
  { :digest_auth => auth }
88
91
  end
89
92
  end
90
-
93
+
91
94
  def auth
92
95
  { :username => @username, :password => @password }
93
96
  end
94
-
97
+
95
98
  def api_get(query, options = {})
96
99
  # prefer sparul endpoint with auth if present to allow SELECT/CONSTRUCT access to protected graphs
97
100
  if @sparul_endpoint
98
101
  self.class.endpoint @sparul_endpoint
99
- get '/', :extra_query => { :query => query }.merge(options),
100
- :extra_request => extra_request_options,
101
- :transform => RDF::Virtuoso::Parser::JSON
102
+ Timeout::timeout(@timeout) {
103
+ get '/', :extra_query => { :query => query }.merge(options),
104
+ :extra_request => extra_request_options,
105
+ :transform => RDF::Virtuoso::Parser::JSON
106
+ }
102
107
  else
103
108
  self.class.endpoint @sparql_endpoint
104
- get '/', :extra_query => { :query => query }.merge(options),
105
- :transform => RDF::Virtuoso::Parser::JSON
109
+ Timeout::timeout(@timeout) {
110
+ get '/', :extra_query => { :query => query }.merge(options),
111
+ :transform => RDF::Virtuoso::Parser::JSON
112
+ }
106
113
  end
107
114
  end
108
115
 
109
116
  def api_post(query, options = {})
110
117
  self.class.endpoint @sparul_endpoint
111
- post '/', :extra_body => { :query => query }.merge(options),
112
- :extra_request => extra_request_options,
113
- :response_container => [
114
- "results", "bindings", 0, "callret-0", "value"]
118
+ Timeout::timeout(@timeout) {
119
+ post '/', :extra_body => { :query => query }.merge(options),
120
+ :extra_request => extra_request_options,
121
+ :response_container => [
122
+ "results", "bindings", 0, "callret-0", "value"]
123
+ }
115
124
  end
116
125
 
117
126
  end
@@ -1,5 +1,5 @@
1
1
  module RDF
2
2
  module Virtuoso
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -33,4 +33,9 @@ describe RDF::Virtuoso::Repository do
33
33
  repo = RDF::Virtuoso::Repository.new(@uri, :update_uri => @update_uri, :username => 'admin', :password => 'secret', :auth_method => 'digest')
34
34
  repo.instance_variable_get("@sparul_endpoint").should == "/sparql-auth"
35
35
  end
36
+
37
+ it "should support timeout option" do
38
+ repo = RDF::Virtuoso::Repository.new(@uri, :timeout => 10)
39
+ repo.instance_variable_get("@timeout").should == 10
40
+ end
36
41
  end
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
4
+ version: 0.1.5
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-03-15 00:00:00.000000000 Z
13
+ date: 2013-07-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 2.13.0
22
+ version: 2.14.1
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- version: 2.13.0
30
+ version: 2.14.1
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rdf-spec
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: 1.0.0
38
+ version: 1.0.7
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.0
46
+ version: 1.0.7
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.3
54
+ version: 1.0.7
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.3
62
+ version: 1.0.7
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.10.2
70
+ version: 0.11.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.10.2
78
+ version: 0.11.0
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: api_smith
81
81
  requirement: !ruby/object:Gem::Requirement
@@ -83,7 +83,7 @@ dependencies:
83
83
  requirements:
84
84
  - - ~>
85
85
  - !ruby/object:Gem::Version
86
- version: 1.2.0
86
+ version: 1.3.0
87
87
  type: :runtime
88
88
  prerelease: false
89
89
  version_requirements: !ruby/object:Gem::Requirement
@@ -91,7 +91,7 @@ dependencies:
91
91
  requirements:
92
92
  - - ~>
93
93
  - !ruby/object:Gem::Version
94
- version: 1.2.0
94
+ version: 1.3.0
95
95
  description: An RDF.rb extension library for interacting with a Virtuoso rdf store
96
96
  email:
97
97
  - benjamin.rokseth@kul.oslo.kommune.no
@@ -100,15 +100,15 @@ extensions: []
100
100
  extra_rdoc_files: []
101
101
  files:
102
102
  - README.md
103
- - lib/rdf/virtuoso/version.rb
104
- - lib/rdf/virtuoso/query.rb
105
103
  - lib/rdf/virtuoso/prefixes.rb
104
+ - lib/rdf/virtuoso/query.rb
106
105
  - lib/rdf/virtuoso/repository.rb
106
+ - lib/rdf/virtuoso/version.rb
107
107
  - lib/rdf/virtuoso/parser.rb
108
108
  - lib/rdf/virtuoso.rb
109
- - spec/repository_spec.rb
110
109
  - spec/prefixes_spec.rb
111
110
  - spec/query_spec.rb
111
+ - spec/repository_spec.rb
112
112
  - spec/spec_helper.rb
113
113
  homepage: https://github.com/digibib/rdf-virtuoso
114
114
  licenses: []
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project: rdf-virtuoso
133
- rubygems_version: 1.8.24
133
+ rubygems_version: 1.8.25
134
134
  signing_key:
135
135
  specification_version: 3
136
136
  summary: An RDF.rb extension library for interacting with a Virtuoso rdf store