rufus-jig 0.1.23 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/.rspec +1 -0
  2. data/CHANGELOG.txt +8 -0
  3. data/README.rdoc +41 -11
  4. data/Rakefile +37 -12
  5. data/TODO.txt +6 -3
  6. data/lib/rufus/jig/adapters/em.rb +21 -24
  7. data/lib/rufus/jig/adapters/net.rb +3 -4
  8. data/lib/rufus/jig/adapters/net_persistent.rb +26 -7
  9. data/lib/rufus/jig/adapters/patron.rb +25 -10
  10. data/lib/rufus/jig/couch.rb +199 -36
  11. data/lib/rufus/jig/http.rb +183 -90
  12. data/lib/rufus/jig/path.rb +4 -4
  13. data/lib/rufus/jig/version.rb +1 -1
  14. data/rufus-jig.gemspec +55 -34
  15. data/spec/couch/attachements_spec.rb +113 -0
  16. data/spec/couch/basic_auth_spec.rb +75 -0
  17. data/spec/couch/conditional_spec.rb +178 -0
  18. data/spec/couch/continuous.rb +97 -0
  19. data/spec/couch/couch_spec.rb +64 -0
  20. data/spec/couch/db_spec.rb +366 -0
  21. data/{test → spec/couch}/tweet.png +0 -0
  22. data/spec/couch/views_spec.rb +326 -0
  23. data/spec/couch_url.txt +2 -0
  24. data/spec/jig/basic_auth_spec.rb +51 -0
  25. data/spec/jig/conditional_spec.rb +76 -0
  26. data/spec/jig/delete_spec.rb +32 -0
  27. data/spec/jig/get_spec.rb +116 -0
  28. data/spec/jig/misc_spec.rb +120 -0
  29. data/spec/jig/new_spec.rb +95 -0
  30. data/spec/jig/parse_uri_spec.rb +139 -0
  31. data/spec/jig/post_spec.rb +79 -0
  32. data/spec/jig/prefix_spec.rb +51 -0
  33. data/spec/jig/put_spec.rb +68 -0
  34. data/spec/jig/timeout_spec.rb +94 -0
  35. data/{test → spec}/server.rb +14 -4
  36. data/spec/spec_helper.rb +61 -0
  37. data/spec/support/couch_helper.rb +14 -0
  38. data/spec/support/server_helper.rb +32 -0
  39. metadata +98 -43
  40. data/lib/rufus/jig/adapters/net_response.rb +0 -42
  41. data/test/base.rb +0 -53
  42. data/test/bm/bm0.rb +0 -49
  43. data/test/bm/bm1.rb +0 -43
  44. data/test/conc/put_vs_delete.rb +0 -28
  45. data/test/couch_base.rb +0 -52
  46. data/test/couch_url.txt +0 -1
  47. data/test/ct_0_couch.rb +0 -64
  48. data/test/ct_1_couchdb.rb +0 -204
  49. data/test/ct_2_couchdb_options.rb +0 -50
  50. data/test/ct_3_couchdb_views.rb +0 -106
  51. data/test/ct_4_attachments.rb +0 -126
  52. data/test/ct_5_couchdb_continuous.rb +0 -92
  53. data/test/cut_0_auth_couch.rb +0 -62
  54. data/test/test.rb +0 -28
  55. data/test/to.sh +0 -25
  56. data/test/tt_0_get_timeout.rb +0 -92
  57. data/test/ut_0_http_get.rb +0 -191
  58. data/test/ut_1_http_post.rb +0 -81
  59. data/test/ut_2_http_delete.rb +0 -42
  60. data/test/ut_3_http_put.rb +0 -105
  61. data/test/ut_4_http_prefix.rb +0 -50
  62. data/test/ut_5_http_misc.rb +0 -65
  63. data/test/ut_6_args.rb +0 -98
  64. data/test/ut_7_parse_uri.rb +0 -79
  65. data/test/ut_8_auth.rb +0 -37
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-jig
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
- - 0
7
7
  - 1
8
- - 23
9
- version: 0.1.23
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - John Mettraux
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-01 00:00:00 +09:00
19
+ date: 2010-12-08 00:00:00 +09:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: rufus-lru
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ">="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 3
28
31
  segments:
29
32
  - 0
30
33
  version: "0"
@@ -34,9 +37,11 @@ dependencies:
34
37
  name: rufus-json
35
38
  prerelease: false
36
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
37
41
  requirements:
38
42
  - - ">="
39
43
  - !ruby/object:Gem::Version
44
+ hash: 29
40
45
  segments:
41
46
  - 0
42
47
  - 2
@@ -48,76 +53,104 @@ dependencies:
48
53
  name: rake
49
54
  prerelease: false
