wishdev-rio 0.4.3.1
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/COPYING +341 -0
- data/README +81 -0
- data/Rakefile +281 -0
- data/build_doc.rb +94 -0
- data/doc/ANNOUNCE +159 -0
- data/doc/RELEASE_NOTES +308 -0
- data/doc/RIOIS +215 -0
- data/doc/generators/template/html/rio.css +428 -0
- data/doc/generators/template/html/rio.rb +523 -0
- data/doc/generators/template/html/ugly.rb +132 -0
- data/doc/pkg_def.rb +60 -0
- data/doc/rfc1738.txt +1403 -0
- data/doc/rfc959.txt +3933 -0
- data/ex/catcsv.rb +64 -0
- data/ex/colx.rb +8 -0
- data/ex/findinruby +15 -0
- data/ex/findruby +14 -0
- data/ex/passwd_report.rb +8 -0
- data/ex/prompt.rb +25 -0
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +42 -0
- data/ex/riogunzip +31 -0
- data/ex/riogzip +24 -0
- data/ex/rioprompt.rb +10 -0
- data/ex/targz2zip +17 -0
- data/ex/tonl +10 -0
- data/lib/rio/abstract_method.rb +56 -0
- data/lib/rio/argv.rb +56 -0
- data/lib/rio/arycopy.rb +43 -0
- data/lib/rio/assert.rb +114 -0
- data/lib/rio/base.rb +56 -0
- data/lib/rio/callstr.rb +46 -0
- data/lib/rio/const.rb +51 -0
- data/lib/rio/construct.rb +50 -0
- data/lib/rio/constructor.rb +258 -0
- data/lib/rio/context/autoclose.rb +72 -0
- data/lib/rio/context/copying.rb +55 -0
- data/lib/rio/context/cxx.rb +66 -0
- data/lib/rio/context/dir.rb +120 -0
- data/lib/rio/context/gzip.rb +50 -0
- data/lib/rio/context/methods.rb +182 -0
- data/lib/rio/context/skip.rb +66 -0
- data/lib/rio/context/stream.rb +229 -0
- data/lib/rio/context.rb +117 -0
- data/lib/rio/cp.rb +370 -0
- data/lib/rio/def.rb +53 -0
- data/lib/rio/dir.rb +144 -0
- data/lib/rio/doc/EXAMPLES.rb +299 -0
- data/lib/rio/doc/HOWTO.rb +737 -0
- data/lib/rio/doc/INDEX.rb +311 -0
- data/lib/rio/doc/INTRO.rb +1068 -0
- data/lib/rio/doc/OPTIONAL.rb +130 -0
- data/lib/rio/doc/SYNOPSIS.rb +183 -0
- data/lib/rio/doc.rb +45 -0
- data/lib/rio/entrysel.rb +246 -0
- data/lib/rio/exception/copy.rb +97 -0
- data/lib/rio/exception/notimplemented.rb +57 -0
- data/lib/rio/exception/notsupported.rb +46 -0
- data/lib/rio/exception/open.rb +61 -0
- data/lib/rio/exception/state.rb +73 -0
- data/lib/rio/exception.rb +41 -0
- data/lib/rio/ext/csv.rb +351 -0
- data/lib/rio/ext/if.rb +45 -0
- data/lib/rio/ext/mp3info.rb +80 -0
- data/lib/rio/ext/splitlines.rb +253 -0
- data/lib/rio/ext/yaml/doc.rb +133 -0
- data/lib/rio/ext/yaml/tie.rb +149 -0
- data/lib/rio/ext/yaml.rb +164 -0
- data/lib/rio/ext/zipfile/fs.rb +116 -0
- data/lib/rio/ext/zipfile/rl.rb +251 -0
- data/lib/rio/ext/zipfile/rootdir.rb +117 -0
- data/lib/rio/ext/zipfile/state.rb +161 -0
- data/lib/rio/ext/zipfile/wrap.rb +204 -0
- data/lib/rio/ext/zipfile.rb +110 -0
- data/lib/rio/ext.rb +138 -0
- data/lib/rio/factory.rb +436 -0
- data/lib/rio/file.rb +118 -0
- data/lib/rio/filter/closeoneof.rb +103 -0
- data/lib/rio/filter/gzip.rb +70 -0
- data/lib/rio/filter.rb +94 -0
- data/lib/rio/fs/base.rb +41 -0
- data/lib/rio/fs/impl.rb +122 -0
- data/lib/rio/fs/native.rb +75 -0
- data/lib/rio/fs/stream.rb +61 -0
- data/lib/rio/fs/url.rb +63 -0
- data/lib/rio/ftp/conncache.rb +101 -0
- data/lib/rio/ftp/dir.rb +94 -0
- data/lib/rio/ftp/fs.rb +180 -0
- data/lib/rio/ftp/ftpfile.rb +20 -0
- data/lib/rio/grande.rb +97 -0
- data/lib/rio/handle.rb +100 -0
- data/lib/rio/if/basic.rb +64 -0
- data/lib/rio/if/csv.rb +76 -0
- data/lib/rio/if/dir.rb +157 -0
- data/lib/rio/if/file.rb +89 -0
- data/lib/rio/if/fileordir.rb +268 -0
- data/lib/rio/if/grande.rb +729 -0
- data/lib/rio/if/grande_entry.rb +379 -0
- data/lib/rio/if/grande_stream.rb +693 -0
- data/lib/rio/if/internal.rb +125 -0
- data/lib/rio/if/path.rb +462 -0
- data/lib/rio/if/rubyio.rb +681 -0
- data/lib/rio/if/string.rb +83 -0
- data/lib/rio/if/temp.rb +45 -0
- data/lib/rio/if/test.rb +282 -0
- data/lib/rio/if/yaml.rb +206 -0
- data/lib/rio/if.rb +64 -0
- data/lib/rio/ioh.rb +162 -0
- data/lib/rio/iomode.rb +109 -0
- data/lib/rio/ios/fail.rb +106 -0
- data/lib/rio/ios/generic.rb +119 -0
- data/lib/rio/ios/mode.rb +60 -0
- data/lib/rio/ios/null.rb +119 -0
- data/lib/rio/iowrap.rb +128 -0
- data/lib/rio/kernel.rb +54 -0
- data/lib/rio/local.rb +62 -0
- data/lib/rio/match.rb +53 -0
- data/lib/rio/matchrecord.rb +283 -0
- data/lib/rio/no_warn.rb +49 -0
- data/lib/rio/nullio.rb +159 -0
- data/lib/rio/open3.rb +68 -0
- data/lib/rio/ops/construct.rb +61 -0
- data/lib/rio/ops/create.rb +77 -0
- data/lib/rio/ops/dir.rb +346 -0
- data/lib/rio/ops/either.rb +134 -0
- data/lib/rio/ops/file.rb +102 -0
- data/lib/rio/ops/path.rb +296 -0
- data/lib/rio/ops/stream/input.rb +267 -0
- data/lib/rio/ops/stream/output.rb +100 -0
- data/lib/rio/ops/stream/read.rb +86 -0
- data/lib/rio/ops/stream/write.rb +57 -0
- data/lib/rio/ops/stream.rb +87 -0
- data/lib/rio/ops/symlink.rb +80 -0
- data/lib/rio/path/reset.rb +69 -0
- data/lib/rio/path.rb +129 -0
- data/lib/rio/piper/cp.rb +80 -0
- data/lib/rio/piper.rb +122 -0
- data/lib/rio/prompt.rb +66 -0
- data/lib/rio/rectype.rb +88 -0
- data/lib/rio/rl/base.rb +118 -0
- data/lib/rio/rl/builder.rb +117 -0
- data/lib/rio/rl/chmap.rb +66 -0
- data/lib/rio/rl/fs2url.rb +82 -0
- data/lib/rio/rl/ioi.rb +78 -0
- data/lib/rio/rl/path.rb +110 -0
- data/lib/rio/rl/pathmethods.rb +116 -0
- data/lib/rio/rl/uri.rb +200 -0
- data/lib/rio/rl/withpath.rb +296 -0
- data/lib/rio/scheme/aryio.rb +88 -0
- data/lib/rio/scheme/cmdio.rb +80 -0
- data/lib/rio/scheme/cmdpipe.rb +118 -0
- data/lib/rio/scheme/fd.rb +65 -0
- data/lib/rio/scheme/ftp.rb +141 -0
- data/lib/rio/scheme/http.rb +78 -0
- data/lib/rio/scheme/null.rb +55 -0
- data/lib/rio/scheme/path.rb +98 -0
- data/lib/rio/scheme/stderr.rb +55 -0
- data/lib/rio/scheme/stdio.rb +71 -0
- data/lib/rio/scheme/strio.rb +87 -0
- data/lib/rio/scheme/sysio.rb +63 -0
- data/lib/rio/scheme/tcp.rb +75 -0
- data/lib/rio/scheme/temp.rb +200 -0
- data/lib/rio/state/error.rb +72 -0
- data/lib/rio/state.rb +242 -0
- data/lib/rio/stream/base.rb +54 -0
- data/lib/rio/stream/duplex.rb +79 -0
- data/lib/rio/stream/open.rb +202 -0
- data/lib/rio/stream.rb +181 -0
- data/lib/rio/symantics.rb +45 -0
- data/lib/rio/tempdir.rb +132 -0
- data/lib/rio/to_rio/all.rb +39 -0
- data/lib/rio/to_rio/array.rb +39 -0
- data/lib/rio/to_rio/io.rb +40 -0
- data/lib/rio/to_rio/object.rb +42 -0
- data/lib/rio/to_rio/string.rb +40 -0
- data/lib/rio/to_rio.rb +67 -0
- data/lib/rio/uri/file.rb +198 -0
- data/lib/rio/util.rb +48 -0
- data/lib/rio/version.rb +51 -0
- data/lib/rio.rb +162 -0
- data/setup.rb +1360 -0
- data/test/bin/count_lines.rb +11 -0
- data/test/bin/find_lines.rb +13 -0
- data/test/bin/list_dir.rb +14 -0
- data/test/ftp/all.rb +9 -0
- data/test/ftp/anon_copy_data.rb +36 -0
- data/test/ftp/anon_misc.rb +124 -0
- data/test/ftp/anon_read.rb +105 -0
- data/test/ftp/anon_special.rb +68 -0
- data/test/ftp/anon_write.rb +70 -0
- data/test/ftp/ftp2ftp.rb +51 -0
- data/test/ftp/initftpfiles.rb +14 -0
- data/test/ftp/testdef.rb +55 -0
- data/test/gem_runtests.rb +15 -0
- data/test/http/all.rb +4 -0
- data/test/http/copy-from-http.rb +141 -0
- data/test/http/uri-meta.rb +72 -0
- data/test/lib/temp_server.rb +46 -0
- data/test/runalltests.rb +17 -0
- data/test/runftptests.rb +14 -0
- data/test/runhttp.rb +11 -0
- data/test/runhttptests.rb +14 -0
- data/test/runtests.rb +52 -0
- data/test/tc/abs.rb +355 -0
- data/test/tc/all.rb +80 -0
- data/test/tc/base.rb +31 -0
- data/test/tc/base2.rb +87 -0
- data/test/tc/cd1.rb +113 -0
- data/test/tc/clearsel.rb +68 -0
- data/test/tc/clone.rb +208 -0
- data/test/tc/closeoncopy.rb +102 -0
- data/test/tc/closeoneof.rb +194 -0
- data/test/tc/cmdpipe.rb +149 -0
- data/test/tc/copy-dir-samevar.rb +91 -0
- data/test/tc/copy-from.rb +129 -0
- data/test/tc/copy-to.rb +91 -0
- data/test/tc/copy.rb +74 -0
- data/test/tc/copyarray.rb +188 -0
- data/test/tc/copydest.rb +50 -0
- data/test/tc/copydir.rb +166 -0
- data/test/tc/copydirlines.rb +121 -0
- data/test/tc/copylines.rb +46 -0
- data/test/tc/copynonex.rb +118 -0
- data/test/tc/copysymlink.rb +39 -0
- data/test/tc/create.rb +114 -0
- data/test/tc/csv.rb +226 -0
- data/test/tc/csv2.rb +138 -0
- data/test/tc/csv_columns.rb +37 -0
- data/test/tc/csvutil.rb +56 -0
- data/test/tc/dir.rb +76 -0
- data/test/tc/dir_iter.rb +383 -0
- data/test/tc/dirautoclose.rb +67 -0
- data/test/tc/dirent.rb +178 -0
- data/test/tc/dirss.rb +81 -0
- data/test/tc/each.rb +111 -0
- data/test/tc/each_break.rb +243 -0
- data/test/tc/edf.rb +81 -0
- data/test/tc/empty.rb +51 -0
- data/test/tc/emptyriodir.rb +129 -0
- data/test/tc/entary.rb +227 -0
- data/test/tc/entsel.rb +110 -0
- data/test/tc/eq.rb +101 -0
- data/test/tc/expand_path.rb +69 -0
- data/test/tc/ext.rb +136 -0
- data/test/tc/fileno.rb +94 -0
- data/test/tc/files_select.rb +92 -0
- data/test/tc/get.rb +152 -0
- data/test/tc/getrec.rb +137 -0
- data/test/tc/gzip.rb +109 -0
- data/test/tc/io_each_byte.rb +60 -0
- data/test/tc/io_read.rb +80 -0
- data/test/tc/iometh.rb +149 -0
- data/test/tc/likeio.rb +116 -0
- data/test/tc/line_record_row.rb +51 -0
- data/test/tc/lineno.rb +196 -0
- data/test/tc/lines.rb +66 -0
- data/test/tc/misc.rb +432 -0
- data/test/tc/nolines.rb +204 -0
- data/test/tc/noqae.rb +879 -0
- data/test/tc/null.rb +45 -0
- data/test/tc/once.rb +6 -0
- data/test/tc/overload.rb +140 -0
- data/test/tc/pa.rb +158 -0
- data/test/tc/path_parts.rb +175 -0
- data/test/tc/pathop.rb +60 -0
- data/test/tc/paths.rb +145 -0
- data/test/tc/pid.rb +31 -0
- data/test/tc/piper.rb +143 -0
- data/test/tc/programs_util.rb +24 -0
- data/test/tc/qae.rb +493 -0
- data/test/tc/qae_riovar.rb +499 -0
- data/test/tc/readline.rb +30 -0
- data/test/tc/records.rb +68 -0
- data/test/tc/rename.rb +233 -0
- data/test/tc/rename_assign.rb +45 -0
- data/test/tc/riorl.rb +181 -0
- data/test/tc/route.rb +51 -0
- data/test/tc/selnosel.rb +33 -0
- data/test/tc/skip.rb +89 -0
- data/test/tc/skiplines.rb +71 -0
- data/test/tc/split.rb +28 -0
- data/test/tc/splitlines.rb +65 -0
- data/test/tc/splitpath.rb +83 -0
- data/test/tc/sub.rb +46 -0
- data/test/tc/symlink.rb +176 -0
- data/test/tc/symlink0.rb +348 -0
- data/test/tc/symlink1.rb +114 -0
- data/test/tc/synopsis.rb +75 -0
- data/test/tc/temp.rb +152 -0
- data/test/tc/tempdir.rb +60 -0
- data/test/tc/tempfile.rb +66 -0
- data/test/tc/testcase.rb +170 -0
- data/test/tc/tonl.rb +37 -0
- data/test/tc/truncate.rb +39 -0
- data/test/tc/yaml.rb +275 -0
- metadata +387 -0
data/lib/rio/assert.rb
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
|
4
|
+
# All rights reserved
|
|
5
|
+
#
|
|
6
|
+
# This file is part of the Rio library for ruby.
|
|
7
|
+
#
|
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with Rio; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# ===============================================================================
|
|
22
|
+
#++
|
|
23
|
+
#
|
|
24
|
+
# To create the documentation for Rio run the command
|
|
25
|
+
# ruby build_doc.rb
|
|
26
|
+
# from the distribution directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Doc::EXAMPLES
|
|
33
|
+
# * RIO::Rio
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#!/usr/bin/env ruby
|
|
38
|
+
|
|
39
|
+
require 'rio/kernel'
|
|
40
|
+
module RIO
|
|
41
|
+
module Assert #:nodoc: all
|
|
42
|
+
def ok(a,b,msg=nil)
|
|
43
|
+
puts "PASS" + (msg.nil? ? "" : ": #{msg}")
|
|
44
|
+
end
|
|
45
|
+
def nok(a,b,msg=nil)
|
|
46
|
+
puts "FAIL" + (msg.nil? ? "" : ": #{msg}")
|
|
47
|
+
puts " exp: #{a.inspect}"
|
|
48
|
+
puts " was: #{b.inspect}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def assert(a,msg=nil)
|
|
52
|
+
assert_equal(true,a,msg)
|
|
53
|
+
end
|
|
54
|
+
def assert_equal(a,b,msg=nil)
|
|
55
|
+
if a == b
|
|
56
|
+
ok(a,b,msg)
|
|
57
|
+
else
|
|
58
|
+
nok(a,b,msg)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
def assert_case_equal(a,b,msg=nil)
|
|
62
|
+
if a == b
|
|
63
|
+
ok(a,b,msg)
|
|
64
|
+
else
|
|
65
|
+
nok(a,b,msg)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
def assert_block(msg=nil)
|
|
69
|
+
if yield
|
|
70
|
+
ok(nil,nil,msg)
|
|
71
|
+
else
|
|
72
|
+
nok(nil,nil,msg)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def assert_not_equal(a,b,msg=nil)
|
|
77
|
+
if a != b
|
|
78
|
+
ok(a,b,msg)
|
|
79
|
+
else
|
|
80
|
+
nok(a,b,msg)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
def assert_nil(a,msg=nil)
|
|
84
|
+
if a.nil?
|
|
85
|
+
ok(nil,a)
|
|
86
|
+
else
|
|
87
|
+
nok(nil,a)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
def assert_same(a,b,msg=nil)
|
|
91
|
+
if a.equal? b
|
|
92
|
+
ok(a,b)
|
|
93
|
+
else
|
|
94
|
+
nok(a,b)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
def assert_match(a,b,msg=nil)
|
|
98
|
+
if a =~ b
|
|
99
|
+
ok(a,b)
|
|
100
|
+
else
|
|
101
|
+
nok(a,b)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
def assert_kind_of(a,b,msg=nil)
|
|
105
|
+
if b.kind_of?(a)
|
|
106
|
+
ok(a,b.class)
|
|
107
|
+
else
|
|
108
|
+
nok(a,b.class)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
def assert_equal_s(a,b,msg=nil) assert_equal(a.to_s,b.to_s,msg) end
|
|
112
|
+
def assert_equal_a(a,b,msg=nil) assert_equal(a.sort,b.sort,msg) end
|
|
113
|
+
end
|
|
114
|
+
end
|
data/lib/rio/base.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
|
4
|
+
# All rights reserved
|
|
5
|
+
#
|
|
6
|
+
# This file is part of the Rio library for ruby.
|
|
7
|
+
#
|
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with Rio; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# ===============================================================================
|
|
22
|
+
#++
|
|
23
|
+
#
|
|
24
|
+
# To create the documentation for Rio run the command
|
|
25
|
+
# ruby build_doc.rb
|
|
26
|
+
# from the distribution directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Doc::EXAMPLES
|
|
33
|
+
# * RIO::Rio
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
module RIO
|
|
38
|
+
class Base < ::Object #:nodoc: all
|
|
39
|
+
KEEPSYM = {
|
|
40
|
+
'__id__' => true,
|
|
41
|
+
'__send__' => true,
|
|
42
|
+
'send' => true,
|
|
43
|
+
'class' => true,
|
|
44
|
+
'kind_of?' => true,
|
|
45
|
+
'instance_of?' => true,
|
|
46
|
+
'equal?' => true,
|
|
47
|
+
'respond_to?' => true,
|
|
48
|
+
'object_id' => true,
|
|
49
|
+
'dup' => true,
|
|
50
|
+
'clone' => true,
|
|
51
|
+
'nil?' => true,
|
|
52
|
+
'open' => true,
|
|
53
|
+
}.freeze
|
|
54
|
+
instance_methods.each { |m| undef_method m unless KEEPSYM[m.to_s] }
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/rio/callstr.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
|
4
|
+
# All rights reserved
|
|
5
|
+
#
|
|
6
|
+
# This file is part of the Rio library for ruby.
|
|
7
|
+
#
|
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with Rio; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# ===============================================================================
|
|
22
|
+
#++
|
|
23
|
+
#
|
|
24
|
+
# To create the documentation for Rio run the command
|
|
25
|
+
# ruby build_doc.rb
|
|
26
|
+
# from the distribution directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Doc::EXAMPLES
|
|
33
|
+
# * RIO::Rio
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
module RIO
|
|
38
|
+
module CallStr #:nodoc: all
|
|
39
|
+
def callstr(func,*args)
|
|
40
|
+
self.class.to_s+'['+self.to_url+']'+'.'+func.to_s+'('+args.join(',')+')'
|
|
41
|
+
end
|
|
42
|
+
def scallstr(func,*args)
|
|
43
|
+
self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/lib/rio/const.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
|
4
|
+
# All rights reserved
|
|
5
|
+
#
|
|
6
|
+
# This file is part of the Rio library for ruby.
|
|
7
|
+
#
|
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with Rio; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# ===============================================================================
|
|
22
|
+
#++
|
|
23
|
+
#
|
|
24
|
+
# To create the documentation for Rio run the command
|
|
25
|
+
# ruby build_doc.rb
|
|
26
|
+
# from the distribution directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Doc::EXAMPLES
|
|
33
|
+
# * RIO::Rio
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
module RIO
|
|
37
|
+
SEEK_SET = IO::SEEK_SET
|
|
38
|
+
SEEK_END = IO::SEEK_END
|
|
39
|
+
SEEK_CUR = IO::SEEK_CUR
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if $0 == __FILE__
|
|
43
|
+
eval DATA.read, nil, $0, __LINE__+4
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
__END__
|
|
47
|
+
|
|
48
|
+
puts
|
|
49
|
+
puts("Run the tests that came with the distribution")
|
|
50
|
+
puts("From the distribution directory use 'test/runtests.rb'")
|
|
51
|
+
puts
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
|
4
|
+
# All rights reserved
|
|
5
|
+
#
|
|
6
|
+
# This file is part of the Rio library for ruby.
|
|
7
|
+
#
|
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with Rio; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# ===============================================================================
|
|
22
|
+
#++
|
|
23
|
+
#
|
|
24
|
+
# To create the documentation for Rio run the command
|
|
25
|
+
# ruby build_doc.rb
|
|
26
|
+
# from the distribution directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Doc::EXAMPLES
|
|
33
|
+
# * RIO::Rio
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
module RIO
|
|
38
|
+
require 'rio/ops/construct'
|
|
39
|
+
include Ops::Construct
|
|
40
|
+
|
|
41
|
+
module_function(*RIO::CONSTRUCTOR_SYMS)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
module RIO
|
|
45
|
+
class Rio
|
|
46
|
+
RIO::CONSTRUCTOR_SYMS.each { |sym|
|
|
47
|
+
class_eval "def self.#{sym}(*args,&block) self.rio(:#{sym},*args,&block) end"
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
|
4
|
+
# All rights reserved
|
|
5
|
+
#
|
|
6
|
+
# This file is part of the Rio library for ruby.
|
|
7
|
+
#
|
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with Rio; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# ===============================================================================
|
|
22
|
+
#++
|
|
23
|
+
#
|
|
24
|
+
# To create the documentation for Rio run the command
|
|
25
|
+
# ruby build_doc.rb
|
|
26
|
+
# from the distribution directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Doc::EXAMPLES
|
|
33
|
+
# * RIO::Rio
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
|
|
38
|
+
require 'rio'
|
|
39
|
+
|
|
40
|
+
module RIO
|
|
41
|
+
# Rio Constructor
|
|
42
|
+
#
|
|
43
|
+
# For purposes of discussion, we divide Rios into two catagories, those that have a path
|
|
44
|
+
# and those that don't.
|
|
45
|
+
#
|
|
46
|
+
# ==== Creating a Rio that has a path
|
|
47
|
+
#
|
|
48
|
+
# To create a Rio that has a path the arguments to +rio+ may be:
|
|
49
|
+
#
|
|
50
|
+
# * a string representing the entire path. The separator used for Rios is as specified in RFC1738 ('/').
|
|
51
|
+
# rio('adir/afile')
|
|
52
|
+
# * a string representing a fully qualified +file+ URL as per RFC1738
|
|
53
|
+
# rio('file:///atopleveldir/adir/afile')
|
|
54
|
+
# * a +URI+ object representing a +file+ or generic +URL+
|
|
55
|
+
# rio(URI('adir/afile'))
|
|
56
|
+
# * the components of a path as separate arguments
|
|
57
|
+
# rio('adir','afile')
|
|
58
|
+
# * the components of a path as an array of separate arguments
|
|
59
|
+
# rio(%w/adir afile/)
|
|
60
|
+
# * another Rio
|
|
61
|
+
# another_rio = rio('adir/afile')
|
|
62
|
+
# rio(another_rio)
|
|
63
|
+
# * any object whose +to_s+ method returns one of the above
|
|
64
|
+
# rio(Pathname.new('apath'))
|
|
65
|
+
# * any combination of the above either as separate arguments or as elements of an array,
|
|
66
|
+
# another_rio = rio('dir1/dir2')
|
|
67
|
+
# auri = URI('dir4/dir5)
|
|
68
|
+
# rio(another_rio,'dir3',auri,'dir6/dir7')
|
|
69
|
+
#
|
|
70
|
+
# ===== Creating a Rio that refers to a web page
|
|
71
|
+
#
|
|
72
|
+
# To create a Rio that refers to a web page the arguments to +rio+ may be:
|
|
73
|
+
#
|
|
74
|
+
# * a string representing a fully qualified +http+ URL
|
|
75
|
+
# rio('http://ruby-doc.org/index.html')
|
|
76
|
+
# * a +URI+ object representing a +http+ +URL+
|
|
77
|
+
# rio(URI('http://ruby-doc.org/index.html'))
|
|
78
|
+
# * either of the above with additional path elements
|
|
79
|
+
# rio('http://www.ruby-doc.org/','core','classes/Object.html')
|
|
80
|
+
#
|
|
81
|
+
# ===== Creating a Rio that refers to a file or directory on a FTP server
|
|
82
|
+
#
|
|
83
|
+
# To create a Rio that refers to a file on a FTP server the arguments to +rio+ may be:
|
|
84
|
+
#
|
|
85
|
+
# * a string representing a fully qualified +ftp+ URL
|
|
86
|
+
# rio('ftp://user:password@ftp.example.com/afile.tar.gz')
|
|
87
|
+
# * a +URI+ object representing a +ftp+ +URL+
|
|
88
|
+
# rio(URI('ftp://ftp.example.com/afile.tar.gz'))
|
|
89
|
+
# * either of the above with additional path elements
|
|
90
|
+
# rio('ftp://ftp.gnu.org/pub/gnu','emacs','windows','README')
|
|
91
|
+
#
|
|
92
|
+
# ==== Creating Rios that do not have a path
|
|
93
|
+
#
|
|
94
|
+
# To create a Rio without a path, the first argument to +rio+ is usually
|
|
95
|
+
# either a single character or a symbol.
|
|
96
|
+
#
|
|
97
|
+
# ===== Creating a Rio that refers to a clone of your programs stdin or stdout.
|
|
98
|
+
#
|
|
99
|
+
# <tt>rio(?-)</tt> (mnemonic: '-' is used by some Unix programs to specify stdin or stdout in place of a file)
|
|
100
|
+
#
|
|
101
|
+
# <tt>rio(:stdio)</tt>
|
|
102
|
+
#
|
|
103
|
+
# Just as a Rio that refers to a file, does not know whether that file will be opened for reading or
|
|
104
|
+
# writing until an I/O operation is specified, a <tt>stdio:</tt> Rio does not know whether it will connect
|
|
105
|
+
# to stdin or stdout until an I/O operation is specified.
|
|
106
|
+
#
|
|
107
|
+
# Currently :stdin and :stdout are allowed as synonyms for :stdio. This allows one to write
|
|
108
|
+
# rio(:stdout).puts("Hello :stdout")
|
|
109
|
+
# which is reasonable. It also allows one to write
|
|
110
|
+
# rio(:stdin).puts("Hello :stdin")
|
|
111
|
+
# which is not reasonable and will be disallowed in future releases.
|
|
112
|
+
#
|
|
113
|
+
# ===== Creating a Rio that refers to a clone of your programs stderr.
|
|
114
|
+
#
|
|
115
|
+
# <tt>rio(?=)</tt> (mnemonic: '-' refers to fileno 1, so '=' refers to fileno 2)
|
|
116
|
+
#
|
|
117
|
+
# <tt>rio(:stderr)</tt>
|
|
118
|
+
#
|
|
119
|
+
# ===== Creating a Rio that refers to an arbitrary IO object.
|
|
120
|
+
#
|
|
121
|
+
# an_io = ::File.new('afile')
|
|
122
|
+
# rio(an_io)
|
|
123
|
+
#
|
|
124
|
+
# ===== Creating a Rio that refers to a file descriptor
|
|
125
|
+
#
|
|
126
|
+
# <tt>rio(?#,file_descriptor)</tt> (mnemonic: a file descriptor is a number '#')
|
|
127
|
+
#
|
|
128
|
+
# <tt>rio(:fd,file_descriptor)</tt>
|
|
129
|
+
#
|
|
130
|
+
# an_io = ::File.new('afile')
|
|
131
|
+
# fnum = an_io.fileno
|
|
132
|
+
# rio(?#,fnum)
|
|
133
|
+
#
|
|
134
|
+
# ===== Creating a Rio that refers to a StringIO object
|
|
135
|
+
#
|
|
136
|
+
# <tt>rio(?")</tt> (mnemonic: '"' surrounds strings)
|
|
137
|
+
#
|
|
138
|
+
# <tt>rio(:string)</tt>
|
|
139
|
+
#
|
|
140
|
+
# <tt>rio(:strio)</tt>
|
|
141
|
+
#
|
|
142
|
+
# <tt>rio(:stringio)</tt>
|
|
143
|
+
#
|
|
144
|
+
#
|
|
145
|
+
# * create a Rio that refers to a string that it creates
|
|
146
|
+
# rio(?")
|
|
147
|
+
# * create a Rio that refers to a string of your choosing
|
|
148
|
+
# astring = ""
|
|
149
|
+
# rio(?",astring)
|
|
150
|
+
#
|
|
151
|
+
# ===== Creating a Rio that refers to a temporary object
|
|
152
|
+
#
|
|
153
|
+
# To create a temporary object that will become a file (Tempfile)
|
|
154
|
+
# or a temporary directory, depending on how it is used.
|
|
155
|
+
#
|
|
156
|
+
# <tt>rio(??)</tt> (mnemonic: '?' you don't know its name)
|
|
157
|
+
#
|
|
158
|
+
# <tt>rio(:temp)</tt>
|
|
159
|
+
#
|
|
160
|
+
# The following are also supported, to specify file or directory
|
|
161
|
+
#
|
|
162
|
+
# <tt>rio(:tempfile)</tt>
|
|
163
|
+
#
|
|
164
|
+
# <tt>rio(:tempdir)</tt>
|
|
165
|
+
#
|
|
166
|
+
# rio(??)
|
|
167
|
+
# rio(??,basename='rio',tmpdir=Dir::tmpdir)
|
|
168
|
+
#
|
|
169
|
+
# To create a temporary object that will become a file
|
|
170
|
+
# or a directory, depending on how you use it:
|
|
171
|
+
# rio(??)
|
|
172
|
+
# rio(??,basename='rio',tmpdir=Dir::tmpdir)
|
|
173
|
+
#
|
|
174
|
+
# To force it to become a file
|
|
175
|
+
# rio(??).file
|
|
176
|
+
# or just write to it.
|
|
177
|
+
#
|
|
178
|
+
# To force it to become a directory:
|
|
179
|
+
# rio(??).mkdir
|
|
180
|
+
# or
|
|
181
|
+
# rio(??).chdir
|
|
182
|
+
#
|
|
183
|
+
#
|
|
184
|
+
# ===== Creating a Rio that refers to an arbitrary TCPSocket
|
|
185
|
+
#
|
|
186
|
+
# <tt>rio('tcp:',hostname,port)</tt>
|
|
187
|
+
#
|
|
188
|
+
# <tt>rio('tcp://hostname:port')</tt>
|
|
189
|
+
#
|
|
190
|
+
# <tt>rio(:tcp,hostname,port)</tt>
|
|
191
|
+
#
|
|
192
|
+
# ===== Creating a Rio that runs an external program and connects to its stdin and stdout
|
|
193
|
+
#
|
|
194
|
+
# <tt>rio(?-,cmd)</tt> (mnemonic: '-' is used by some Unix programs to specify stdin or stdout in place of a file)
|
|
195
|
+
#
|
|
196
|
+
# <tt>rio(?`,cmd)</tt> (mnemonic: '`' (backtick) runs an external program in ruby)
|
|
197
|
+
#
|
|
198
|
+
# <tt>rio(:cmdio,cmd)</tt>
|
|
199
|
+
#
|
|
200
|
+
# This is Rio's interface to IO#popen
|
|
201
|
+
#
|
|
202
|
+
# ===== Creating a Rio that acts like /dev/null
|
|
203
|
+
#
|
|
204
|
+
# <tt>rio(nil)</tt>
|
|
205
|
+
#
|
|
206
|
+
# <tt>rio(:null)</tt>
|
|
207
|
+
#
|
|
208
|
+
# This rio behaves like the Unix file /dev/null, but does depend on it -
|
|
209
|
+
# and thus will work on non-Unix systems. Reading behaves as if reading from
|
|
210
|
+
# an empty file, and writing to it discards anything written.
|
|
211
|
+
#
|
|
212
|
+
# ===== Creating a Rio Pipe
|
|
213
|
+
#
|
|
214
|
+
# A Rio Pipe is a sequence of Rios that are run with the output of each being
|
|
215
|
+
# copied to the input of the next.
|
|
216
|
+
#
|
|
217
|
+
# <tt>rio(?|, ario, ...)</tt> (mnemonic: '|' is the Unix pipe operator)
|
|
218
|
+
#
|
|
219
|
+
# <tt>rio(:cmdpipe, ario, ...)</tt>
|
|
220
|
+
#
|
|
221
|
+
#
|
|
222
|
+
# See also IF::Grande#|
|
|
223
|
+
#
|
|
224
|
+
#
|
|
225
|
+
def rio(*args,&block) # :yields: self
|
|
226
|
+
Rio.rio(*args,&block)
|
|
227
|
+
end
|
|
228
|
+
module_function :rio
|
|
229
|
+
|
|
230
|
+
# Create a Rio as with RIO#rio which refers to the current working directory
|
|
231
|
+
# wd = RIO.cwd
|
|
232
|
+
# If passed arguments they are treated as if
|
|
233
|
+
# rio(RIO.cwd,*args)
|
|
234
|
+
# had been called
|
|
235
|
+
def cwd(*args,&block) # :yields: self
|
|
236
|
+
Rio.new.getwd(*args,&block)
|
|
237
|
+
end
|
|
238
|
+
module_function :cwd
|
|
239
|
+
|
|
240
|
+
# Create a Rio as with RIO#rio which refers to a directory at the root of the file system
|
|
241
|
+
# tmpdir = RIO.root('tmp') #=> rio('/tmp')
|
|
242
|
+
def root(*args,&block) # :yields: self
|
|
243
|
+
Rio.new.rootpath(*args,&block)
|
|
244
|
+
end
|
|
245
|
+
module_function :root
|
|
246
|
+
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
if $0 == __FILE__
|
|
250
|
+
eval DATA.read, nil, $0, __LINE__+4
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
__END__
|
|
254
|
+
|
|
255
|
+
puts
|
|
256
|
+
puts("Run the tests that came with the distribution")
|
|
257
|
+
puts("From the distribution directory use 'test/runtests.rb'")
|
|
258
|
+
puts
|