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,66 @@
|
|
|
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/context/cxx.rb'
|
|
38
|
+
|
|
39
|
+
module RIO
|
|
40
|
+
module Cx
|
|
41
|
+
module Methods
|
|
42
|
+
def _arg_skip(args)
|
|
43
|
+
#p callstr('_arg_skip',args,cx.inspect)
|
|
44
|
+
cx['ss_skipped'] = cx['ss_type'].sub(/^skip/,'') if cx['ss_type']
|
|
45
|
+
cx['ss_type'] = 'skip'
|
|
46
|
+
cx['skip_args'] = args
|
|
47
|
+
end
|
|
48
|
+
def _noarg_skip
|
|
49
|
+
cx['ss_skipped'] = cx['ss_type'].sub(/^skip/,'') if cx['ss_type']
|
|
50
|
+
cx['ss_type'] = 'skip'
|
|
51
|
+
cx['skipping'] = true
|
|
52
|
+
end
|
|
53
|
+
def skipping?() cx['skipping'] end
|
|
54
|
+
def skip(*args,&block)
|
|
55
|
+
if args.empty?
|
|
56
|
+
_noarg_skip
|
|
57
|
+
else
|
|
58
|
+
_arg_skip(args)
|
|
59
|
+
end
|
|
60
|
+
each(&block) if block_given?
|
|
61
|
+
self
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,229 @@
|
|
|
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/context/cxx.rb'
|
|
38
|
+
require 'rio/iomode'
|
|
39
|
+
|
|
40
|
+
module RIO
|
|
41
|
+
module Cx
|
|
42
|
+
module Methods
|
|
43
|
+
def stream_iter?() cx.has_key?('stream_itertype') && !cx['nostreamenum'] end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def _set_bytes(nb)
|
|
48
|
+
nb = 1 if nb.nil? or nb < 1
|
|
49
|
+
cx['bytes_n'] = nb
|
|
50
|
+
end
|
|
51
|
+
def _set_bytes_(nb)
|
|
52
|
+
nb = 1 if nb.nil? or nb < 1
|
|
53
|
+
cx.set_('bytes_n',nb)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def _set_sstype(ss,explicit=true)
|
|
57
|
+
case
|
|
58
|
+
when explicit then cx['ss_type'] = ss
|
|
59
|
+
else cx.set_('ss_type',ss)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
def _set_rectype(rt,explicit=true)
|
|
63
|
+
case
|
|
64
|
+
when explicit then cx['stream_rectype'] = rt
|
|
65
|
+
else cx.set_('stream_rectype',rt)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
def _set_itertype(rt,explicit=true)
|
|
69
|
+
case
|
|
70
|
+
when explicit then cx['stream_itertype'] = rt
|
|
71
|
+
else cx.set_('stream_itertype',rt)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def _set_selargs(sa,sel=true,&block)
|
|
76
|
+
key = (sel ? 'stream_sel' : 'stream_nosel')
|
|
77
|
+
cx[key] = sa
|
|
78
|
+
each(&block) if block_given?
|
|
79
|
+
self
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def _lines(args,sel=true,explicit=true,&block)
|
|
83
|
+
#p callstr('lines',*args)
|
|
84
|
+
_set_itertype('lines',explicit)
|
|
85
|
+
_set_rectype('lines',explicit)
|
|
86
|
+
_set_selargs(args,sel,&block)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def _records(args,sel=true,explicit=true,&block)
|
|
90
|
+
_set_itertype('records',explicit)
|
|
91
|
+
_set_selargs(args,sel,&block)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def _rows(args,sel=true,explicit=true,&block)
|
|
95
|
+
_set_itertype('rows',explicit)
|
|
96
|
+
_set_selargs(args,sel,&block)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def _sel()
|
|
100
|
+
!skipping?
|
|
101
|
+
end
|
|
102
|
+
def _sel_key(key)
|
|
103
|
+
(skipping? ? 'skip'+key : key)
|
|
104
|
+
end
|
|
105
|
+
public
|
|
106
|
+
|
|
107
|
+
def lines(*args,&block)
|
|
108
|
+
#p callstr('lines',*args)
|
|
109
|
+
if skipping?
|
|
110
|
+
cx['skipping'] = false
|
|
111
|
+
skiplines(*args,&block)
|
|
112
|
+
else
|
|
113
|
+
_set_sstype('lines')
|
|
114
|
+
_lines(args,_sel,&block)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
def lines_(*args,&block)
|
|
118
|
+
#p callstr('lines_',*args)
|
|
119
|
+
_set_sstype('lines',false)
|
|
120
|
+
_lines(args,_sel,false,&block)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def line(*args,&block)
|
|
124
|
+
#p callstr('line',*args)
|
|
125
|
+
cx['line'] = true
|
|
126
|
+
self.lines(*args,&block)
|
|
127
|
+
end
|
|
128
|
+
def line_(*args,&block)
|
|
129
|
+
#p callstr('line_',*args)
|
|
130
|
+
cx.set_('line',true)
|
|
131
|
+
self.lines_(*args,&block)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def records(*args,&block)
|
|
135
|
+
if skipping?
|
|
136
|
+
cx['skipping'] = false
|
|
137
|
+
skiprecords(*args,&block)
|
|
138
|
+
else
|
|
139
|
+
_set_sstype('records')
|
|
140
|
+
_records(args,_sel,&block)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
def records_(*args,&block)
|
|
144
|
+
_set_sstype('records',false)
|
|
145
|
+
_records(args,_sel,false,&block)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def record(*args,&block)
|
|
149
|
+
#p callstr('record',*args)
|
|
150
|
+
cx['record'] = true
|
|
151
|
+
self.records(*args,&block)
|
|
152
|
+
end
|
|
153
|
+
def record_(*args,&block)
|
|
154
|
+
#p callstr('record_',*args)
|
|
155
|
+
cx.set_('record',true)
|
|
156
|
+
self.records_(*args,&block)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def rows(*args,&block)
|
|
160
|
+
if skipping?
|
|
161
|
+
cx['skipping'] = false
|
|
162
|
+
skiprows(*args,&block)
|
|
163
|
+
else
|
|
164
|
+
_set_sstype('rows')
|
|
165
|
+
_rows(args,_sel,&block)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
def rows_(*args,&block)
|
|
169
|
+
_set_sstype('rows',false)
|
|
170
|
+
_rows(args,_sel,false,&block)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def row(*args,&block)
|
|
174
|
+
#p callstr('row',*args)
|
|
175
|
+
cx['row'] = true
|
|
176
|
+
self.rows(*args,&block)
|
|
177
|
+
end
|
|
178
|
+
def row_(*args,&block)
|
|
179
|
+
#p callstr('row_',*args)
|
|
180
|
+
cx.set_('row',true)
|
|
181
|
+
self.rows_(*args,&block)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def skiplines(*args,&block)
|
|
186
|
+
#p callstr('skiplines',*args)
|
|
187
|
+
self.lines() unless args.empty? or cx.has_key?('stream_sel')
|
|
188
|
+
_set_sstype('skiplines')
|
|
189
|
+
_lines(args,false,&block)
|
|
190
|
+
end
|
|
191
|
+
def skiprecords(*args,&block)
|
|
192
|
+
self.records_() unless args.empty? or cx.has_key?('stream_sel')
|
|
193
|
+
_set_sstype('skiprecords')
|
|
194
|
+
_records(args,false,&block)
|
|
195
|
+
end
|
|
196
|
+
def skiprecords_(*args,&block)
|
|
197
|
+
self.records_() unless args.empty? or cx.has_key?('stream_sel')
|
|
198
|
+
_set_sstype('skiprecords',false)
|
|
199
|
+
_records(args,false,false,&block)
|
|
200
|
+
end
|
|
201
|
+
def skiprows(*args,&block)
|
|
202
|
+
self.rows() unless args.empty? or cx.has_key?('stream_sel')
|
|
203
|
+
_set_sstype('skiprows')
|
|
204
|
+
_rows(args,false,&block)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def bytes(nb=1,*args,&block)
|
|
210
|
+
_set_sstype('bytes')
|
|
211
|
+
_set_bytes(nb)
|
|
212
|
+
_set_itertype('records')
|
|
213
|
+
_set_rectype('bytes')
|
|
214
|
+
each(&block) if block_given?
|
|
215
|
+
self
|
|
216
|
+
end
|
|
217
|
+
def bytes_(nb=1,*args,&block)
|
|
218
|
+
_set_bytes_(nb)
|
|
219
|
+
_set_itertype('records',false)
|
|
220
|
+
_set_rectype('bytes',false)
|
|
221
|
+
each(&block) if block_given?
|
|
222
|
+
self
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
data/lib/rio/context.rb
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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 Cx #:nodoc: all
|
|
39
|
+
class Vars
|
|
40
|
+
def initialize(h=Hash.new,exp=Hash.new)
|
|
41
|
+
@values = h
|
|
42
|
+
@explicit = exp
|
|
43
|
+
end
|
|
44
|
+
def initialize_copy(*args)
|
|
45
|
+
super
|
|
46
|
+
@values = @values.clone
|
|
47
|
+
@explicit = @explicit.clone
|
|
48
|
+
end
|
|
49
|
+
BEQUEATH_KEYS = %w[chomp strip rename closeoneof closeoncopy]
|
|
50
|
+
#BEQUEATH_KEYS = %w[chomp strip rename]
|
|
51
|
+
def bequeath(oldcx)
|
|
52
|
+
keys = BEQUEATH_KEYS
|
|
53
|
+
ncx = oldcx.clone
|
|
54
|
+
#ncx = Vars.new
|
|
55
|
+
keys.each { |key|
|
|
56
|
+
ncx.set_(key,@values[key]) if @values.has_key?(key)
|
|
57
|
+
}
|
|
58
|
+
ncx
|
|
59
|
+
end
|
|
60
|
+
def delete(key)
|
|
61
|
+
@values.delete(key)
|
|
62
|
+
@explicit.delete(key)
|
|
63
|
+
end
|
|
64
|
+
def get_keystate(key)
|
|
65
|
+
key_exists = @values.key?(key)
|
|
66
|
+
key_val = @values[key]
|
|
67
|
+
key_explicit = @explicit[key]
|
|
68
|
+
[key,key_exists,key_val,key_explicit]
|
|
69
|
+
end
|
|
70
|
+
def set_keystate(key,key_exists,key_val,key_explicit)
|
|
71
|
+
if(key_exists) then
|
|
72
|
+
@values[key] = key_val
|
|
73
|
+
@explicit[key] = key_explicit
|
|
74
|
+
else
|
|
75
|
+
@values.delete(key)
|
|
76
|
+
@explicit.delete(key)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
def set_(key,val)
|
|
80
|
+
@values[key] = val unless @explicit[key]
|
|
81
|
+
end
|
|
82
|
+
def []=(key,val)
|
|
83
|
+
@values[key] = val
|
|
84
|
+
@explicit[key] = true
|
|
85
|
+
end
|
|
86
|
+
def inspect()
|
|
87
|
+
str = sprintf('#<Cx:0x%08x ',self.object_id)
|
|
88
|
+
vary = {}
|
|
89
|
+
@values.each { |k,v|
|
|
90
|
+
name = k
|
|
91
|
+
name += '_' unless @explicit[k]
|
|
92
|
+
if v == true
|
|
93
|
+
vary[name] = nil
|
|
94
|
+
elsif v == false
|
|
95
|
+
vary[name] = 'false'
|
|
96
|
+
else
|
|
97
|
+
vary[name] = v
|
|
98
|
+
end
|
|
99
|
+
}
|
|
100
|
+
strs = []
|
|
101
|
+
vary.each { |k,v|
|
|
102
|
+
if v.nil?
|
|
103
|
+
strs << k
|
|
104
|
+
else
|
|
105
|
+
strs << "#{k}(#{v.inspect})"
|
|
106
|
+
end
|
|
107
|
+
}
|
|
108
|
+
str += strs.join(',')
|
|
109
|
+
str +='>'
|
|
110
|
+
str
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
extend Forwardable
|
|
114
|
+
def_instance_delegators(:@values,:[],:has_key?,:values_at,:keys)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
data/lib/rio/cp.rb
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
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/exception/copy'
|
|
38
|
+
class String #:nodoc: all
|
|
39
|
+
def clear()
|
|
40
|
+
self[0..-1] = ''
|
|
41
|
+
self
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
require 'rio/no_warn'
|
|
45
|
+
|
|
46
|
+
module RIO
|
|
47
|
+
module Cp #:nodoc: all
|
|
48
|
+
module Util
|
|
49
|
+
module InOut
|
|
50
|
+
def cpclose(*args,&block)
|
|
51
|
+
if args.empty?
|
|
52
|
+
oldcoc = self.cx.get_keystate('closeoncopy')
|
|
53
|
+
self.cx['closeoncopy'] = false
|
|
54
|
+
rtn = yield
|
|
55
|
+
rtn.cx.set_keystate(*oldcoc)
|
|
56
|
+
rtn.copyclose
|
|
57
|
+
else
|
|
58
|
+
if (ario = args[0]).kind_of?(Rio)
|
|
59
|
+
oldcoc = ario.cx.get_keystate('closeoncopy')
|
|
60
|
+
ario.cx['closeoncopy'] = false
|
|
61
|
+
rtn = yield
|
|
62
|
+
ario.cx.set_keystate(*oldcoc)
|
|
63
|
+
ario.copyclose
|
|
64
|
+
rtn
|
|
65
|
+
else
|
|
66
|
+
yield
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
def cpclose0(*args,&block)
|
|
71
|
+
if args.empty?
|
|
72
|
+
oldcoc,self.cx['closeoncopy'] = self.cx['closeoncopy'],false
|
|
73
|
+
rtn = yield
|
|
74
|
+
rtn.cx['closeoncopy'] = oldcoc
|
|
75
|
+
rtn.copyclose
|
|
76
|
+
else
|
|
77
|
+
if (ario = args[0]).kind_of?(Rio)
|
|
78
|
+
oldcoc,ario.cx['closeoncopy'] = ario.cx['closeoncopy'],false
|
|
79
|
+
rtn = yield
|
|
80
|
+
ario.cx['closeoncopy'] = oldcoc
|
|
81
|
+
ario.copyclose
|
|
82
|
+
rtn
|
|
83
|
+
else
|
|
84
|
+
yield
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
module Input
|
|
90
|
+
include InOut
|
|
91
|
+
protected
|
|
92
|
+
|
|
93
|
+
def cpto_obj_(obj)
|
|
94
|
+
self.each do |el|
|
|
95
|
+
obj << el
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
module Output
|
|
101
|
+
include InOut
|
|
102
|
+
|
|
103
|
+
protected
|
|
104
|
+
|
|
105
|
+
def cpfrom_obj_(obj)
|
|
106
|
+
obj.each do |el|
|
|
107
|
+
self << el
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
def cpfrom_array_(ary)
|
|
111
|
+
#p "CPFROM_ARRAY_"
|
|
112
|
+
ary.inject(self) { |anio,el| anio << el }
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
module RIO
|
|
120
|
+
module Cp
|
|
121
|
+
module Stream
|
|
122
|
+
module Input
|
|
123
|
+
include Util::Input
|
|
124
|
+
def >>(arg)
|
|
125
|
+
cpclose(arg) {
|
|
126
|
+
apto_(arg)
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
def >(arg)
|
|
130
|
+
cpclose(arg) {
|
|
131
|
+
cpto_(arg)
|
|
132
|
+
}
|
|
133
|
+
end
|
|
134
|
+
alias :copy_to :>
|
|
135
|
+
alias :append_to :>>
|
|
136
|
+
|
|
137
|
+
protected
|
|
138
|
+
def cpto_(arg)
|
|
139
|
+
case arg
|
|
140
|
+
when ::Array then cpto_array_(arg.clear)
|
|
141
|
+
when ::String then cpto_string_(arg.clear)
|
|
142
|
+
when ::IO then cpto_obj_(arg)
|
|
143
|
+
else cpto_rio_(arg,:<)
|
|
144
|
+
end
|
|
145
|
+
self
|
|
146
|
+
end
|
|
147
|
+
def apto_(arg)
|
|
148
|
+
case arg
|
|
149
|
+
when ::Array then cpto_array_(arg)
|
|
150
|
+
when ::String then cpto_string_(arg)
|
|
151
|
+
when ::IO then cpto_obj_(arg)
|
|
152
|
+
else cpto_rio_(arg,:<<)
|
|
153
|
+
end
|
|
154
|
+
self
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def cpto_array_(arg)
|
|
158
|
+
cpto_obj_(arg)
|
|
159
|
+
end
|
|
160
|
+
def cpto_string_(arg)
|
|
161
|
+
cpto_obj_(arg)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def cpto_rio_(arg,sym)
|
|
165
|
+
ario = ensure_rio(arg)
|
|
166
|
+
#p ario
|
|
167
|
+
ario = ario.join(self.filename) if ario.dir?
|
|
168
|
+
ario.cpclose {
|
|
169
|
+
ario = ario.iostate(sym)
|
|
170
|
+
self.copying(ario).each { |el|
|
|
171
|
+
# p el
|
|
172
|
+
ario.putrec(el)
|
|
173
|
+
# ario << el
|
|
174
|
+
}.copying_done(ario)
|
|
175
|
+
ario
|
|
176
|
+
}
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
module Output
|
|
181
|
+
include Util::Output
|
|
182
|
+
def <<(arg) cpclose { cpfrom_(arg) } end
|
|
183
|
+
def <(arg) cpclose { cpfrom_(arg) } end
|
|
184
|
+
alias :copy_from :<
|
|
185
|
+
alias :append_from :<<
|
|
186
|
+
|
|
187
|
+
protected
|
|
188
|
+
|
|
189
|
+
def cpfrom_(arg)
|
|
190
|
+
case arg
|
|
191
|
+
when ::Array then cpfrom_array_(arg)
|
|
192
|
+
when ::IO then cpfrom_obj_(arg)
|
|
193
|
+
when ::String then
|
|
194
|
+
self.put_(arg)
|
|
195
|
+
else cpfrom_rio_(arg)
|
|
196
|
+
end
|
|
197
|
+
self
|
|
198
|
+
end
|
|
199
|
+
def cpfrom_rio_(arg)
|
|
200
|
+
ario = ensure_rio(arg)
|
|
201
|
+
#p ario.cx
|
|
202
|
+
|
|
203
|
+
ario.copying(self).each { |el|
|
|
204
|
+
self << el
|
|
205
|
+
}.copying_done(self)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
module RIO
|
|
212
|
+
module Cp
|
|
213
|
+
module File
|
|
214
|
+
module Output
|
|
215
|
+
include Util::Output
|
|
216
|
+
def <(arg) cpclose { self.iostate(:<) < arg } end
|
|
217
|
+
def <<(arg) cpclose { self.iostate(:<<) << arg } end
|
|
218
|
+
alias :copy_from :<
|
|
219
|
+
alias :append_from :<<
|
|
220
|
+
end
|
|
221
|
+
module Input
|
|
222
|
+
include Util::Input
|
|
223
|
+
def >(arg)
|
|
224
|
+
spcp(arg) || cpclose(arg) { self.iostate(:>) > arg }
|
|
225
|
+
end
|
|
226
|
+
def >>(arg)
|
|
227
|
+
spcp(arg) || cpclose(arg) { self.iostate(:>>) >> arg }
|
|
228
|
+
end
|
|
229
|
+
alias :copy_to :>
|
|
230
|
+
alias :append_to :>>
|
|
231
|
+
def copy_as_file?(arg)
|
|
232
|
+
arg.kind_of?(Rio) and arg.scheme == 'ftp'
|
|
233
|
+
end
|
|
234
|
+
def spcp(arg)
|
|
235
|
+
if arg.kind_of?(Rio) and arg.scheme == 'ftp'
|
|
236
|
+
arg.copy_from(new_rio(rl.path))
|
|
237
|
+
self
|
|
238
|
+
else
|
|
239
|
+
nil
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
module RIO
|
|
247
|
+
module Cp
|
|
248
|
+
module Open
|
|
249
|
+
module Output
|
|
250
|
+
include Util::Output
|
|
251
|
+
def <(arg) cpclose { self.iostate(:<) < arg } end
|
|
252
|
+
def <<(arg) cpclose { self.iostate(:<<) << arg } end
|
|
253
|
+
alias :copy_from :<
|
|
254
|
+
alias :append_from :<<
|
|
255
|
+
end
|
|
256
|
+
module Input
|
|
257
|
+
include Util::Input
|
|
258
|
+
def >(arg) cpclose(arg) { self.iostate(:>) > arg } end
|
|
259
|
+
def >>(arg) cpclose(arg) { self.iostate(:>>) >> arg } end
|
|
260
|
+
alias :copy_to :>
|
|
261
|
+
alias :append_to :>>
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
module RIO
|
|
267
|
+
module Cp
|
|
268
|
+
module Dir
|
|
269
|
+
module Output
|
|
270
|
+
include Util::Output
|
|
271
|
+
def <<(arg) cpfrom_(arg); self end
|
|
272
|
+
def <(arg) cpfrom_(arg); self end
|
|
273
|
+
alias :copy_from :<
|
|
274
|
+
alias :append_from :<<
|
|
275
|
+
|
|
276
|
+
private
|
|
277
|
+
|
|
278
|
+
def cpfrom_(arg)
|
|
279
|
+
case arg
|
|
280
|
+
when ::Array then cpfrom_array_(arg)
|
|
281
|
+
else cpfrom_rio_(ensure_rio(arg))
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
def cpfrom_rio_(ario)
|
|
285
|
+
dest = self.join(ario.filename)
|
|
286
|
+
case
|
|
287
|
+
when ario.symlink?
|
|
288
|
+
::File.symlink(ario.readlink.to_s,dest.to_s)
|
|
289
|
+
when ario.dir?
|
|
290
|
+
dest.mkdir
|
|
291
|
+
ario.nostreamenum.each do |el|
|
|
292
|
+
dest < el
|
|
293
|
+
end
|
|
294
|
+
else
|
|
295
|
+
dest < ario
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
module Input
|
|
300
|
+
include Util::Input
|
|
301
|
+
def >>(arg)
|
|
302
|
+
case arg
|
|
303
|
+
when ::Array then cpto_obj_(arg)
|
|
304
|
+
else cpto_rio_(ensure_rio(arg))
|
|
305
|
+
end
|
|
306
|
+
self
|
|
307
|
+
end
|
|
308
|
+
def >(arg)
|
|
309
|
+
case arg
|
|
310
|
+
when ::Array then cpto_obj_(arg.clear)
|
|
311
|
+
else cpto_rio_(ensure_rio(arg))
|
|
312
|
+
end
|
|
313
|
+
self
|
|
314
|
+
end
|
|
315
|
+
alias :copy_to :>
|
|
316
|
+
alias :append_to :>>
|
|
317
|
+
|
|
318
|
+
protected
|
|
319
|
+
|
|
320
|
+
def cpto_rio_(ario)
|
|
321
|
+
ario = ario.join(self.filename) if ario.exist?
|
|
322
|
+
nostreamenum.cpto_obj_(ario.mkdir)
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
module RIO
|
|
329
|
+
module Cp
|
|
330
|
+
module NonExisting
|
|
331
|
+
module Output
|
|
332
|
+
include Util::Output
|
|
333
|
+
def <(arg)
|
|
334
|
+
if _switch_direction?(arg)
|
|
335
|
+
#arg > self
|
|
336
|
+
arg.copy_to(self)
|
|
337
|
+
self
|
|
338
|
+
else
|
|
339
|
+
_cpsrc(arg) < arg
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
def <<(arg)
|
|
343
|
+
if _switch_direction?(arg)
|
|
344
|
+
arg >> self
|
|
345
|
+
self
|
|
346
|
+
else
|
|
347
|
+
_cpsrc(arg) << arg
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
alias :copy_from :<
|
|
351
|
+
alias :append_from :<<
|
|
352
|
+
|
|
353
|
+
private
|
|
354
|
+
|
|
355
|
+
def _cpsrc(arg)
|
|
356
|
+
if arg.kind_of?(::Array) and !arg.empty? and arg[0].kind_of?(Rio)
|
|
357
|
+
self.mkdir.reset
|
|
358
|
+
else
|
|
359
|
+
self.nfile
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
def _switch_direction?(arg)
|
|
363
|
+
arg.kind_of?(Rio) and arg.dir? and !arg.stream_iter?
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
__END__
|