rufus-jig 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -2,6 +2,12 @@
2
2
  = rufus-jig CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-jig - 0.1.17 not yet released
6
+
7
+ - using a new Patron::Session for each request (yes, they seem GC friendly)
8
+ - Rufus::Jig::Couch #path and #name methods
9
+
10
+
5
11
  == rufus-jig - 0.1.16 released 2010/03/17
6
12
 
7
13
  - Rufus::Jig::Couch returns true (was nil) when trying to put into a missing db
@@ -46,7 +46,7 @@ class Rufus::Jig::Http < Rufus::Jig::HttpCore
46
46
  # it's not really closing, it's rather making sure the patron
47
47
  # session can get collected as garbage
48
48
 
49
- Thread.current[key] = nil
49
+ #Thread.current[key] = nil
50
50
  end
51
51
 
52
52
  def variant
@@ -55,28 +55,14 @@ class Rufus::Jig::Http < Rufus::Jig::HttpCore
55
55
 
56
56
  protected
57
57
 
58
- def key
59
- self.object_id.to_s
60
- end
61
-
62
- # One patron session per thread
63
- #
64
58
  def get_patron (opts)
65
59
 
66
60
  to = (opts[:timeout] || @options[:timeout])
67
61
  to = to.to_i if to
68
62
  to = nil if to && to < 1
69
63
 
70
- k = key
71
-
72
- patron = Thread.current[k]
73
-
74
- return patron if patron && patron.timeout == to
75
-
76
- if patron.nil?
77
- patron = Patron::Session.new
78
- patron.base_url = "#{@host}:#{@port}"
79
- end
64
+ patron = Patron::Session.new
65
+ patron.base_url = "#{@host}:#{@port}"
80
66
 
81
67
  #patron.connect_timeout = 1
82
68
  # connection timeout defaults to 1 second
@@ -84,11 +70,9 @@ class Rufus::Jig::Http < Rufus::Jig::HttpCore
84
70
 
85
71
  patron.headers['User-Agent'] =
86
72
  @options[:user_agent] ||
87
- [
88
- self.class, Rufus::Jig::VERSION, Thread.current.object_id, '(patron)'
89
- ].join(' ')
73
+ [ self.class, Rufus::Jig::VERSION, '(patron)' ].join(' ')
90
74
 
91
- Thread.current[k] = patron
75
+ patron
92
76
  end
93
77
 
94
78
  def do_request (method, path, data, opts)
@@ -31,6 +31,7 @@ module Rufus::Jig
31
31
  #
32
32
  class Couch
33
33
 
34
+ attr_reader :path
34
35
  attr_reader :http
35
36
 
36
37
  def initialize (*args)
@@ -40,6 +41,11 @@ module Rufus::Jig
40
41
  @path ||= '/'
41
42
  end
42
43
 
44
+ def name
45
+
46
+ path
47
+ end
48
+
43
49
  def close
44
50
 
45
51
  @http.close
@@ -280,9 +280,9 @@ module Rufus::Jig
280
280
 
281
281
  def do_cache (method, path, response, body, opts)
282
282
 
283
- if method == :delete || (opts[:cache] == false)
283
+ if (method == :delete) || (opts[:cache] == false)
284
284
  @cache.delete(path)
285
- elsif et = response.headers['Etag']
285
+ elsif (method == :get) && (et = response.headers['Etag'])
286
286
  @cache[path] = [ et, Rufus::Jig.marshal_copy(body) ]
287
287
  end
288
288
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Rufus
3
3
  module Jig
4
- VERSION = '0.1.16'
4
+ VERSION = '0.1.17'
5
5
  end
6
6
  end
7
7
 
data/rufus-jig.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rufus-jig}
8
- s.version = "0.1.16"
8
+ s.version = "0.1.17"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux", "Kenneth Kalmer"]
12
- s.date = %q{2010-03-17}
12
+ s.date = %q{2010-03-22}
13
13
  s.description = %q{
14
14
  Json Interwebs Get.
15
15
 
data/test/ct_1_couchdb.rb CHANGED
@@ -33,6 +33,12 @@ class CtCouchDbTest < Test::Unit::TestCase
33
33
  @c.close
34
34
  end
35
35
 
36
+ def test_path
37
+
38
+ assert_equal 'rufus_jig_test', @c.path
39
+ assert_equal 'rufus_jig_test', @c.name
40
+ end
41
+
36
42
  def test_put
37
43
 
38
44
  r = @c.put('_id' => 'coffee0', 'type' => 'espresso')
@@ -75,5 +75,23 @@ class CtCouchDbViewsTest < Test::Unit::TestCase
75
75
  {"total_rows"=>5, "rows"=>[{"id"=>"c0", "value"=>nil, "key"=>"espresso"}, {"id"=>"c2", "value"=>nil, "key"=>"macchiato"}, {"id"=>"c4", "value"=>nil, "key"=>"macchiato"}], "offset"=>1},
76
76
  @c.post('_design/my_test/_view/my_view', { 'keys' => [ 'espresso', 'macchiato' ] }))
77
77
  end
78
+
79
+ #def test_put_views
80
+ # p @c.get('_design/my_test_2')
81
+ # @c.put(
82
+ # {
83
+ # '_id' => '_design/my_test_2',
84
+ # 'views' => {
85
+ # 'my_view' => {
86
+ # 'map' => "function (doc) { emit(doc['type'], null); }"
87
+ # }
88
+ # }
89
+ # })
90
+ # p @c.http.cache.keys
91
+ # p @c.get('_design/my_test_2/_view/my_view?key=%22macchiato%22')
92
+ # p @c.http.cache.keys
93
+ # p @c.get('_design/my_test_2/_view/my_view?key=%22macchiato%22')
94
+ # p @c.http.cache.keys
95
+ #end
78
96
  end
79
97
 
@@ -31,6 +31,10 @@ class UtHttpPostTest < Test::Unit::TestCase
31
31
  assert_equal 201, r.status
32
32
  assert_not_nil l
33
33
 
34
+ if l.match(/^http:\/\//)
35
+ l = '/' + l.split('/')[3..-1].join('/')
36
+ end
37
+
34
38
  assert_equal({ 'msg' => 'hello' }, @h.get(l))
35
39
  end
36
40
 
@@ -51,7 +55,7 @@ class UtHttpPostTest < Test::Unit::TestCase
51
55
 
52
56
  assert_equal({ 'msg' => 'hello world' }, b)
53
57
 
54
- assert_equal 1, @h.cache.size
58
+ assert_equal 0, @h.cache.size
55
59
  end
56
60
 
57
61
  def test_post_long_stuff
@@ -75,7 +75,7 @@ class UtHttpPutTest < Test::Unit::TestCase
75
75
  :content_type => :json)
76
76
 
77
77
  assert_equal({ 'msg' => 'hello world' }, b)
78
- assert_equal 1, @h.cache.size
78
+ assert_equal 0, @h.cache.size
79
79
  end
80
80
 
81
81
  def test_put_conflict
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 16
9
- version: 0.1.16
8
+ - 17
9
+ version: 0.1.17
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Mettraux
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-03-17 00:00:00 +09:00
18
+ date: 2010-03-22 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency