streamly_ffi 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/benchmark/basic_request.rb +17 -1
- data/lib/streamly_ffi/version.rb +1 -1
- data/spec/streamly_ffi/request_spec.rb +40 -40
- data/streamly_ffi.gemspec +15 -27
- metadata +39 -15
data/.gitignore
CHANGED
data/benchmark/basic_request.rb
CHANGED
@@ -5,12 +5,21 @@ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'net/http'
|
7
7
|
require 'rest_client'
|
8
|
+
require 'curb'
|
8
9
|
require 'streamly'
|
10
|
+
require 'streamly_ffi'
|
9
11
|
require 'benchmark'
|
10
12
|
|
11
13
|
url = ARGV[0]
|
12
14
|
|
13
15
|
Benchmark.bmbm do |x|
|
16
|
+
x.report do
|
17
|
+
puts "StreamlyFFI"
|
18
|
+
(ARGV[1] || 1).to_i.times do
|
19
|
+
StreamlyFFI.get(url)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
14
23
|
x.report do
|
15
24
|
puts "Streamly"
|
16
25
|
(ARGV[1] || 1).to_i.times do
|
@@ -19,7 +28,14 @@ Benchmark.bmbm do |x|
|
|
19
28
|
end
|
20
29
|
|
21
30
|
x.report do
|
22
|
-
puts "
|
31
|
+
puts "Curb"
|
32
|
+
(ARGV[1] || 1).to_i.times do
|
33
|
+
Curl::Easy.perform(url)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
x.report do
|
38
|
+
puts "`curl`"
|
23
39
|
(ARGV[1] || 1).to_i.times do
|
24
40
|
`curl -s --compressed #{url}`
|
25
41
|
end
|
data/lib/streamly_ffi/version.rb
CHANGED
@@ -10,21 +10,21 @@ describe StreamlyFFI::Request do
|
|
10
10
|
describe "HEAD" do
|
11
11
|
describe "basic" do
|
12
12
|
it "should perform a basic request" do
|
13
|
-
resp =
|
13
|
+
resp = StreamlyFFI.head('localhost:4567')
|
14
14
|
resp.should_not be_nil
|
15
15
|
end
|
16
16
|
=begin
|
17
17
|
if RUBY_VERSION =~ /^1.9/
|
18
18
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
19
19
|
Encoding.default_internal = nil
|
20
|
-
|
20
|
+
StreamlyFFI.head('localhost:4567').encoding.should eql(Encoding.find('utf-8'))
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should use Encoding.default_internal" do
|
24
24
|
Encoding.default_internal = Encoding.find('utf-8')
|
25
|
-
|
25
|
+
StreamlyFFI.head('localhost:4567').encoding.should eql(Encoding.default_internal)
|
26
26
|
Encoding.default_internal = Encoding.find('us-ascii')
|
27
|
-
|
27
|
+
StreamlyFFI.head('localhost:4567').encoding.should eql(Encoding.default_internal)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
=end
|
@@ -33,7 +33,7 @@ describe StreamlyFFI::Request do
|
|
33
33
|
describe "streaming" do
|
34
34
|
it "should perform a basic request and stream header chunks to the caller" do
|
35
35
|
streamed_response = ""
|
36
|
-
resp =
|
36
|
+
resp = StreamlyFFI.head('localhost:4567') do |chunk|
|
37
37
|
chunk.should_not be_empty
|
38
38
|
streamed_response << chunk
|
39
39
|
end
|
@@ -44,18 +44,18 @@ describe StreamlyFFI::Request do
|
|
44
44
|
if RUBY_VERSION =~ /^1.9/
|
45
45
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
46
46
|
Encoding.default_internal = nil
|
47
|
-
|
47
|
+
StreamlyFFI.head('localhost:4567') do |chunk|
|
48
48
|
chunk.encoding.should eql(Encoding.find('utf-8'))
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should use Encoding.default_internal" do
|
53
53
|
Encoding.default_internal = Encoding.find('utf-8')
|
54
|
-
|
54
|
+
StreamlyFFI.head('localhost:4567') do |chunk|
|
55
55
|
chunk.encoding.should eql(Encoding.default_internal)
|
56
56
|
end
|
57
57
|
Encoding.default_internal = Encoding.find('us-ascii')
|
58
|
-
|
58
|
+
StreamlyFFI.head('localhost:4567') do |chunk|
|
59
59
|
chunk.encoding.should eql(Encoding.default_internal)
|
60
60
|
end
|
61
61
|
end
|
@@ -67,21 +67,21 @@ describe StreamlyFFI::Request do
|
|
67
67
|
describe "GET" do
|
68
68
|
describe "basic" do
|
69
69
|
it "should perform a basic request" do
|
70
|
-
resp =
|
70
|
+
resp = StreamlyFFI.get('localhost:4567/?name=brian')
|
71
71
|
resp.should eql(@response)
|
72
72
|
end
|
73
73
|
=begin
|
74
74
|
if RUBY_VERSION =~ /^1.9/
|
75
75
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
76
76
|
Encoding.default_internal = nil
|
77
|
-
|
77
|
+
StreamlyFFI.get('localhost:4567').encoding.should eql(Encoding.find('utf-8'))
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should use Encoding.default_internal" do
|
81
81
|
Encoding.default_internal = Encoding.find('utf-8')
|
82
|
-
|
82
|
+
StreamlyFFI.get('localhost:4567').encoding.should eql(Encoding.default_internal)
|
83
83
|
Encoding.default_internal = Encoding.find('us-ascii')
|
84
|
-
|
84
|
+
StreamlyFFI.get('localhost:4567').encoding.should eql(Encoding.default_internal)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
=end
|
@@ -90,7 +90,7 @@ describe StreamlyFFI::Request do
|
|
90
90
|
describe "streaming" do
|
91
91
|
it "should perform a basic request and stream the response to the caller" do
|
92
92
|
streamed_response = ''
|
93
|
-
resp =
|
93
|
+
resp = StreamlyFFI.get('localhost:4567/?name=brian') do |chunk|
|
94
94
|
chunk.should_not be_empty
|
95
95
|
streamed_response << chunk
|
96
96
|
end
|
@@ -101,18 +101,18 @@ describe StreamlyFFI::Request do
|
|
101
101
|
if RUBY_VERSION =~ /^1.9/
|
102
102
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
103
103
|
Encoding.default_internal = nil
|
104
|
-
|
104
|
+
StreamlyFFI.get('localhost:4567') do |chunk|
|
105
105
|
chunk.encoding.should eql(Encoding.find('utf-8'))
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should use Encoding.default_internal" do
|
110
110
|
Encoding.default_internal = Encoding.find('utf-8')
|
111
|
-
|
111
|
+
StreamlyFFI.get('localhost:4567') do |chunk|
|
112
112
|
chunk.encoding.should eql(Encoding.default_internal)
|
113
113
|
end
|
114
114
|
Encoding.default_internal = Encoding.find('us-ascii')
|
115
|
-
|
115
|
+
StreamlyFFI.get('localhost:4567') do |chunk|
|
116
116
|
chunk.encoding.should eql(Encoding.default_internal)
|
117
117
|
end
|
118
118
|
end
|
@@ -124,21 +124,21 @@ describe StreamlyFFI::Request do
|
|
124
124
|
describe "POST" do
|
125
125
|
describe "basic" do
|
126
126
|
it "should perform a basic request" do
|
127
|
-
resp =
|
127
|
+
resp = StreamlyFFI.post('localhost:4567', 'name=brian')
|
128
128
|
resp.should eql(@response)
|
129
129
|
end
|
130
130
|
=begin
|
131
131
|
if RUBY_VERSION =~ /^1.9/
|
132
132
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
133
133
|
Encoding.default_internal = nil
|
134
|
-
|
134
|
+
StreamlyFFI.post('localhost:4567', 'name=brian').encoding.should eql(Encoding.find('utf-8'))
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should use Encoding.default_internal" do
|
138
138
|
Encoding.default_internal = Encoding.find('utf-8')
|
139
|
-
|
139
|
+
StreamlyFFI.post('localhost:4567', 'name=brian').encoding.should eql(Encoding.default_internal)
|
140
140
|
Encoding.default_internal = Encoding.find('us-ascii')
|
141
|
-
|
141
|
+
StreamlyFFI.post('localhost:4567', 'name=brian').encoding.should eql(Encoding.default_internal)
|
142
142
|
end
|
143
143
|
end
|
144
144
|
=end
|
@@ -147,7 +147,7 @@ describe StreamlyFFI::Request do
|
|
147
147
|
describe "streaming" do
|
148
148
|
it "should perform a basic request and stream the response to the caller" do
|
149
149
|
streamed_response = ''
|
150
|
-
resp =
|
150
|
+
resp = StreamlyFFI.post('localhost:4567', 'name=brian') do |chunk|
|
151
151
|
chunk.should_not be_empty
|
152
152
|
streamed_response << chunk
|
153
153
|
end
|
@@ -158,18 +158,18 @@ describe StreamlyFFI::Request do
|
|
158
158
|
if RUBY_VERSION =~ /^1.9/
|
159
159
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
160
160
|
Encoding.default_internal = nil
|
161
|
-
|
161
|
+
StreamlyFFI.post('localhost:4567', 'name=brian') do |chunk|
|
162
162
|
chunk.encoding.should eql(Encoding.find('utf-8'))
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
166
|
it "should use Encoding.default_internal" do
|
167
167
|
Encoding.default_internal = Encoding.find('utf-8')
|
168
|
-
|
168
|
+
StreamlyFFI.post('localhost:4567', 'name=brian') do |chunk|
|
169
169
|
chunk.encoding.should eql(Encoding.default_internal)
|
170
170
|
end
|
171
171
|
Encoding.default_internal = Encoding.find('us-ascii')
|
172
|
-
|
172
|
+
StreamlyFFI.post('localhost:4567', 'name=brian') do |chunk|
|
173
173
|
chunk.encoding.should eql(Encoding.default_internal)
|
174
174
|
end
|
175
175
|
end
|
@@ -181,21 +181,21 @@ describe StreamlyFFI::Request do
|
|
181
181
|
describe "PUT" do
|
182
182
|
describe "basic" do
|
183
183
|
it "should perform a basic request" do
|
184
|
-
resp =
|
184
|
+
resp = StreamlyFFI.put('localhost:4567', 'name=brian')
|
185
185
|
resp.should eql(@response)
|
186
186
|
end
|
187
187
|
=begin
|
188
188
|
if RUBY_VERSION =~ /^1.9/
|
189
189
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
190
190
|
Encoding.default_internal = nil
|
191
|
-
|
191
|
+
StreamlyFFI.put('localhost:4567', 'name=brian').encoding.should eql(Encoding.find('utf-8'))
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should use Encoding.default_internal" do
|
195
195
|
Encoding.default_internal = Encoding.find('utf-8')
|
196
|
-
|
196
|
+
StreamlyFFI.put('localhost:4567', 'name=brian').encoding.should eql(Encoding.default_internal)
|
197
197
|
Encoding.default_internal = Encoding.find('us-ascii')
|
198
|
-
|
198
|
+
StreamlyFFI.put('localhost:4567', 'name=brian').encoding.should eql(Encoding.default_internal)
|
199
199
|
end
|
200
200
|
end
|
201
201
|
=end
|
@@ -204,7 +204,7 @@ describe StreamlyFFI::Request do
|
|
204
204
|
describe "streaming" do
|
205
205
|
it "should perform a basic request and stream the response to the caller" do
|
206
206
|
streamed_response = ''
|
207
|
-
resp =
|
207
|
+
resp = StreamlyFFI.put('localhost:4567', 'name=brian') do |chunk|
|
208
208
|
chunk.should_not be_empty
|
209
209
|
streamed_response << chunk
|
210
210
|
end
|
@@ -215,18 +215,18 @@ describe StreamlyFFI::Request do
|
|
215
215
|
if RUBY_VERSION =~ /^1.9/
|
216
216
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
217
217
|
Encoding.default_internal = nil
|
218
|
-
|
218
|
+
StreamlyFFI.put('localhost:4567', 'name=brian') do |chunk|
|
219
219
|
chunk.encoding.should eql(Encoding.find('utf-8'))
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should use Encoding.default_internal" do
|
224
224
|
Encoding.default_internal = Encoding.find('utf-8')
|
225
|
-
|
225
|
+
StreamlyFFI.put('localhost:4567', 'name=brian') do |chunk|
|
226
226
|
chunk.encoding.should eql(Encoding.default_internal)
|
227
227
|
end
|
228
228
|
Encoding.default_internal = Encoding.find('us-ascii')
|
229
|
-
|
229
|
+
StreamlyFFI.put('localhost:4567', 'name=brian') do |chunk|
|
230
230
|
chunk.encoding.should eql(Encoding.default_internal)
|
231
231
|
end
|
232
232
|
end
|
@@ -238,20 +238,20 @@ describe StreamlyFFI::Request do
|
|
238
238
|
describe "DELETE" do
|
239
239
|
describe "basic" do
|
240
240
|
it "should perform a basic request" do
|
241
|
-
resp =
|
241
|
+
resp = StreamlyFFI.delete('localhost:4567/?name=brian').should eql(@response)
|
242
242
|
end
|
243
243
|
=begin
|
244
244
|
if RUBY_VERSION =~ /^1.9/
|
245
245
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
246
246
|
Encoding.default_internal = nil
|
247
|
-
|
247
|
+
StreamlyFFI.delete('localhost:4567/?name=brian').encoding.should eql(Encoding.find('utf-8'))
|
248
248
|
end
|
249
249
|
|
250
250
|
it "should use Encoding.default_internal" do
|
251
251
|
Encoding.default_internal = Encoding.find('utf-8')
|
252
|
-
|
252
|
+
StreamlyFFI.delete('localhost:4567/?name=brian').encoding.should eql(Encoding.default_internal)
|
253
253
|
Encoding.default_internal = Encoding.find('us-ascii')
|
254
|
-
|
254
|
+
StreamlyFFI.delete('localhost:4567/?name=brian').encoding.should eql(Encoding.default_internal)
|
255
255
|
end
|
256
256
|
end
|
257
257
|
=end
|
@@ -260,7 +260,7 @@ describe StreamlyFFI::Request do
|
|
260
260
|
describe "streaming" do
|
261
261
|
it "should perform a basic request and stream the response to the caller" do
|
262
262
|
streamed_response = ''
|
263
|
-
resp =
|
263
|
+
resp = StreamlyFFI.delete('localhost:4567/?name=brian') do |chunk|
|
264
264
|
chunk.should_not be_empty
|
265
265
|
streamed_response << chunk
|
266
266
|
end
|
@@ -271,18 +271,18 @@ describe StreamlyFFI::Request do
|
|
271
271
|
if RUBY_VERSION =~ /^1.9/
|
272
272
|
it "should default to utf-8 if Encoding.default_internal is nil" do
|
273
273
|
Encoding.default_internal = nil
|
274
|
-
|
274
|
+
StreamlyFFI.delete('localhost:4567/?name=brian') do |chunk|
|
275
275
|
chunk.encoding.should eql(Encoding.find('utf-8'))
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
279
|
it "should use Encoding.default_internal" do
|
280
280
|
Encoding.default_internal = Encoding.find('utf-8')
|
281
|
-
|
281
|
+
StreamlyFFI.delete('localhost:4567/?name=brian') do |chunk|
|
282
282
|
chunk.encoding.should eql(Encoding.default_internal)
|
283
283
|
end
|
284
284
|
Encoding.default_internal = Encoding.find('us-ascii')
|
285
|
-
|
285
|
+
StreamlyFFI.delete('localhost:4567/?name=brian') do |chunk|
|
286
286
|
chunk.encoding.should eql(Encoding.default_internal)
|
287
287
|
end
|
288
288
|
end
|
data/streamly_ffi.gemspec
CHANGED
@@ -5,37 +5,25 @@
|
|
5
5
|
|
6
6
|
$:.push File.expand_path("../lib", __FILE__)
|
7
7
|
|
8
|
+
require "date"
|
8
9
|
require "streamly_ffi/version"
|
9
10
|
|
10
11
|
Gem::Specification.new do |s|
|
11
|
-
s.name
|
12
|
-
s.version
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.authors
|
16
|
-
s.date
|
17
|
-
s.email
|
18
|
-
s.
|
19
|
-
s.extra_rdoc_files = [
|
20
|
-
"README.rdoc"
|
21
|
-
]
|
22
|
-
s.files = `git ls-files`.split("\n")
|
23
|
-
s.homepage = %q{http://github.com/aitrus/streamly_ffi}
|
24
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
25
|
-
s.require_paths = ["lib", "ext"]
|
26
|
-
s.rubyforge_project = %q{streamly_ffi}
|
27
|
-
s.rubygems_version = %q{1.3.7}
|
28
|
-
s.summary = %q{A streaming REST client for Ruby, in C.}
|
29
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
s.name = "streamly_ffi"
|
13
|
+
s.version = StreamlyFFI::VERSION
|
14
|
+
s.summary = %q{A streaming Curl/HTTP/REST client for Ruby, in cross-Ruby FFI.}
|
15
|
+
s.description = %q{A streaming Curl/HTTP/REST client for Ruby, in cross-Ruby FFI. Using the CurlFFI RubyGem.}
|
16
|
+
s.authors = ["Brian Lopez", "Scott Gonyea"]
|
17
|
+
s.date = Date.today.to_s
|
18
|
+
s.email = %q{seniorlopez@gmail.com}
|
19
|
+
s.homepage = %q{http://github.com/aitrus/streamly_ffi}
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
s.platform = Gem::Platform::RUBY
|
22
|
+
s.add_dependency "curl_ffi"
|
23
|
+
s.add_development_dependency "rspec"
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
end
|
25
|
+
s.files = `git ls-files`.split("\n")
|
26
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
27
|
+
s.require_paths = ["lib"]
|
40
28
|
end
|
41
29
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 6
|
9
|
+
version: 0.1.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brian Lopez
|
@@ -15,18 +15,43 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09
|
18
|
+
date: 2010-11-09 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: curl_ffi
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rspec
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
version_requirements: *id002
|
47
|
+
description: A streaming Curl/HTTP/REST client for Ruby, in cross-Ruby FFI. Using the CurlFFI RubyGem.
|
23
48
|
email: seniorlopez@gmail.com
|
24
49
|
executables: []
|
25
50
|
|
26
|
-
extensions:
|
27
|
-
|
28
|
-
extra_rdoc_files:
|
29
|
-
|
51
|
+
extensions: []
|
52
|
+
|
53
|
+
extra_rdoc_files: []
|
54
|
+
|
30
55
|
files:
|
31
56
|
- .gitignore
|
32
57
|
- .rspec
|
@@ -62,11 +87,10 @@ homepage: http://github.com/aitrus/streamly_ffi
|
|
62
87
|
licenses: []
|
63
88
|
|
64
89
|
post_install_message:
|
65
|
-
rdoc_options:
|
66
|
-
|
90
|
+
rdoc_options: []
|
91
|
+
|
67
92
|
require_paths:
|
68
93
|
- lib
|
69
|
-
- ext
|
70
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
95
|
none: false
|
72
96
|
requirements:
|
@@ -85,11 +109,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
109
|
version: "0"
|
86
110
|
requirements: []
|
87
111
|
|
88
|
-
rubyforge_project:
|
112
|
+
rubyforge_project:
|
89
113
|
rubygems_version: 1.3.7
|
90
114
|
signing_key:
|
91
115
|
specification_version: 3
|
92
|
-
summary: A streaming REST client for Ruby, in
|
116
|
+
summary: A streaming Curl/HTTP/REST client for Ruby, in cross-Ruby FFI.
|
93
117
|
test_files:
|
94
118
|
- spec/server.rb
|
95
119
|
- spec/spec_helper.rb
|