50
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
51
57
  requirements:
52
58
  - - ">="
53
59
  - !ruby/object:Gem::Version
60
+ hash: 3
54
61
  segments:
55
62
  - 0
56
63
  version: "0"
57
64
  type: :development
58
65
  version_requirements: *id003
59
66
  - !ruby/object:Gem::Dependency
60
- name: yard
67
+ name: rspec
61
68
  prerelease: false
62
69
  requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
63
71
  requirements:
64
- - - ">="
72
+ - - ~>
65
73
  - !ruby/object:Gem::Version
74
+ hash: 7
66
75
  segments:
76
+ - 2
77
+ - 2
67
78
  - 0
68
- version: "0"
79
+ version: 2.2.0
69
80
  type: :development
70
81
  version_requirements: *id004
71
82
  - !ruby/object:Gem::Dependency
72
- name: jeweler
83
+ name: yard
73
84
  prerelease: false
74
85
  requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
75
87
  requirements:
76
88
  - - ">="
77
89
  - !ruby/object:Gem::Version
90
+ hash: 3
78
91
  segments:
79
92
  - 0
80
93
  version: "0"
81
94
  type: :development
82
95
  version_requirements: *id005
83
96
  - !ruby/object:Gem::Dependency
84
- name: patron
97
+ name: jeweler
85
98
  prerelease: false
86
99
  requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
87
101
  requirements:
88
102
  - - ">="
89
103
  - !ruby/object:Gem::Version
104
+ hash: 3
90
105
  segments:
91
106
  - 0
92
107
  version: "0"
93
108
  type: :development
94
109
  version_requirements: *id006
95
110
  - !ruby/object:Gem::Dependency
96
- name: em-http-request
111
+ name: patron
97
112
  prerelease: false
98
113
  requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
99
115
  requirements:
100
116
  - - ">="
101
117
  - !ruby/object:Gem::Version
118
+ hash: 3
102
119
  segments:
103
120
  - 0
104
121
  version: "0"
105
122
  type: :development
106
123
  version_requirements: *id007
107
124
  - !ruby/object:Gem::Dependency
108
- name: net-http-persistent
125
+ name: em-http-request
109
126
  prerelease: false
110
127
  requirement: &id008 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ type: :development
137
+ version_requirements: *id008
138
+ - !ruby/object:Gem::Dependency
139
+ name: net-http-persistent
140
+ prerelease: false
141
+ requirement: &id009 !ruby/object:Gem::Requirement
142
+ none: false
111
143
  requirements:
112
144
  - - ">="
113
145
  - !ruby/object:Gem::Version
146
+ hash: 7
114
147
  segments:
115
148
  - 1
116
149
  - 4
117
150
  version: "1.4"
118
151
  type: :development
119
- version_requirements: *id008
120
- description: "\n Json Interwebs Get.\n\n An HTTP client, greedy with JSON content, GETting conditionally.\n\n Uses Patron and Yajl-ruby whenever possible.\n "
152
+ version_requirements: *id009
153
+ description: "\n Json Interwebs Get.\n\n An HTTP client, greedy with JSON content, GETting conditionally.\n\n Uses Yajl-ruby whenever possible.\n "
121
154
  email: jmettraux@gmail.com
122
155
  executables: []
123
156
 
@@ -128,6 +161,7 @@ extra_rdoc_files:
128
161
  - README.rdoc
129
162
  files:
130
163
  - .gitignore
164
+ - .rspec
131
165
  - CHANGELOG.txt
132
166
  - CREDITS.txt
133
167
  - LICENSE.txt
@@ -139,40 +173,36 @@ files:
139
173
  - lib/rufus/jig/adapters/em.rb
140
174
  - lib/rufus/jig/adapters/net.rb
141
175
  - lib/rufus/jig/adapters/net_persistent.rb
142
- - lib/rufus/jig/adapters/net_response.rb
143
176
  - lib/rufus/jig/adapters/patron.rb
144
177
  - lib/rufus/jig/couch.rb
145
178
  - lib/rufus/jig/http.rb
146
179
  - lib/rufus/jig/path.rb
147
180
  - lib/rufus/jig/version.rb
148
181
  - rufus-jig.gemspec
