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 +6 -1
- data/Rakefile +1 -2
- data/lib/rufus/jig/couch.rb +5 -0
- data/lib/rufus/jig/http.rb +18 -1
- data/lib/rufus/jig/version.rb +7 -0
- data/lib/rufus/jig.rb +2 -2
- data/rufus-jig.gemspec +3 -2
- data/test/base.rb +1 -1
- data/test/ct_0_couch.rb +9 -1
- data/test/ct_1_couchdb.rb +12 -5
- data/test/ut_0_http_get.rb +3 -1
- data/test/ut_1_http_post.rb +3 -2
- data/test/ut_2_http_delete.rb +5 -0
- data/test/ut_3_http_put.rb +3 -2
- data/test/ut_4_http_prefix.rb +3 -1
- data/test/ut_5_http_misc.rb +17 -1
- metadata +3 -2
data/CHANGELOG.txt
CHANGED
@@ -2,7 +2,12 @@
|
|
2
2
|
= rufus-jig CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
-
== rufus-jig - 0.1.
|
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
data/lib/rufus/jig/couch.rb
CHANGED
data/lib/rufus/jig/http.rb
CHANGED
@@ -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 =
|
318
|
+
k = key
|
302
319
|
|
303
320
|
patron = Thread.current[k]
|
304
321
|
|
data/lib/rufus/jig.rb
CHANGED
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.
|
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-
|
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
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
|
-
|
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
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
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')
|
data/test/ut_0_http_get.rb
CHANGED
data/test/ut_1_http_post.rb
CHANGED
@@ -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
|
|
data/test/ut_2_http_delete.rb
CHANGED
data/test/ut_3_http_put.rb
CHANGED
@@ -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
|
|
data/test/ut_4_http_prefix.rb
CHANGED
@@ -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
|
|
data/test/ut_5_http_misc.rb
CHANGED
@@ -10,27 +10,43 @@ require File.join(File.dirname(__FILE__), 'base')
|
|
10
10
|
|
11
11
|
class UtHttpMiscTest < Test::Unit::TestCase
|
12
12
|
|
13
|
-
def
|
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.
|
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-
|
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
|