io_splice 4.0.0 → 4.1.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.
- data/GIT-VERSION-GEN +1 -1
- data/io_splice.gemspec +1 -0
- data/lib/io/splice.rb +8 -3
- data/test/test_rack_file_compat.rb +31 -0
- metadata +22 -5
data/GIT-VERSION-GEN
CHANGED
data/io_splice.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.rubyforge_project = %q{qrp}
|
22
22
|
s.test_files = Dir['test/test_*.rb']
|
23
23
|
s.add_development_dependency('wrongdoc', '~> 1.5')
|
24
|
+
s.add_development_dependency('rack', '~> 1.2')
|
24
25
|
|
25
26
|
# s.licenses = %w(LGPL) # accessor not compatible with older RubyGems
|
26
27
|
end
|
data/lib/io/splice.rb
CHANGED
@@ -25,6 +25,11 @@ module IO::Splice
|
|
25
25
|
n
|
26
26
|
end
|
27
27
|
|
28
|
+
def self.need_open?(obj) # :nodoc:
|
29
|
+
return false if obj.respond_to?(:to_io)
|
30
|
+
obj.respond_to?(:to_path) || obj.kind_of?(String)
|
31
|
+
end
|
32
|
+
|
28
33
|
# copies the contents of the IO object given by +src+ to +dst+
|
29
34
|
# If +len+ is specified, then only +len+ bytes are copied and
|
30
35
|
# +EOFError+ is raised if fewer than +len+ bytes could be copied.
|
@@ -36,10 +41,10 @@ module IO::Splice
|
|
36
41
|
# objects with no underlying file descriptor (e.g. StringIO).
|
37
42
|
def self.copy_stream(src, dst, len = nil, src_offset = nil)
|
38
43
|
close = []
|
39
|
-
|
40
|
-
|
41
|
-
src, dst = src.to_io, dst.to_io
|
44
|
+
need_open?(src) and close << (src = File.open(src))
|
45
|
+
need_open?(dst) and close << (dst = File.open(dst, "w"))
|
42
46
|
rv = len
|
47
|
+
src, dst = src.to_io, dst.to_io
|
43
48
|
|
44
49
|
if src.stat.pipe? || dst.stat.pipe?
|
45
50
|
if len
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
require "rack"
|
3
|
+
require "test/unit"
|
4
|
+
require "socket"
|
5
|
+
require "io/splice"
|
6
|
+
|
7
|
+
class TestRackFileCompat < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@app = Rack::File.new(File.dirname(__FILE__))
|
10
|
+
@req = Rack::MockRequest.new(@app)
|
11
|
+
@base_file = File.basename(__FILE__)
|
12
|
+
@r, @w = UNIXSocket.pair
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
[ @r, @w ].each { |io| io.closed? or io.close }
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_rack_file
|
20
|
+
env = Rack::MockRequest.env_for "http://example.com/#@base_file"
|
21
|
+
status, headers, body = @app.call(env)
|
22
|
+
assert_equal 200, status.to_i
|
23
|
+
headers.each { |k,v|
|
24
|
+
assert_instance_of String, k.to_str
|
25
|
+
assert_instance_of String, v.to_str
|
26
|
+
}
|
27
|
+
thr = Thread.new { @r.read(File.size(__FILE__)) }
|
28
|
+
assert_equal File.size(__FILE__), IO::Splice.copy_stream(body, @w)
|
29
|
+
assert_equal File.read(__FILE__), thr.value
|
30
|
+
end
|
31
|
+
end if IO.respond_to?(:copy_stream)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io_splice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 4
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 4.0.0
|
10
|
+
version: 4.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ruby io_splice hackers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: wrongdoc
|
@@ -32,6 +32,21 @@ dependencies:
|
|
32
32
|
version: "1.5"
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rack
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 11
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 2
|
47
|
+
version: "1.2"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
35
50
|
description: |-
|
36
51
|
The splice family of Linux system calls can transfer data between file
|
37
52
|
descriptors without the need to copy data into userspace. Instead of a
|
@@ -80,6 +95,7 @@ files:
|
|
80
95
|
- test/test_io_splice.rb
|
81
96
|
- test/test_io_splice_eintr.rb
|
82
97
|
- test/test_io_splice_in_full.rb
|
98
|
+
- test/test_rack_file_compat.rb
|
83
99
|
homepage: http://bogomips.org/ruby_io_splice/
|
84
100
|
licenses: []
|
85
101
|
|
@@ -112,11 +128,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
128
|
requirements: []
|
113
129
|
|
114
130
|
rubyforge_project: qrp
|
115
|
-
rubygems_version: 1.8.
|
131
|
+
rubygems_version: 1.8.2
|
116
132
|
signing_key:
|
117
133
|
specification_version: 3
|
118
134
|
summary: zero-copy pipe I/O for Linux and Ruby
|
119
135
|
test_files:
|
136
|
+
- test/test_rack_file_compat.rb
|
120
137
|
- test/test_io_splice_in_full.rb
|
121
138
|
- test/test_io_splice.rb
|
122
139
|
- test/test_copy_stream.rb
|