149
- - test/base.rb
150
- - test/bm/bm0.rb
151
- - test/bm/bm1.rb
152
- - test/conc/put_vs_delete.rb
153
- - test/couch_base.rb
154
- - test/couch_url.txt
155
- - test/ct_0_couch.rb
156
- - test/ct_1_couchdb.rb
157
- - test/ct_2_couchdb_options.rb
158
- - test/ct_3_couchdb_views.rb
159
- - test/ct_4_attachments.rb
160
- - test/ct_5_couchdb_continuous.rb
161
- - test/cut_0_auth_couch.rb
162
- - test/server.rb
163
- - test/test.rb
164
- - test/to.sh
165
- - test/tt_0_get_timeout.rb
166
- - test/tweet.png
167
- - test/ut_0_http_get.rb
168
- - test/ut_1_http_post.rb
169
- - test/ut_2_http_delete.rb
170
- - test/ut_3_http_put.rb
171
- - test/ut_4_http_prefix.rb
172
- - test/ut_5_http_misc.rb
173
- - test/ut_6_args.rb
174
- - test/ut_7_parse_uri.rb
175
- - test/ut_8_auth.rb
182
+ - spec/couch/attachements_spec.rb
183
+ - spec/couch/basic_auth_spec.rb
184
+ - spec/couch/conditional_spec.rb
185
+ - spec/couch/continuous.rb
186
+ - spec/couch/couch_spec.rb
187
+ - spec/couch/db_spec.rb
188
+ - spec/couch/tweet.png
189
+ - spec/couch/views_spec.rb
190
+ - spec/couch_url.txt
191
+ - spec/jig/basic_auth_spec.rb
192
+ - spec/jig/conditional_spec.rb
193
+ - spec/jig/delete_spec.rb
194
+ - spec/jig/get_spec.rb
195
+ - spec/jig/misc_spec.rb
196
+ - spec/jig/new_spec.rb
197
+ - spec/jig/parse_uri_spec.rb
198
+ - spec/jig/post_spec.rb
199
+ - spec/jig/prefix_spec.rb
200
+ - spec/jig/put_spec.rb
201
+ - spec/jig/timeout_spec.rb
202
+ - spec/server.rb
203
+ - spec/spec_helper.rb
204
+ - spec/support/couch_helper.rb
205
+ - spec/support/server_helper.rb
176
206
  has_rdoc: true
177
207
  homepage: http://github.com/jmettraux/rufus-jig/
178
208
  licenses: []
@@ -183,25 +213,50 @@ rdoc_options:
183
213
  require_paths:
184
214
  - lib
185
215
  required_ruby_version: !ruby/object:Gem::Requirement
216
+ none: false
186
217
  requirements:
187
218
  - - ">="
188
219
  - !ruby/object:Gem::Version
220
+ hash: 3
189
221
  segments:
190
222
  - 0
191
223
  version: "0"
192
224
  required_rubygems_version: !ruby/object:Gem::Requirement
225
+ none: false
193
226
  requirements:
194
227
  - - ">="
195
228
  - !ruby/object:Gem::Version
229
+ hash: 3
196
230
  segments:
197
231
  - 0
198
232
  version: "0"
199
233
  requirements: []
200
234
 
201
235
  rubyforge_project: rufus
202
- rubygems_version: 1.3.6
236
+ rubygems_version: 1.3.7
203
237
  signing_key:
204
238
  specification_version: 3
205
239
  summary: An HTTP client, greedy with JSON content, GETting conditionally.
206
240
  test_files:
