rufus-jig 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -2,6 +2,11 @@
2
2
  = rufus-jig CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-jig - 0.1.4 released 2009/12/15
6
+
7
+ - made jig/patron thread-safe
8
+
9
+
5
10
  == rufus-jig - 0.1.3 released 2009/12/15
6
11
 
7
12
  - delete(doc) without _rev now raises ArgumentError
@@ -289,50 +289,48 @@ if defined?(Patron) # gem install patron
289
289
  def initialize (host, port, opts={})
290
290
 
291
291
  super(host, port, opts)
292
-
293
- refresh
294
292
  end
295
293
 
296
- # Patron sessions tends to wear out. Have to refresh them.
294
+ protected
295
+
296
+ # One patron session per thread
297
297
  #
298
- def refresh
298
+ def get_patron
299
299
 
300
- @patron = Patron::Session.new
301
- @patron.base_url = "#{@host}:#{@port}"
300
+ patron = Thread.current["#{self.class}_patron"]
302
301
 
303
- @patron.headers['User-Agent'] =
304
- @options[:user_agent] || "#{self.class} #{Rufus::Jig::VERSION} (patron)"
305
- end
302
+ return patron if patron
306
303
 
307
- protected
308
-
309
- def request (method, path, data, opts={})
304
+ patron = Patron::Session.new
305
+ patron.base_url = "#{@host}:#{@port}"
310
306
 
311
- refresh
307
+ patron.headers['User-Agent'] =
308
+ @options[:user_agent] ||
309
+ "#{self.class} #{Rufus::Jig::VERSION} #{Thread.current.object_id} (patron)"
312
310
 
313
- super(method, path, data, opts)
311
+ Thread.current["#{self.class}_patron"] = patron
314
312
  end
315
313
 
316
314
  def do_get (path, data, opts)
317
315
 
318
- @patron.get(path, opts)
316
+ get_patron.get(path, opts)
319
317
  end
320
318
 
321
319
  def do_post (path, data, opts)
322
320
 
323
- @patron.post(path, data, opts)
321
+ get_patron.post(path, data, opts)
324
322
  end
325
323
 
326
324
  def do_put (path, data, opts)
327
325
 
328
326
  opts['Expect'] = '' unless @options[:expect]
329
327
 
330
- @patron.put(path, data, opts)
328
+ get_patron.put(path, data, opts)
331
329
  end
332
330
 
333
331
  def do_delete (path, data, opts)
334
332
 
335
- @patron.delete(path, opts)
333
+ get_patron.delete(path, opts)
336
334
  end
337
335
  end
338
336
 
data/lib/rufus/jig.rb CHANGED
@@ -29,7 +29,7 @@ module Jig
29
29
  require 'rufus/jig/http'
30
30
  require 'rufus/jig/json'
31
31
 
32
- VERSION = '0.1.3'
32
+ VERSION = '0.1.4'
33
33
 
34
34
  autoload :Couch, 'rufus/jig/couch'
35
35
  autoload :CouchError, 'rufus/jig/couch'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-jig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux