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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
require 'tempfile'
|
|
3
|
+
require 'delegate'
|
|
4
|
+
module RIO
|
|
5
|
+
module FTP
|
|
6
|
+
class FTPFile < DelegateClass( ::Tempfile )
|
|
7
|
+
def initialize(remote_path, netftp)
|
|
8
|
+
@remote_path = remote_path
|
|
9
|
+
@netftp = netftp
|
|
10
|
+
@ftpfile = ::Tempfile.new('ftpfile')
|
|
11
|
+
super(@ftpfile)
|
|
12
|
+
end
|
|
13
|
+
def close()
|
|
14
|
+
super
|
|
15
|
+
@netftp.put(path(),@remote_path)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/rio/grande.rb
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
require 'rio/match'
|
|
38
|
+
module RIO
|
|
39
|
+
module Grande #:nodoc: all
|
|
40
|
+
include Match::Common
|
|
41
|
+
def [](*args)
|
|
42
|
+
#p "#{callstr('[]',*args)} ss_type=#{cx['ss_type']} stream_iter=#{stream_iter?}"
|
|
43
|
+
ss_args = cx['ss_args'] = args
|
|
44
|
+
rtn = nil
|
|
45
|
+
if ss_args and (ss_type = ss_type?(_ss_keys()))
|
|
46
|
+
rtn = self.__send__(ss_type,*(ss_args)).to_a
|
|
47
|
+
else
|
|
48
|
+
rtn = to_a()
|
|
49
|
+
end
|
|
50
|
+
_ss_returns_first? ? _ss_return_first(rtn) : rtn
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def _ss_return_first(ary)
|
|
56
|
+
_ss_clear_single_return()
|
|
57
|
+
ary[0]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
SINGLE_RETURN_KEYS = %[line record row]
|
|
61
|
+
|
|
62
|
+
def _ss_clear_single_return
|
|
63
|
+
SINGLE_RETURN_KEYS.each do |key|
|
|
64
|
+
cx.delete(key)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def _ss_returns_first?
|
|
69
|
+
cx['line'] || cx['record'] || cx['row']
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def fixnumss(*args)
|
|
73
|
+
|
|
74
|
+
#p args[0].class,ss_type?(_ss_keys())
|
|
75
|
+
ss_args = cx['ss_args'] = args
|
|
76
|
+
if ss_args.length == 1 and ss_args[0].kind_of?(Fixnum) and !cx.has_key?('dirlines')
|
|
77
|
+
ans = nil
|
|
78
|
+
ss_type = ss_type?(_ss_keys())
|
|
79
|
+
|
|
80
|
+
if ss_args and ss_type
|
|
81
|
+
ans = self.__send__(ss_type,*(ss_args)).to_a
|
|
82
|
+
else
|
|
83
|
+
ans = to_a()
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
return (ans.empty? ? nil : ans[0])
|
|
87
|
+
else
|
|
88
|
+
if ss_args and (ss_type = ss_type?(_ss_keys()))
|
|
89
|
+
return self.__send__(ss_type,*(ss_args)).to_a
|
|
90
|
+
else
|
|
91
|
+
return to_a()
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
end
|
data/lib/rio/handle.rb
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
require 'rio/base'
|
|
38
|
+
|
|
39
|
+
module RIO
|
|
40
|
+
class Handle < Base #:nodoc: all
|
|
41
|
+
attr_accessor :target
|
|
42
|
+
def initialize(st=nil)
|
|
43
|
+
@target = st
|
|
44
|
+
end
|
|
45
|
+
def initialize_copy(*args)
|
|
46
|
+
#p callstr('initialize_copy',*args)
|
|
47
|
+
super
|
|
48
|
+
@target = @target.clone
|
|
49
|
+
end
|
|
50
|
+
def method_missing(sym,*args,&block)
|
|
51
|
+
# p callstr('method_missing',*args)
|
|
52
|
+
@target.__send__(sym,*args,&block)
|
|
53
|
+
end
|
|
54
|
+
def t_instance_of?(*args) @target.instance_of?(*args) end
|
|
55
|
+
def t_kind_of?(*args) @target.kind_of?(*args) end
|
|
56
|
+
def t_class(*args) @target.class(*args) end
|
|
57
|
+
def to_s() @target.to_s() end
|
|
58
|
+
def split(*args,&block) @target.split(*args,&block) end
|
|
59
|
+
def callstr(func,*args)
|
|
60
|
+
self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if $0 == __FILE__
|
|
66
|
+
eval DATA.read, nil, $0, __LINE__+4
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
__END__
|
|
70
|
+
|
|
71
|
+
require 'test/unit'
|
|
72
|
+
|
|
73
|
+
class TC_Handle < Test::Unit::TestCase
|
|
74
|
+
def test_handle
|
|
75
|
+
assert_nothing_raised {
|
|
76
|
+
h = Handle.new()
|
|
77
|
+
}
|
|
78
|
+
h = Handle.new()
|
|
79
|
+
assert_nil(h.v)
|
|
80
|
+
object = String.new("Zippy")
|
|
81
|
+
h = FwdHandle.new(object,$stdout)
|
|
82
|
+
s = "Hello World\n"
|
|
83
|
+
|
|
84
|
+
rtn = h.fwd_rtn(:write,s)
|
|
85
|
+
assert_equal(rtn,s.length)
|
|
86
|
+
|
|
87
|
+
rtn = h.fwd_rtn_obj(:write,s)
|
|
88
|
+
assert_same(rtn,object)
|
|
89
|
+
|
|
90
|
+
rtn = h.fwd_rtn_new(:write,s)
|
|
91
|
+
assert_equal(object.class,rtn.class)
|
|
92
|
+
assert_not_same(object,rtn)
|
|
93
|
+
assert_equal(rtn,s.length.to_s)
|
|
94
|
+
|
|
95
|
+
rtn = h.write(s)
|
|
96
|
+
p rtn
|
|
97
|
+
# assert_equal(sdocdir,docdir.to_s)
|
|
98
|
+
# assert_instance_of(RIO::Rio,doc,"catpath does not return an FS")
|
|
99
|
+
end
|
|
100
|
+
end
|
data/lib/rio/if/basic.rb
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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 Rio
|
|
39
|
+
|
|
40
|
+
#def to_rl() target.to_rl end
|
|
41
|
+
|
|
42
|
+
# Returns the length of the Rio's String representation
|
|
43
|
+
#
|
|
44
|
+
# To get the size of the underlying file system object use RIO::IF::Test#size
|
|
45
|
+
def length() target.length end
|
|
46
|
+
|
|
47
|
+
# Equality - calls to_s on _other_ and compares its return value
|
|
48
|
+
# with the value returned by Rio#to_s
|
|
49
|
+
def ==(other) target == other end
|
|
50
|
+
|
|
51
|
+
# Equality (for case statements) same as Rio#==
|
|
52
|
+
def ===(other) target === other end
|
|
53
|
+
|
|
54
|
+
# Rios are hashed based on their String representation
|
|
55
|
+
def hash() target.hash end
|
|
56
|
+
|
|
57
|
+
# Returns true if their String representations are eql?
|
|
58
|
+
def eql?(other) target.eql?(other) end
|
|
59
|
+
|
|
60
|
+
# Match - invokes _other_.=~, passing the value returned by Rio#to_str
|
|
61
|
+
def =~(other) target =~ other end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
data/lib/rio/if/csv.rb
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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 IF
|
|
39
|
+
module CSV
|
|
40
|
+
#def file() target.file end
|
|
41
|
+
#def dir() target.dir end
|
|
42
|
+
|
|
43
|
+
# Puts a Rio in CSV mode and sets the field and record separators.
|
|
44
|
+
# In csv mode selecting with IF::GrandeStream#records will cause each line
|
|
45
|
+
# read to be parsed into a line with the CSV standard library.
|
|
46
|
+
# Specifying using IF::GrandeStream#lines to select will return unparsed strings
|
|
47
|
+
# as normal.
|
|
48
|
+
#
|
|
49
|
+
# # copy a csv file, changing the field separator
|
|
50
|
+
# rio('afile.csv').csv > rio('afile_semicolons.csv').csv(';')
|
|
51
|
+
#
|
|
52
|
+
# CSV mode also adds two methods #columns and #skipcolumns which
|
|
53
|
+
# allows selecting columns by column index using Fixnums or Ranges
|
|
54
|
+
# in a way similar to how lines are selected.
|
|
55
|
+
#
|
|
56
|
+
# # iterate through every line but only get the first three columns
|
|
57
|
+
# rio("afile.csv").csv.columns(0..2) { |array_of_fields| ... }
|
|
58
|
+
#
|
|
59
|
+
# # iterate through every line but skip the columns 2 and 3 through 5
|
|
60
|
+
# rio("afile.csv").csv.skipcolumns(2,3..5) { |array_of_fields| ... }
|
|
61
|
+
#
|
|
62
|
+
# # an array containg all but the first line returning columns 5,6 and 7
|
|
63
|
+
# rio("afile.csv").csv.columns(5..7).skiplines[0]
|
|
64
|
+
#
|
|
65
|
+
# See RIO::Doc::INTRO for complete documentation on csv mode.
|
|
66
|
+
def csv(field_separator=',',record_separator=nil,&block)
|
|
67
|
+
target.csv(field_separator,record_separator,&block);
|
|
68
|
+
self
|
|
69
|
+
end
|
|
70
|
+
# Select columns from a CSV file. See #csv and RIO::Doc::INTRO.
|
|
71
|
+
def columns(*ranges,&block) target.columns(*ranges,&block); self end
|
|
72
|
+
# Reject columns from a CSV file. See #csv and RIO::Doc::INTRO.
|
|
73
|
+
def skipcolumns(*ranges,&block) target.skipcolumns(*ranges,&block); self end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
data/lib/rio/if/dir.rb
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
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 IF
|
|
39
|
+
module Dir
|
|
40
|
+
# Calls ::Dir#chdir.
|
|
41
|
+
#
|
|
42
|
+
# Changes the current working directory of the process to the directory specified by the Rio.
|
|
43
|
+
# Raises a SystemCallError (probably Errno::ENOENT) if the target directory does not exist or
|
|
44
|
+
# if the Rio does not reference a directory.
|
|
45
|
+
#
|
|
46
|
+
# If a block is given changes to the directory specified by the rio for the length of the block
|
|
47
|
+
# and changes back outside the block
|
|
48
|
+
#
|
|
49
|
+
# Returns the Rio
|
|
50
|
+
#
|
|
51
|
+
# rio('/home').chdir # change the current working directory to /home
|
|
52
|
+
# # the working directory here is /home
|
|
53
|
+
# rio('/tmp/data/mydata').delete!.mkpath.chdir {
|
|
54
|
+
# # the working directory here is /tmp/data/mydata
|
|
55
|
+
# }
|
|
56
|
+
# # the working directory here is /home
|
|
57
|
+
#
|
|
58
|
+
def chdir(&block) target.chdir(&block);self end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Calls Find#find
|
|
63
|
+
#
|
|
64
|
+
# Uses ::Find#find to find all entries recursively for a Rio that
|
|
65
|
+
# specifies a directory. Note that there are other ways to recurse through
|
|
66
|
+
# a directory structure using a Rio. See IF::Grande#each and IF::GrandeEntry#all.
|
|
67
|
+
#
|
|
68
|
+
# Calls the block passing a Rio for each entry found. The Rio inherits
|
|
69
|
+
# file attrubutes from the directory Rio.
|
|
70
|
+
#
|
|
71
|
+
# Returns itself
|
|
72
|
+
#
|
|
73
|
+
# rio('adir').find { |entrio| puts "#{entrio}: #{entrio.file?}" }
|
|
74
|
+
#
|
|
75
|
+
# rio('adir').chomp.find do |entrio|
|
|
76
|
+
# next unless entrio.file?
|
|
77
|
+
# lines = entrio[0..10] # lines are chomped because 'chomp' was inherited
|
|
78
|
+
# end
|
|
79
|
+
#
|
|
80
|
+
def find(*args,&block) target.find_entries(*args,&block); self end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Calls ::Dir#glob
|
|
84
|
+
#
|
|
85
|
+
# Returns the filenames found by expanding the pattern given in string,
|
|
86
|
+
# either as an array or as parameters to the block. In both cases the filenames
|
|
87
|
+
# are expressed as a Rio.
|
|
88
|
+
# Note that this pattern is not a regexp (it�s closer to a shell glob).
|
|
89
|
+
# See File::fnmatch for details of file name matching and the meaning of the flags parameter.
|
|
90
|
+
#
|
|
91
|
+
#
|
|
92
|
+
def glob(string,*args,&block) target.glob(string,*args,&block) end
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# Calls ::Dir#rmdir
|
|
96
|
+
#
|
|
97
|
+
# Deletes the directory referenced by the Rio.
|
|
98
|
+
# Raises a subclass of SystemCallError if the directory isn�t empty.
|
|
99
|
+
# Returns the Rio. If the directory does not exist, just returns the Rio.
|
|
100
|
+
#
|
|
101
|
+
# See also #rmtree, IF::Grande#delete, IF::Grande#delete!
|
|
102
|
+
#
|
|
103
|
+
# rio('adir').rmdir # remove the empty directory 'adir'
|
|
104
|
+
#
|
|
105
|
+
def rmdir() target.rmdir(); self end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# Calls FileUtils#rmtree
|
|
109
|
+
#
|
|
110
|
+
# Removes a directory Rio recursively. Returns the Rio.
|
|
111
|
+
# If the directory does not exist, simply returns the Rio
|
|
112
|
+
#
|
|
113
|
+
# If called with a block, behaves as if <tt>rmtree.each(&block)</tt> had been called
|
|
114
|
+
#
|
|
115
|
+
# See also IF::Grande#delete!
|
|
116
|
+
#
|
|
117
|
+
# rio('adir').rmtree # removes the directory 'adir' recursively
|
|
118
|
+
#
|
|
119
|
+
# # delete the directory 'adir', recreate it and then change to the new directory
|
|
120
|
+
# rio('adir/asubdir').rmtree.mkpath.chdir {
|
|
121
|
+
# ...
|
|
122
|
+
# }
|
|
123
|
+
#
|
|
124
|
+
#
|
|
125
|
+
def rmtree() target.rmtree(); self end
|
|
126
|
+
|
|
127
|
+
# Calls FileUtils#mkpath
|
|
128
|
+
#
|
|
129
|
+
# Makes a new directory named by the Rio and any directories in its path that do not exist.
|
|
130
|
+
#
|
|
131
|
+
# Returns the Rio. If the directory already exists, just returns the Rio.
|
|
132
|
+
#
|
|
133
|
+
# rio('adir/a/b').mkpath
|
|
134
|
+
def mkpath(&block) target.mkpath(&block); self end
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# Calls FileUtils#mkdir
|
|
138
|
+
#
|
|
139
|
+
# Makes a new directory named by the Rio with permissions specified by the optional parameter.
|
|
140
|
+
# The permissions may be modified by the value of File::umask
|
|
141
|
+
#
|
|
142
|
+
# Returns the Rio. If the directory already exists, just returns the Rio.
|
|
143
|
+
#
|
|
144
|
+
# rio('adir').mkdir
|
|
145
|
+
def mkdir(*args,&block) target.mkdir(*args,&block); self end
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
module RIO
|
|
154
|
+
class Rio
|
|
155
|
+
include RIO::IF::Dir
|
|
156
|
+
end
|
|
157
|
+
end
|