207
- - test/test.rb
241
+ - spec/couch/attachements_spec.rb
242
+ - spec/couch/basic_auth_spec.rb
243
+ - spec/couch/conditional_spec.rb
244
+ - spec/couch/continuous.rb
245
+ - spec/couch/couch_spec.rb
246
+ - spec/couch/db_spec.rb
247
+ - spec/couch/views_spec.rb
248
+ - spec/jig/basic_auth_spec.rb
249
+ - spec/jig/conditional_spec.rb
250
+ - spec/jig/delete_spec.rb
251
+ - spec/jig/get_spec.rb
252
+ - spec/jig/misc_spec.rb
253
+ - spec/jig/new_spec.rb
254
+ - spec/jig/parse_uri_spec.rb
255
+ - spec/jig/post_spec.rb
256
+ - spec/jig/prefix_spec.rb
257
+ - spec/jig/put_spec.rb
258
+ - spec/jig/timeout_spec.rb
259
+ - spec/server.rb
260
+ - spec/spec_helper.rb
261
+ - spec/support/couch_helper.rb
262
+ - spec/support/server_helper.rb
@@ -1,42 +0,0 @@
1
- #--
2
- # Copyright (c) 2009-2010, John Mettraux, jmettraux@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
-
26
- #
27
- # a Rufus::Jig wrapper for the server response.
28
- #
29
- class Rufus::Jig::HttpResponse
30
-
31
- def initialize (nh_res)
32
-
33
- @original = nh_res
34
- @status = nh_res.code.to_i
35
- @body = nh_res.body
36
- @headers = {}
37
- nh_res.each { |k, v|
38
- @headers[k.split('-').collect { |s| s.capitalize }.join('-')] = v
39
- }
40
- end
41
- end
42
-
@@ -1,53 +0,0 @@
1
-
2
- lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- $:.unshift(lib) unless $:.include?(lib)
4
-
5
- require 'rubygems'
6
- require 'yajl'
7
-
8
- # Our default
9
- transport_library = 'net/http'
10
-
11
- if ARGV.include?( '--em' )
12
- require 'openssl'
13
- transport_library = 'em-http'
14
- elsif ARGV.include?( '--netp' )
15
- transport_library = 'net/http/persistent'
16
- elsif ARGV.include?( '--patron' )
17
- transport_library = 'patron'
18
- end
19
-
20
- require transport_library
21
-
22
- unless $advertised
23
- p transport_library
24
- $advertised = true
25
- end
26
-
27
- require 'rufus/jig'
28
-
29
- require 'test/unit'
30
-
31
- if transport_library == 'em-http'
32
- Thread.new { EM.run {} }
33
- Thread.pass until EM.reactor_running?
34
- end
35
-
36
- t = nil
37
- begin
38
- t = Time.now
39
- Rufus::Jig::Http.new('127.0.0.1', 4567).get('/document', :timeout => -1)
40
- rescue Exception => e
41
- puts
42
- p e
43
- e.backtrace.each { |l| puts l }
44
- puts
45
- puts "(#{Time.now - t} seconds)"
46
- puts
47
- puts "test server not running, please run :"
48
- puts
49
- puts " ruby test/server.rb"
50
- puts
51
- exit(1)
52
- end
53
-
@@ -1,49 +0,0 @@
1
-
2
- $:.unshift('lib')
3
- require 'benchmark'
4
- require 'patron'
5
- require 'yajl'
6
- require 'rufus/jig'
7
-
8
- N = 1
9
-
10
- DOC = {}
11
- 1000.times { |i| DOC["key#{i}"] = { 'a' => 'b', 'c' => 'd', 'e' =>'f' } }
12
-
13
- Rufus::Jig::Couch.delete_db('http://127.0.0.1:5984/test_bm0') rescue nil
14
- CDB = Rufus::Jig::Couch.put_db('http://127.0.0.1:5984/test_bm0')
15
-
16
- Benchmark.benchmark(' ' * 31 + Benchmark::Tms::CAPTION, 31) do |b|
17
-
18
- b.report('marshal to file') do
19
- N.times do
20
- File.open('out.marshal', 'wb') { |f| f.write(Marshal.dump(DOC)) }
21
- end
22
- end
23
- b.report('yajl to file') do
24
- N.times do
25
- File.open('out.json', 'wb') { |f| f.write(Rufus::Jig::Json.encode(DOC)) }
26
- end
27
- end
28
- b.report('to couch') do
29
- N.times do |i|
30
- CDB.put_doc("out#{i}", DOC)
31
- end
32
- end
33
-
34
- b.report('marshal from file') do
35
- N.times do
36
- doc = Marshal.load(File.read('out.marshal'))
37
- end
38
- end
39
- b.report('yajl from file') do
40
- N.times do
41
- doc = Rufus::Jig::Json.decode(File.read('out.json'))
42
- end
43
- end
44
- b.report('from couch') do
45
- N.times do |i|
46
- doc = CDB.get_doc("out#{i}")
47
- end
48
- end
49
- end
@@ -1,43 +0,0 @@
1
-
2
- $:.unshift('lib')
3
- require 'rubygems'
4
- require 'yajl'
5
-
6
- # Our default
7
- transport_library = 'net/http'
8
-
9
- if ARGV.include?( '--em' )
10
- require 'openssl'
11
- transport_library = 'em-http'
12
- elsif ARGV.include?( '--netp' )
13
- transport_library = 'net/http/persistent'
14
- elsif ARGV.include?( '--patron' )
15
- transport_library = 'patron'
16
- end
17
-
18
- require transport_library
19
-
20
- require 'rufus/jig'
21
-
22
- #c = Rufus::Jig::Couch.new('127.0.0.1', 5984, 'artsr_development_ruote_msgs')
23
- #p c.get('_all_docs')
24
- #p c.delete("1100!2148379060!2010-06-28!1277767412.550787!002")
25
-
26
- require 'benchmark'
27
-
28
- N = 10_000
29
-
30
- c = Rufus::Jig::Couch.new('127.0.0.1', 5984, 'artsr_development_ruote_msgs')
31
-
32
- puts
33
- puts RUBY_VERSION
34
- puts c.http.variant
35
- puts
36
-
37
- Benchmark.benchmark(' ' * 31 + Benchmark::Tms::CAPTION, 31) do |b|
38
-
39
- b.report('get') do
40
- N.times { c.get('_all_docs?include_docs=true') }
41
- end
42
- end
43
-