sparql-client 0.0.9 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/CREDITS CHANGED
@@ -5,3 +5,4 @@
5
5
  * Fumihiro Kato <fumi@fumi.me>
6
6
  * David Nielsen <david@graveyard.dk>
7
7
  * Thamaraiselvan Poomalai <p.thamarai@gmail.com>
8
+ * Gregg Kellogg <gregg@greggkellogg.net>
data/README CHANGED
@@ -113,6 +113,7 @@ Contributors
113
113
  * [Fumihiro Kato](http://github.com/fumi) - <http://fumi.me/>
114
114
  * [David Nielsen](http://github.com/drankard) - <http://github.com/drankard>
115
115
  * [Thamaraiselvan Poomalai](http://github.com/selvan) - <http://softonaut.blogspot.com/>
116
+ * [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
116
117
 
117
118
  Contributing
118
119
  ------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.11
@@ -1,4 +1,4 @@
1
- require 'net/http'
1
+ require 'net/http/persistent'
2
2
  require 'rdf' # @see http://rubygems.org/gems/rdf
3
3
  require 'rdf/ntriples'
4
4
 
@@ -29,10 +29,14 @@ module SPARQL
29
29
  ##
30
30
  # @param [String, #to_s] url
31
31
  # @param [Hash{Symbol => Object}] options
32
+ # @option options [Hash] :headers
32
33
  def initialize(url, options = {}, &block)
33
34
  @url, @options = RDF::URI.new(url.to_s), options
34
35
  #@headers = {'Accept' => "#{RESULT_JSON}, #{RESULT_XML}, text/plain"}
35
- @headers = {'Accept' => [RESULT_JSON, RESULT_XML, RDF::Format.content_types.collect { |k,v| k.to_s }].join(', ')}
36
+ @headers = {
37
+ 'Accept' => [RESULT_JSON, RESULT_XML, RDF::Format.content_types.keys.map(&:to_s)].join(', ')
38
+ }.merge @options[:headers] || {}
39
+ @http = http_klass(@url.scheme)
36
40
 
37
41
  if block_given?
38
42
  case block.arity
@@ -101,6 +105,7 @@ module SPARQL
101
105
  # @param [String, #to_s] url
102
106
  # @param [Hash{Symbol => Object}] options
103
107
  # @option options [String] :content_type
108
+ # @option options [Hash] :headers
104
109
  # @return [Array<RDF::Query::Solution>]
105
110
  def query(query, options = {})
106
111
  parse_response(response(query, options), options)
@@ -112,10 +117,11 @@ module SPARQL
112
117
  # @param [String, #to_s] url
113
118
  # @param [Hash{Symbol => Object}] options
114
119
  # @option options [String] :content_type
120
+ # @option options [Hash] :headers
115
121
  # @return [String]
116
122
  def response(query, options = {})
117
123
  @headers['Accept'] = options[:content_type] if options[:content_type]
118
- get(query) do |response|
124
+ get(query, options[:headers] || {}) do |response|
119
125
  case response
120
126
  when Net::HTTPBadRequest # 400 Bad Request
121
127
  raise MalformedQuery.new(response.body)
@@ -270,11 +276,9 @@ module SPARQL
270
276
  when "https"
271
277
  proxy_uri = URI.parse(ENV['https_proxy']) unless ENV['https_proxy'].nil?
272
278
  end
273
- return Net::HTTP if proxy_uri.nil?
274
-
275
- proxy_host, proxy_port = proxy_uri.host, proxy_uri.port
276
- proxy_user, proxy_pass = proxy_uri.userinfo.split(/:/) if proxy_uri.userinfo
277
- Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass)
279
+ klass = Net::HTTP::Persistent.new(self.class.to_s, proxy_uri)
280
+ klass.keep_alive = 120 # increase to 2 minutes
281
+ klass
278
282
  end
279
283
 
280
284
  ##
@@ -289,13 +293,13 @@ module SPARQL
289
293
  url = self.url.dup
290
294
  url.query_values = {:query => query.to_s}
291
295
 
292
- http_klass(url.scheme).start(url.host, url.port) do |http|
293
- response = http.get(url.path + "?#{url.query}", @headers.merge(headers))
294
- if block_given?
295
- block.call(response)
296
- else
297
- response
298
- end
296
+ request = Net::HTTP::Get.new(url.request_uri, @headers.merge(headers))
297
+ request.basic_auth url.user, url.password if url.user && !url.user.empty?
298
+ response = @http.request url, request
299
+ if block_given?
300
+ block.call(response)
301
+ else
302
+ response
299
303
  end
300
304
  end
301
305
  end # Client
@@ -73,7 +73,7 @@ module SPARQL; class Client
73
73
  # @yieldparam [Query]
74
74
  def initialize(form = :ask, options = {}, &block)
75
75
  @form = form.respond_to?(:to_sym) ? form.to_sym : form.to_s.to_sym
76
- super(options.dup, &block)
76
+ super([], options, &block)
77
77
  end
78
78
 
79
79
  ##
@@ -2,7 +2,7 @@ module SPARQL; class Client
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 9
5
+ TINY = 11
6
6
  EXTRA = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparql-client
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 9
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 9
9
- version: 0.0.9
9
+ - 11
10
+ version: 0.0.11
10
11
  platform: ruby
11
12
  authors:
12
13
  - Arto Bendiken
@@ -15,8 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-02-02 00:00:00 +01:00
19
- default_executable:
19
+ date: 2011-10-03 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: json_pure
@@ -26,6 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
+ hash: 3
29
30
  segments:
30
31
  - 1
31
32
  - 4
@@ -39,60 +40,80 @@ dependencies:
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
- - - ~>
43
+ - - ">="
43
44
  - !ruby/object:Gem::Version
45
+ hash: 27
44
46
  segments:
45
47
  - 0
46
48
  - 3
47
- - 0
48
- version: 0.3.0
49
+ - 4
50
+ version: 0.3.4
49
51
  type: :runtime
50
52
  version_requirements: *id002
51
53
  - !ruby/object:Gem::Dependency
52
- name: yard
54
+ name: net-http-persistent
53
55
  prerelease: false
54
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 5
62
+ segments:
63
+ - 1
64
+ - 4
65
+ - 1
66
+ version: 1.4.1
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
55
73
  none: false
56
74
  requirements:
57
75
  - - ">="
58
76
  - !ruby/object:Gem::Version
77
+ hash: 7
59
78
  segments:
60
79
  - 0
61
80
  - 6
62
81
  - 0
63
82
  version: 0.6.0
64
83
  type: :development
65
- version_requirements: *id003
84
+ version_requirements: *id004
66
85
  - !ruby/object:Gem::Dependency
67
86
  name: rspec
68
87
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
70
89
  none: false
71
90
  requirements:
72
91
  - - ">="
73
92
  - !ruby/object:Gem::Version
93
+ hash: 11
74
94
  segments:
75
95
  - 2
76
96
  - 1
77
97
  - 0
78
98
  version: 2.1.0
79
99
  type: :development
80
- version_requirements: *id004
100
+ version_requirements: *id005
81
101
  - !ruby/object:Gem::Dependency
82
102
  name: rdf-spec
83
103
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
85
105
  none: false
86
106
  requirements:
87
- - - ~>
107
+ - - ">="
88
108
  - !ruby/object:Gem::Version
109
+ hash: 19
89
110
  segments:
90
111
  - 0
91
112
  - 3
92
113
  - 0
93
114
  version: 0.3.0
94
115
  type: :development
95
- version_requirements: *id005
116
+ version_requirements: *id006
96
117
  description: SPARQL client for RDF.rb.
97
118
  email: public-rdf-ruby@w3.org
98
119
  executables: []
@@ -111,8 +132,6 @@ files:
111
132
  - lib/sparql/client/repository.rb
112
133
  - lib/sparql/client/version.rb
113
134
  - lib/sparql/client.rb
114
- - lib/sparql.rb
115
- has_rdoc: false
116
135
  homepage: http://sparql.rubyforge.org/client/
117
136
  licenses:
118
137
  - Public Domain
@@ -126,6 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
145
  requirements:
127
146
  - - ">="
128
147
  - !ruby/object:Gem::Version
148
+ hash: 53
129
149
  segments:
130
150
  - 1
131
151
  - 8
@@ -136,13 +156,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
156
  requirements:
137
157
  - - ">="
138
158
  - !ruby/object:Gem::Version
159
+ hash: 3
139
160
  segments:
140
161
  - 0
141
162
  version: "0"
142
163
  requirements: []
143
164
 
144
165
  rubyforge_project: sparql
145
- rubygems_version: 1.3.7
166
+ rubygems_version: 1.8.10
146
167
  signing_key:
147
168
  specification_version: 3
148
169
  summary: SPARQL client for RDF.rb.
@@ -1,8 +0,0 @@
1
- module SPARQL
2
- # @see http://rubygems.org/gems/sparql-algebra
3
- autoload :Algebra, 'sparql/algebra'
4
- # @see http://rubygems.org/gems/sparql-grammar
5
- autoload :Grammar, 'sparql/grammar'
6
- # @see http://rubygems.org/gems/sparql-client
7
- autoload :Client, 'sparql/client'
8
- end