rufus-jig 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -2,7 +2,12 @@
2
2
  = rufus-jig CHANGELOG.txt
3
3
 
4
4
 
5
- == rufus-jig - 0.1.5 not yet released
5
+ == rufus-jig - 0.1.6 released 2009/12/21
6
+
7
+ - implemented close for Http and Couch classes
8
+
9
+
10
+ == rufus-jig - 0.1.5 released 2009/12/17
6
11
 
7
12
  - returning true (not raising) in case of 409 conflict
8
13
  - using jeweler (thanks Kenneth)
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
 
2
2
 
3
- $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
4
- require 'lib/rufus/jig.rb'
3
+ require 'lib/rufus/jig/version.rb'
5
4
 
6
5
  require 'rubygems'
7
6
  require 'rake'
@@ -36,6 +36,11 @@ module Rufus::Jig
36
36
  @path ||= '/'
37
37
  end
38
38
 
39
+ def close
40
+
41
+ @http.close
42
+ end
43
+
39
44
  def put (doc_or_path, opts={})
40
45
 
41
46
  path, payload = if doc_or_path.is_a?(String)
@@ -97,6 +97,11 @@ module Rufus::Jig
97
97
  @error_class = opts[:error_class] || HttpError
98
98
  end
99
99
 
100
+ def close
101
+
102
+ # default implementation does nothing
103
+ end
104
+
100
105
  def get (path, opts={})
101
106
 
102
107
  request(:get, path, nil, opts)
@@ -292,13 +297,25 @@ if defined?(Patron) # gem install patron
292
297
  super(host, port, opts)
293
298
  end
294
299
 
300
+ def close
301
+
302
+ # it's not really closing, it's rather making sure the patron
303
+ # session can get collected as garbage
304
+
305
+ Thread.current[key] = nil
306
+ end
307
+
295
308
  protected
296
309
 
310
+ def key
311
+ self.object_id.to_s
312
+ end
313
+
297
314
  # One patron session per thread
298
315
  #
299
316
  def get_patron
300
317
 
301
- k = "#{self.class} #{self.object_id}"
318
+ k = key
302
319
 
303
320
  patron = Thread.current[k]
304
321
 
@@ -0,0 +1,7 @@
1
+
2
+ module Rufus
3
+ module Jig
4
+ VERSION = '0.1.6'
5
+ end
6
+ end
7
+
data/lib/rufus/jig.rb CHANGED
@@ -26,11 +26,11 @@
26
26
  module Rufus
27
27
  module Jig
28
28
 
29
+ require 'rufus/jig/version'
30
+
29
31
  require 'rufus/jig/http'
30
32
  require 'rufus/jig/json'
31
33
 
32
- VERSION = '0.1.5'
33
-
34
34
  autoload :Couch, 'rufus/jig/couch'
35
35
  autoload :CouchError, 'rufus/jig/couch'
36
36
  end
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.5"
8
+ s.version = "0.1.6"
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{2009-12-17}
12
+ s.date = %q{2009-12-21}
13
13
  s.description = %q{
14
14
  Json Internet Get.
15
15
 
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
36
36
  "lib/rufus/jig/http.rb",
37
37
  "lib/rufus/jig/json.rb",
38
38
  "lib/rufus/jig/path.rb",
39
+ "lib/rufus/jig/version.rb",
39
40
  "rufus-jig.gemspec",
40
41
  "test/base.rb",
41
42
  "test/couch_base.rb",
data/test/base.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- $: << lib unless $:.include?(lib)
3
+ $:.unshift(lib) unless $:.include?(lib)
4
4
 
5
5
  require 'rubygems'
6
6
  require 'yajl'
data/test/ct_0_couch.rb CHANGED
@@ -12,15 +12,23 @@ class CtCouchTest < Test::Unit::TestCase
12
12
 
13
13
  def setup
14
14
 
15
+ h = Rufus::Jig::Http.new('127.0.0.1', 5984)
15
16
  begin
16
- Rufus::Jig::Http.new('127.0.0.1', 5984).delete('/rufus_jig_test')
17
+ h.delete('/rufus_jig_test')
17
18
  rescue Exception => e
18
19
  #p e
20
+ ensure
21
+ h.close rescue nil
19
22
  end
20
23
 
21
24
  @c = Rufus::Jig::Couch.new('127.0.0.1', 5984)
22
25
  end
23
26
 
27
+ def teardown
28
+
29
+ @c.close
30
+ end
31
+
24
32
  def test_welcome
25
33
 
26
34
  assert_equal 'Welcome', @c.get('.')['couchdb']
data/test/ct_1_couchdb.rb CHANGED
@@ -12,20 +12,27 @@ class CtCouchDbTest < Test::Unit::TestCase
12
12
 
13
13
  def setup
14
14
 
15
+ h = Rufus::Jig::Http.new('127.0.0.1', 5984)
16
+
15
17
  begin
16
- Rufus::Jig::Http.new('127.0.0.1', 5984).delete('/rufus_jig_test')
18
+ h.delete('/rufus_jig_test')
17
19
  rescue Exception => e
18
20
  #p e
19
21
  end
20
- Rufus::Jig::Http.new('127.0.0.1', 5984).put('/rufus_jig_test', '')
21
22
 
22
- Rufus::Jig::Http.new('127.0.0.1', 5984).put(
23
- '/rufus_jig_test/coffee1',
24
- '{"_id":"coffee1","type":"ristretto"}')
23
+ h.put('/rufus_jig_test', '')
24
+ h.put('/rufus_jig_test/coffee1', '{"_id":"coffee1","type":"ristretto"}')
25
+
26
+ h.close
25
27
 
26
28
  @c = Rufus::Jig::Couch.new('127.0.0.1', 5984, 'rufus_jig_test')
27
29
  end
28
30
 
31
+ def teardown
32
+
33
+ @c.close
34
+ end
35
+
29
36
  def test_put_doc
30
37
 
31
38
  r = @c.put('_id' => 'coffee0', 'type' => 'espresso')
@@ -11,9 +11,11 @@ require File.join(File.dirname(__FILE__), 'base')
11
11
  class UtHttpGetTest < Test::Unit::TestCase
12
12
 
13
13
  def setup
14
-
15
14
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567)
16
15
  end
