io-extra 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/README +50 -48
- data/Rakefile +34 -29
- data/ext/io/extra.c +2 -2
- data/io-extra.gemspec +29 -33
- data/test/test_io_extra.rb +1 -1
- metadata +10 -10
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 1.2.1 - 16-Jan-2010
|
2
|
+
* Some README updates
|
3
|
+
* Updates to the gemspec.
|
4
|
+
* Added the gem:build and gem:install rake task.
|
5
|
+
* Source code moved to github.
|
6
|
+
|
1
7
|
== 1.2.0 - 28-Jul-2009
|
2
8
|
* Several Linux compatibility fixes, all provided by Eric Wong.
|
3
9
|
* Now compatible with 1.9.x thanks to Eric Wong.
|
data/README
CHANGED
@@ -1,40 +1,44 @@
|
|
1
1
|
= Description
|
2
|
-
The io-extra library provides a few extra IO methods that you may find
|
3
|
-
handy. They are IO.closefrom, IO.fdwalk, IO#directio? and IO#directio=.
|
2
|
+
The io-extra library provides a few extra IO methods that you may find
|
3
|
+
handy. They are IO.closefrom, IO.fdwalk, IO#directio? and IO#directio=.
|
4
4
|
|
5
|
-
|
5
|
+
This library is not supported on MS Windows.
|
6
6
|
|
7
|
-
|
7
|
+
Support for OS X is limited. See the documentation for details.
|
8
8
|
|
9
9
|
= Installation
|
10
|
-
|
11
|
-
rake test (optional)
|
12
|
-
rake install
|
10
|
+
gem install io-extra
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
= Synopsis
|
13
|
+
require 'io/extra'
|
14
|
+
|
15
|
+
# Close all file descriptors from 3 up.
|
16
|
+
IO.closefrom(3)
|
17
|
+
|
18
|
+
# Inspect all the open handles
|
19
|
+
IO.fdwalk(0){ |handle|
|
20
|
+
puts "=" * 40
|
21
|
+
p handle
|
22
|
+
p handle.fileno
|
23
|
+
}
|
20
24
|
|
21
25
|
= Developer's Notes
|
22
|
-
You might be wondering what the difference is between my implementation of
|
23
|
-
IO.closefrom and a pure Ruby version that looks something like this:
|
26
|
+
You might be wondering what the difference is between my implementation of
|
27
|
+
IO.closefrom and a pure Ruby version that looks something like this:
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
def IO.closefrom(n)
|
30
|
+
0.upto(n) do |fd|
|
31
|
+
IO.for_fd(fd).close
|
32
|
+
end
|
33
|
+
end
|
30
34
|
|
31
|
-
The primary difference is that this walks all file descriptors, rather
|
32
|
-
than only open file descriptors. However, I should note that this only
|
33
|
-
applies if your platform supports the closefrom() function. In that case,
|
34
|
-
the only advantage is speed.
|
35
|
+
The primary difference is that this walks all file descriptors, rather
|
36
|
+
than only open file descriptors. However, I should note that this only
|
37
|
+
applies if your platform supports the closefrom() function. In that case,
|
38
|
+
the only advantage is speed.
|
35
39
|
|
36
|
-
You might also be wondering what the difference is between my implementation
|
37
|
-
of IO.fdwalk and a pure Ruby version that looks something like this:
|
40
|
+
You might also be wondering what the difference is between my implementation
|
41
|
+
of IO.fdwalk and a pure Ruby version that looks something like this:
|
38
42
|
|
39
43
|
def IO.fdwalk(n)
|
40
44
|
ObjectSpace.each_object(File){ |f|
|
@@ -42,43 +46,41 @@ of IO.fdwalk and a pure Ruby version that looks something like this:
|
|
42
46
|
}
|
43
47
|
end
|
44
48
|
|
45
|
-
The primary difference is that this only closes Ruby file objects, not
|
46
|
-
necessarily every file handle opened by the Ruby process. For example, handles
|
47
|
-
opened via system() calls.
|
49
|
+
The primary difference is that this only closes Ruby file objects, not
|
50
|
+
necessarily every file handle opened by the Ruby process. For example, handles
|
51
|
+
opened via system() calls.
|
48
52
|
|
49
53
|
= Note to OS X Users
|
50
|
-
The OS X platform does not support closefrom(), fdwalk() or directio(). The
|
51
|
-
hand-crafted IO.closefrom function will not work because the getrlimit()
|
52
|
-
function on OS X does not work. Patches welcome.
|
54
|
+
The OS X platform does not support closefrom(), fdwalk() or directio(). The
|
55
|
+
hand-crafted IO.closefrom function will not work because the getrlimit()
|
56
|
+
function on OS X does not work. Patches welcome.
|
53
57
|
|
54
58
|
= Documentation
|
55
|
-
For further documentation, see the io_extra.txt file or the inline
|
56
|
-
documentation that was generated by RDoc (if you did a gem install).
|
59
|
+
For further documentation, see the io_extra.txt file or the inline
|
60
|
+
documentation that was generated by RDoc (if you did a gem install).
|
57
61
|
|
58
62
|
= Known Issues
|
59
|
-
None that I'm aware of (beyond those documented above). Please file any bug
|
60
|
-
reports on the project page at http://www.rubyforge.org/projects/shards.
|
63
|
+
None that I'm aware of (beyond those documented above). Please file any bug
|
64
|
+
reports on the project page at http://www.rubyforge.org/projects/shards.
|
61
65
|
|
62
66
|
= Future Plans
|
63
|
-
* I may add the File::O_DIRECT open constant on platforms that support it.
|
64
|
-
* Switch from C extension to FFI.
|
67
|
+
* I may add the File::O_DIRECT open constant on platforms that support it.
|
68
|
+
* Switch from C extension to FFI.
|
65
69
|
|
66
70
|
= Acknowledgements
|
67
|
-
Eric Wong for some great work on Linux compatibility and other fixes.
|
71
|
+
Eric Wong for some great work on Linux compatibility and other fixes.
|
68
72
|
|
69
73
|
= License
|
70
|
-
Artistic 2.0
|
74
|
+
Artistic 2.0
|
71
75
|
|
72
76
|
= Copyright
|
73
|
-
(C) 2003-
|
74
|
-
All Rights Reserved
|
77
|
+
(C) 2003-2010 Daniel J. Berger
|
78
|
+
All Rights Reserved
|
75
79
|
|
76
80
|
= Warranty
|
77
|
-
This package is provided "as is" and without any express or
|
78
|
-
implied warranties, including, without limitation, the implied
|
79
|
-
warranties of merchantability and fitness for a particular purpose.
|
81
|
+
This package is provided "as is" and without any express or
|
82
|
+
implied warranties, including, without limitation, the implied
|
83
|
+
warranties of merchantability and fitness for a particular purpose.
|
80
84
|
|
81
85
|
= Author
|
82
|
-
Daniel J. Berger
|
83
|
-
djberg96 at nospam at gmail dot com
|
84
|
-
imperator on IRC (irc.freenode.net)
|
86
|
+
Daniel J. Berger
|
data/Rakefile
CHANGED
@@ -2,55 +2,60 @@ require 'rake'
|
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'rbconfig'
|
5
|
-
include Config
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
exit(-1)
|
6
|
+
if Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
7
|
+
STDERR.puts 'Not supported on this platform. Exiting.'
|
8
|
+
exit(-1)
|
11
9
|
end
|
12
10
|
|
13
11
|
desc "Clean the build files for the io-extra source"
|
14
12
|
task :clean do
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
FileUtils.rm_rf('io') if File.exists?('io')
|
14
|
+
Dir.chdir('ext') do
|
15
|
+
sh 'make distclean' if File.exists?('extra.o')
|
18
16
|
|
19
|
-
|
17
|
+
FileUtils.rm_rf('extra/extra.c') if File.exists?('extra.c')
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
build_file = File.join(Dir.pwd, 'io', 'extra.' + Config::CONFIG['DLEXT'])
|
20
|
+
File.delete(build_file) if File.exists?(build_file)
|
21
|
+
end
|
24
22
|
end
|
25
23
|
|
26
24
|
desc "Build the io-extra library (but don't install it)"
|
27
25
|
task :build => [:clean] do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
Dir.chdir('ext') do
|
27
|
+
ruby 'extconf.rb'
|
28
|
+
sh 'make'
|
29
|
+
build_file = File.join(Dir.pwd, 'extra.' + Config::CONFIG['DLEXT'])
|
30
|
+
Dir.mkdir('io') unless File.exists?('io')
|
31
|
+
FileUtils.cp(build_file, 'io')
|
32
|
+
end
|
35
33
|
end
|
36
34
|
|
37
|
-
desc "Install the io-extra
|
35
|
+
desc "Install the io-extra library (non-gem)"
|
38
36
|
task :install => [:build] do
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
Dir.chdir('ext') do
|
38
|
+
sh 'make install'
|
39
|
+
end
|
42
40
|
end
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
namespace :gem do
|
43
|
+
desc 'Build the io-extra gem'
|
44
|
+
task :build do
|
45
|
+
spec = eval(IO.read('io-extra.gemspec'))
|
46
|
+
Gem::Builder.new(spec).build
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Install the io-extra library as a gem"
|
50
|
+
task :install => [:build] do
|
51
|
+
file = Dir["io-extra*.gem"].last
|
52
|
+
sh "gem install #{file}"
|
53
|
+
end
|
49
54
|
end
|
50
55
|
|
51
56
|
desc "Run the example io-extra program"
|
52
57
|
task :example => [:build] do
|
53
|
-
|
58
|
+
ruby '-Iext examples/example_io_extra.rb'
|
54
59
|
end
|
55
60
|
|
56
61
|
Rake::TestTask.new do |t|
|
data/ext/io/extra.c
CHANGED
@@ -380,6 +380,6 @@ void Init_extra(){
|
|
380
380
|
rb_define_singleton_method(rb_cIO, "pwrite", s_io_pwrite, 3);
|
381
381
|
#endif
|
382
382
|
|
383
|
-
/* 1.2.
|
384
|
-
rb_define_const(rb_cIO, "EXTRA_VERSION", rb_str_new2("1.2.
|
383
|
+
/* 1.2.1: The version of this library. This a string. */
|
384
|
+
rb_define_const(rb_cIO, "EXTRA_VERSION", rb_str_new2("1.2.1"));
|
385
385
|
}
|
data/io-extra.gemspec
CHANGED
@@ -1,42 +1,38 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rbconfig'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
if Config::CONFIG['host_os'] =~ /mswin|dos|win32|cygwin|mingw/i
|
6
|
+
STDERR.puts 'Not supported on this platform. Exiting.'
|
7
|
+
exit(-1)
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
10
|
+
spec.name = 'io-extra'
|
11
|
+
spec.version = '1.2.1'
|
12
|
+
spec.author = 'Daniel J. Berger'
|
13
|
+
spec.license = 'Artistic 2.0'
|
14
|
+
spec.email = 'djberg96@gmail.com'
|
15
|
+
spec.homepage = 'http://www.rubyforge.org/projects/shards'
|
16
|
+
spec.summary = 'Adds extra methods to the IO class.'
|
17
|
+
spec.test_file = 'test/test_io_extra.rb'
|
18
|
+
spec.extensions = ['ext/extconf.rb']
|
19
|
+
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
spec.extra_rdoc_files = [
|
22
|
+
'CHANGES',
|
23
|
+
'README',
|
24
|
+
'MANIFEST',
|
25
|
+
'ext/io/extra.c'
|
26
|
+
]
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
spec.rubyforge_project = 'shards'
|
29
|
+
spec.required_ruby_version = '>= 1.8.6'
|
31
30
|
|
32
|
-
|
31
|
+
spec.add_development_dependency('test-unit', '>= 2.0.3')
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
spec.description = <<-EOF
|
34
|
+
Adds the IO.closefrom, IO.fdwalk, IO.pread, IO.pread_ptr, and IO.pwrite
|
35
|
+
class methods as well as the IO#directio and IO#directio? instance
|
36
|
+
methods (for those platforms that support them).
|
37
|
+
EOF
|
39
38
|
end
|
40
|
-
|
41
|
-
Gem.manage_gems if Gem::RubyGemsVersion.to_f < 1.0
|
42
|
-
Gem::Builder.new(spec).build
|
data/test/test_io_extra.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-extra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 2.0.3
|
24
24
|
version:
|
25
|
-
description: "
|
25
|
+
description: " Adds the IO.closefrom, IO.fdwalk, IO.pread, IO.pread_ptr, and IO.pwrite\n class methods as well as the IO#directio and IO#directio? instance\n methods (for those platforms that support them).\n"
|
26
26
|
email: djberg96@gmail.com
|
27
27
|
executables: []
|
28
28
|
|
@@ -34,16 +34,16 @@ extra_rdoc_files:
|
|
34
34
|
- MANIFEST
|
35
35
|
- ext/io/extra.c
|
36
36
|
files:
|
37
|
-
-
|
38
|
-
- doc/io_extra.txt
|
37
|
+
- MANIFEST
|
39
38
|
- examples/example_io_extra.rb
|
40
|
-
-
|
41
|
-
-
|
39
|
+
- README
|
40
|
+
- CHANGES
|
42
41
|
- io-extra.gemspec
|
43
|
-
- MANIFEST
|
44
42
|
- Rakefile
|
45
|
-
- README
|
46
43
|
- test/test_io_extra.rb
|
44
|
+
- doc/io_extra.txt
|
45
|
+
- ext/io/extra.c
|
46
|
+
- ext/extconf.rb
|
47
47
|
has_rdoc: true
|
48
48
|
homepage: http://www.rubyforge.org/projects/shards
|
49
49
|
licenses:
|
@@ -57,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 1.8.
|
60
|
+
version: 1.8.6
|
61
61
|
version:
|
62
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|