16
+ def teardown
17
+ @h.close
18
+ end
17
19
 
18
20
  def test_get_root
19
21
 
@@ -11,11 +11,12 @@ require File.join(File.dirname(__FILE__), 'base')
11
11
  class UtHttpPostTest < Test::Unit::TestCase
12
12
 
13
13
  def setup
14
-
15
14
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567)
16
-
17
15
  @h.delete('/documents')
18
16
  end
17
+ def teardown
18
+ @h.close
19
+ end
19
20
 
20
21
  def test_post
21
22
 
@@ -18,6 +18,11 @@ class UtHttpDeleteTest < Test::Unit::TestCase
18
18
  '/documents/xyz', 'data', :content_type => 'text/plain', :raw => true)
19
19
  end
20
20
 
21
+ def teardown
22
+
23
+ @h.close
24
+ end
25
+
21
26
  def test_delete
22
27
 
23
28
  b = @h.delete('/documents/xyz')
@@ -11,11 +11,12 @@ require File.join(File.dirname(__FILE__), 'base')
11
11
  class UtHttpPutTest < Test::Unit::TestCase
12
12
 
13
13
  def setup
14
-
15
14
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567)
16
-
17
15
  @h.delete('/documents')
18
16
  end
17
+ def teardown
18
+ @h.close
19
+ end
19
20
 
20
21
  def test_clean
21
22
 
@@ -11,9 +11,11 @@ require File.join(File.dirname(__FILE__), 'base')
11
11
  class UtHttpPrefixTest < Test::Unit::TestCase
12
12
 
13
13
  def setup
14
-
15
14
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567, :prefix => '/a/b/')
16
15
  end
16
+ def teardown
17
+ @h.close
18
+ end
17
19
 
18
20
  def test_get
19
21
 
@@ -10,27 +10,43 @@ require File.join(File.dirname(__FILE__), 'base')
10
10
 
11
11
  class UtHttpMiscTest < Test::Unit::TestCase
12
12
 
13
- def test_prefix
13
+ def teardown
14
+ @h.close if @h
15
+ end
16
+
17
+ def test_prefix_with_slash
14
18
 
15
19
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567, :prefix => '/a/b')
16
20
 
17
21
  assert_equal 'c', @h.get('/c')
18
22
  assert_equal 'C', @h.get('c')
23
+ end
24
+
25
+ def test_prefix_without_slash
19
26
 
20
27
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567, :prefix => 'a/b')
21
28
 
22
29
  assert_equal 'c', @h.get('/c')
23
30
  assert_equal 'C', @h.get('c')
31
+ end
32
+
33
+ def test_without_prefix
24
34
 
25
35
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567)
26
36
 
27
37
  assert_equal 'C', @h.get('/a/b/c')
28
38
  assert_equal 'C', @h.get('a/b/c')
39
+ end
40
+
41
+ def test_with_single_slash_prefix
29
42
 
30
43
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567, :prefix => '/')
31
44
 
32
45
  assert_equal 'C', @h.get('/a/b/c')
33
46
  assert_equal 'C', @h.get('a/b/c')
47
+ end
48
+
49
+ def test_with_empty_prefix
34
50
 
35
51
  @h = Rufus::Jig::Http.new('127.0.0.1', 4567, :prefix => '')
36
52
 
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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-17 00:00:00 +09:00
13
+ date: 2009-12-21 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -46,6 +46,7 @@ files:
46
46
  - lib/rufus/jig/http.rb
47
47
  - lib/rufus/jig/json.rb
48
48
  - lib/rufus/jig/path.rb
49
+ - lib/rufus/jig/version.rb
49
50
  - rufus-jig.gemspec
50
51
  - test/base.rb
51
52
  - test/couch_base.rb