rio 0.3.7 → 0.3.8
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/ChangeLog +1273 -1482
- data/README +2 -2
- data/Rakefile +5 -5
- data/VERSION +1 -1
- data/{RUNME.1st.rb → build_doc.rb} +4 -10
- data/doc/ANNOUNCE +33 -80
- data/doc/RELEASE_NOTES +31 -1
- data/doc/generators/template/html/rio.rb +3 -3
- data/lib/rio/abstract_method.rb +2 -2
- data/lib/rio/argv.rb +2 -2
- data/lib/rio/arycopy.rb +2 -2
- data/lib/rio/assert.rb +2 -2
- data/lib/rio/base.rb +2 -2
- data/lib/rio/callstr.rb +47 -0
- data/lib/rio/const.rb +52 -0
- data/lib/rio/construct.rb +6 -24
- data/lib/rio/constructor.rb +12 -2
- data/lib/rio/context/autoclose.rb +73 -0
- data/lib/rio/context/copying.rb +2 -2
- data/lib/rio/context/cxx.rb +2 -2
- data/lib/rio/context/dir.rb +2 -2
- data/lib/rio/context/gzip.rb +2 -2
- data/lib/rio/context/methods.rb +6 -34
- data/lib/rio/context/skip.rb +2 -2
- data/lib/rio/context/stream.rb +2 -2
- data/lib/rio/context.rb +17 -2
- data/lib/rio/cp.rb +35 -9
- data/lib/rio/def.rb +54 -0
- data/lib/rio/dir.rb +19 -20
- data/lib/rio/doc/HOWTO.rb +23 -7
- data/lib/rio/doc/INTRO.rb +57 -23
- data/lib/rio/doc/MISC.rb +2 -2
- data/lib/rio/doc/OPTIONAL.rb +134 -0
- data/lib/rio/doc/SYNOPSIS.rb +11 -4
- data/lib/rio/doc.rb +2 -2
- data/lib/rio/entrysel.rb +25 -6
- data/lib/rio/exception/copy.rb +2 -2
- data/lib/rio/exception/notsupported.rb +47 -0
- data/lib/rio/exception/open.rb +2 -2
- data/lib/rio/exception/state.rb +2 -2
- data/lib/rio/exception.rb +2 -2
- data/lib/rio/ext/csv.rb +56 -11
- data/lib/rio/ext/yaml.rb +2 -2
- data/lib/rio/ext/zipfile.rb +91 -0
- data/lib/rio/ext.rb +38 -3
- data/lib/rio/factory.rb +17 -34
- data/lib/rio/file.rb +48 -8
- data/lib/rio/filter/closeoneof.rb +36 -16
- data/lib/rio/filter/gzip.rb +2 -2
- data/lib/rio/filter.rb +2 -2
- data/lib/rio/fs/base.rb +42 -0
- data/lib/rio/fs/impl.rb +123 -0
- data/lib/rio/fs/native.rb +76 -0
- data/lib/rio/{record.rb → fs/stream.rb} +21 -18
- data/lib/rio/fs/url.rb +64 -0
- data/lib/rio/ftp/{ioh.rb → conncache.rb} +38 -39
- data/lib/rio/ftp/dir.rb +95 -0
- data/lib/rio/ftp/fs.rb +173 -0
- data/lib/rio/ftp/ftpfile.rb +20 -0
- data/lib/rio/grande.rb +2 -2
- data/lib/rio/handle.rb +2 -2
- data/lib/rio/if/basic.rb +2 -2
- data/lib/rio/if/csv.rb +2 -2
- data/lib/rio/if/dir.rb +2 -2
- data/lib/rio/if/file.rb +26 -2
- data/lib/rio/if/fileordir.rb +44 -49
- data/lib/rio/if/grande.rb +32 -10
- data/lib/rio/if/grande_entry.rb +12 -2
- data/lib/rio/if/grande_stream.rb +17 -28
- data/lib/rio/if/internal.rb +2 -2
- data/lib/rio/if/path.rb +7 -6
- data/lib/rio/if/stream.rb +85 -29
- data/lib/rio/if/string.rb +2 -2
- data/lib/rio/if/temp.rb +2 -2
- data/lib/rio/if/test.rb +37 -4
- data/lib/rio/if/yaml.rb +2 -2
- data/lib/rio/if.rb +2 -2
- data/lib/rio/impl/path.rb +2 -2
- data/lib/rio/ioh.rb +17 -6
- data/lib/rio/iomode.rb +4 -3
- data/lib/rio/ios/fail.rb +107 -0
- data/lib/rio/ios/generic.rb +120 -0
- data/lib/rio/ios/mode.rb +61 -0
- data/lib/rio/ios/null.rb +120 -0
- data/lib/rio/iowrap.rb +129 -0
- data/lib/rio/kernel.rb +12 -3
- data/lib/rio/local.rb +2 -2
- data/lib/rio/match.rb +3 -3
- data/lib/rio/matchrecord.rb +2 -2
- data/lib/rio/no_warn.rb +50 -0
- data/lib/rio/{arrayio.rb → nullio.rb} +47 -86
- data/lib/rio/open3.rb +2 -2
- data/lib/rio/ops/construct.rb +20 -13
- data/lib/rio/ops/create.rb +10 -19
- data/lib/rio/ops/dir.rb +60 -54
- data/lib/rio/ops/either.rb +11 -9
- data/lib/rio/ops/file.rb +28 -24
- data/lib/rio/ops/path.rb +45 -43
- data/lib/rio/ops/stream/input.rb +12 -8
- data/lib/rio/ops/stream/output.rb +2 -2
- data/lib/rio/ops/stream/read.rb +35 -32
- data/lib/rio/ops/stream/write.rb +5 -5
- data/lib/rio/ops/stream.rb +7 -3
- data/lib/rio/ops/symlink.rb +12 -10
- data/lib/rio/path/reset.rb +5 -5
- data/lib/rio/path.rb +32 -24
- data/lib/rio/piper/cp.rb +2 -2
- data/lib/rio/piper.rb +2 -2
- data/lib/rio/prompt.rb +2 -2
- data/lib/rio/rectype.rb +9 -7
- data/lib/rio/rl/base.rb +5 -4
- data/lib/rio/rl/builder.rb +17 -5
- data/lib/rio/rl/ioi.rb +14 -4
- data/lib/rio/rl/path.rb +23 -15
- data/lib/rio/rl/pathmethods.rb +12 -2
- data/lib/rio/rl/uri.rb +13 -6
- data/lib/rio/scheme/aryio.rb +3 -3
- data/lib/rio/scheme/cmdio.rb +4 -3
- data/lib/rio/scheme/cmdpipe.rb +3 -35
- data/lib/rio/scheme/fd.rb +4 -3
- data/lib/rio/scheme/ftp.rb +36 -7
- data/lib/rio/scheme/http.rb +2 -2
- data/lib/rio/{context/closeoneof.rb → scheme/null.rb} +17 -11
- data/lib/rio/scheme/path.rb +28 -30
- data/lib/rio/scheme/stderr.rb +4 -4
- data/lib/rio/scheme/stdio.rb +6 -5
- data/lib/rio/scheme/strio.rb +10 -20
- data/lib/rio/scheme/sysio.rb +5 -2
- data/lib/rio/scheme/tcp.rb +4 -3
- data/lib/rio/scheme/temp.rb +14 -1
- data/lib/rio/state/error.rb +2 -2
- data/lib/rio/state.rb +80 -34
- data/lib/rio/stream/base.rb +7 -2
- data/lib/rio/stream/duplex.rb +13 -10
- data/lib/rio/stream/open.rb +74 -79
- data/lib/rio/stream.rb +15 -23
- data/lib/rio/symantics.rb +2 -2
- data/lib/rio/tempdir.rb +132 -132
- data/lib/rio/to_rio/all.rb +40 -0
- data/lib/rio/to_rio/array.rb +40 -0
- data/lib/rio/to_rio/io.rb +41 -0
- data/lib/rio/to_rio/object.rb +43 -0
- data/lib/rio/to_rio/string.rb +41 -0
- data/lib/rio/to_rio.rb +13 -2
- data/lib/rio/uri/file.rb +2 -2
- data/lib/rio/util.rb +2 -2
- data/lib/rio/version.rb +3 -3
- data/lib/rio.rb +16 -25
- 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_misc.rb +112 -0
- data/test/ftp/anon_read.rb +105 -0
- data/test/ftp/anon_special.rb +68 -0
- data/test/ftp/anon_write.rb +63 -0
- data/test/ftp/ftp2ftp.rb +51 -0
- data/test/ftp/initftpfiles.rb +14 -0
- data/test/ftp/testdef.rb +51 -0
- data/test/gem_runtests.rb +15 -15
- data/test/runalltests.rb +15 -0
- data/test/runftptests.rb +14 -0
- data/test/{1.rb → runhttptests.rb} +14 -14
- data/test/runtests.rb +14 -14
- data/test/tc/all.rb +36 -21
- data/test/tc/cmdpipe.rb +18 -15
- data/test/tc/copy-from-http.rb +89 -0
- data/test/tc/copy-from.rb +1 -52
- data/test/tc/copy.rb +19 -17
- data/test/tc/csv2.rb +6 -3
- data/test/tc/empty.rb +47 -0
- data/test/tc/emptyriodir.rb +129 -0
- data/test/tc/entsel.rb +110 -0
- data/test/tc/files_select.rb +92 -0
- data/test/tc/get.rb +7 -6
- data/test/tc/getrec.rb +2 -5
- data/test/tc/gzip.rb +82 -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 +112 -0
- data/test/tc/methods.rb +10 -9
- data/test/tc/misc.rb +1 -37
- data/test/tc/null.rb +45 -0
- data/test/tc/pid.rb +31 -0
- data/test/tc/piper.rb +34 -37
- data/test/tc/programs_util.rb +24 -0
- data/test/tc/readline.rb +30 -0
- data/test/tc/rename.rb +12 -0
- data/test/tc/tempfile.rb +14 -0
- data/test/tc/testcase.rb +6 -0
- data/test/tc/tonl.rb +37 -0
- metadata +181 -144
- data/ex/colx.rb +0 -8
- data/ex/findinruby +0 -16
- data/ex/findruby +0 -15
- data/ex/passwd_report.rb +0 -8
- data/ex/prompt.rb +0 -25
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +0 -35
- data/ex/riogunzip +0 -31
- data/ex/riogzip +0 -24
- data/ex/rioprompt.rb +0 -6
- data/ex/targz2zip +0 -17
- data/ex/tolf +0 -11
- data/lib/rio/ftp/conn.rb +0 -167
- data/lib/rio/ftp.rb +0 -275
- data/test/once.rb +0 -7
data/lib/rio/context/cxx.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
data/lib/rio/context/dir.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
data/lib/rio/context/gzip.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
data/lib/rio/context/methods.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
|
@@ -42,7 +42,7 @@ require 'rio/context/stream'
|
|
|
42
42
|
require 'rio/context/dir'
|
|
43
43
|
require 'rio/context/skip'
|
|
44
44
|
require 'rio/filter'
|
|
45
|
-
require 'rio/context/
|
|
45
|
+
require 'rio/context/autoclose'
|
|
46
46
|
require 'rio/context/gzip'
|
|
47
47
|
require 'rio/context/copying'
|
|
48
48
|
|
|
@@ -76,37 +76,7 @@ module RIO
|
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
module Cx
|
|
80
|
-
module Methods
|
|
81
|
-
def closeoncopy(arg=true,&block) cxx('closeoncopy',arg,&block) end
|
|
82
|
-
def nocloseoncopy(arg=false,&block) nocxx('closeoncopy',arg,&block) end
|
|
83
|
-
def closeoncopy?() cxx?('closeoncopy') end
|
|
84
|
-
def closeoncopy_(arg=true) cxx_('closeoncopy',arg) end
|
|
85
|
-
protected :closeoncopy_
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
module Cx
|
|
90
|
-
module Methods
|
|
91
|
-
def noautoclose(arg=false,&block)
|
|
92
|
-
closeoncopy(arg).closeoneof(arg,&block)
|
|
93
|
-
end
|
|
94
|
-
def noautoclose_(arg=false)
|
|
95
|
-
closeoncopy_(arg).closeoneof_(arg)
|
|
96
|
-
end
|
|
97
|
-
protected :noautoclose_
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
79
|
|
|
101
|
-
module Cx
|
|
102
|
-
module Methods
|
|
103
|
-
def autorewind(arg=true,&block) cxx('autorewind',arg,&block) end
|
|
104
|
-
def noautorewind(arg=false,&block) nocxx('autorewind',arg,&block) end
|
|
105
|
-
def autorewind?() cxx?('autorewind') end
|
|
106
|
-
def autorewind_(arg=true) cxx_('autorewind',arg) end
|
|
107
|
-
protected :autorewind_
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
80
|
|
|
111
81
|
module Cx
|
|
112
82
|
module Methods
|
|
@@ -183,7 +153,8 @@ module RIO
|
|
|
183
153
|
protected :ext_
|
|
184
154
|
end
|
|
185
155
|
end
|
|
186
|
-
|
|
156
|
+
end
|
|
157
|
+
module RIO
|
|
187
158
|
module Cx
|
|
188
159
|
module Methods
|
|
189
160
|
def a() cx['outputmode'] = Mode::Str.new('a'); self end
|
|
@@ -194,6 +165,7 @@ module RIO
|
|
|
194
165
|
def r!() cx['inputmode'] = Mode::Str.new('r+'); self end
|
|
195
166
|
def outputmode?() cxx?('outputmode') end
|
|
196
167
|
def inputmode?() cxx?('inputmode') end
|
|
168
|
+
def +@() a() end
|
|
197
169
|
end
|
|
198
170
|
end
|
|
199
171
|
end
|
data/lib/rio/context/skip.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
data/lib/rio/context/stream.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
data/lib/rio/context.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
|
@@ -51,6 +51,21 @@ module RIO
|
|
|
51
51
|
@values.delete(key)
|
|
52
52
|
@explicit.delete(key)
|
|
53
53
|
end
|
|
54
|
+
def get_keystate(key)
|
|
55
|
+
key_exists = @values.key?(key)
|
|
56
|
+
key_val = @values[key]
|
|
57
|
+
key_explicit = @explicit[key]
|
|
58
|
+
[key,key_exists,key_val,key_explicit]
|
|
59
|
+
end
|
|
60
|
+
def set_keystate(key,key_exists,key_val,key_explicit)
|
|
61
|
+
if(key_exists) then
|
|
62
|
+
@values[key] = key_val
|
|
63
|
+
@explicit[key] = key_explicit
|
|
64
|
+
else
|
|
65
|
+
@values.delete(key)
|
|
66
|
+
@explicit.delete(key)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
54
69
|
def set_(key,val)
|
|
55
70
|
@values[key] = val unless @explicit[key]
|
|
56
71
|
end
|
data/lib/rio/cp.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
|
@@ -42,11 +42,33 @@ class String #:nodoc: all
|
|
|
42
42
|
self
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
|
+
require 'rio/no_warn'
|
|
46
|
+
|
|
45
47
|
module RIO
|
|
46
48
|
module Cp #:nodoc: all
|
|
47
49
|
module Util
|
|
48
50
|
module InOut
|
|
49
51
|
def cpclose(*args,&block)
|
|
52
|
+
if args.empty?
|
|
53
|
+
oldcoc = self.cx.get_keystate('closeoncopy')
|
|
54
|
+
self.cx['closeoncopy'] = false
|
|
55
|
+
rtn = yield
|
|
56
|
+
rtn.cx.set_keystate(*oldcoc)
|
|
57
|
+
rtn.copyclose
|
|
58
|
+
else
|
|
59
|
+
if (ario = args[0]).kind_of?(Rio)
|
|
60
|
+
oldcoc = ario.cx.get_keystate('closeoncopy')
|
|
61
|
+
ario.cx['closeoncopy'] = false
|
|
62
|
+
rtn = yield
|
|
63
|
+
ario.cx.set_keystate(*oldcoc)
|
|
64
|
+
ario.copyclose
|
|
65
|
+
rtn
|
|
66
|
+
else
|
|
67
|
+
yield
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
def cpclose0(*args,&block)
|
|
50
72
|
if args.empty?
|
|
51
73
|
oldcoc,self.cx['closeoncopy'] = self.cx['closeoncopy'],false
|
|
52
74
|
rtn = yield
|
|
@@ -141,10 +163,12 @@ module RIO
|
|
|
141
163
|
|
|
142
164
|
def cpto_rio_(arg,sym)
|
|
143
165
|
ario = ensure_rio(arg)
|
|
166
|
+
#p ario
|
|
144
167
|
ario = ario.join(self.filename) if ario.dir?
|
|
145
168
|
ario.cpclose {
|
|
146
169
|
ario = ario.iostate(sym)
|
|
147
170
|
self.copying(ario).each { |el|
|
|
171
|
+
# p el
|
|
148
172
|
ario.putrec(el)
|
|
149
173
|
# ario << el
|
|
150
174
|
}.copying_done(ario)
|
|
@@ -166,15 +190,16 @@ module RIO
|
|
|
166
190
|
case arg
|
|
167
191
|
when ::Array then cpfrom_array_(arg)
|
|
168
192
|
when ::IO then cpfrom_obj_(arg)
|
|
169
|
-
when ::String then
|
|
193
|
+
when ::String then
|
|
194
|
+
self.put_(arg)
|
|
170
195
|
else cpfrom_rio_(arg)
|
|
171
196
|
end
|
|
172
197
|
self
|
|
173
198
|
end
|
|
174
199
|
def cpfrom_rio_(arg)
|
|
175
200
|
ensure_rio(arg).copying(self).each { |el|
|
|
176
|
-
self.putrec(el)
|
|
177
|
-
|
|
201
|
+
#self.putrec(el)
|
|
202
|
+
self << el
|
|
178
203
|
}.copying_done(self)
|
|
179
204
|
end
|
|
180
205
|
end
|
|
@@ -206,7 +231,8 @@ module RIO
|
|
|
206
231
|
end
|
|
207
232
|
def spcp(arg)
|
|
208
233
|
if arg.kind_of?(Rio) and arg.scheme == 'ftp'
|
|
209
|
-
arg
|
|
234
|
+
arg.copy_from(new_rio(rl.path))
|
|
235
|
+
#arg < new_rio(rl.path)
|
|
210
236
|
self
|
|
211
237
|
else
|
|
212
238
|
nil
|
|
@@ -255,7 +281,6 @@ module RIO
|
|
|
255
281
|
end
|
|
256
282
|
end
|
|
257
283
|
def cpfrom_rio_(ario)
|
|
258
|
-
#p callstr('cpfrom_rio_',ario)
|
|
259
284
|
dest = self.join(ario.filename)
|
|
260
285
|
case
|
|
261
286
|
when ario.symlink?
|
|
@@ -289,7 +314,7 @@ module RIO
|
|
|
289
314
|
alias :copy_to :>
|
|
290
315
|
alias :append_to :>>
|
|
291
316
|
|
|
292
|
-
|
|
317
|
+
protected
|
|
293
318
|
|
|
294
319
|
def cpto_rio_(ario)
|
|
295
320
|
ario = ario.join(self.filename) if ario.exist?
|
|
@@ -306,7 +331,8 @@ module RIO
|
|
|
306
331
|
include Util::Output
|
|
307
332
|
def <(arg)
|
|
308
333
|
if _switch_direction?(arg)
|
|
309
|
-
arg > self
|
|
334
|
+
#arg > self
|
|
335
|
+
arg.copy_to(self)
|
|
310
336
|
self
|
|
311
337
|
else
|
|
312
338
|
_cpsrc(arg) < arg
|
data/lib/rio/def.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005, 2006 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. Then point your browser at the 'doc/rdoc' directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Rio
|
|
33
|
+
#
|
|
34
|
+
# <b>Rio is pre-alpha software.
|
|
35
|
+
# The documented interface and behavior is subject to change without notice.</b>
|
|
36
|
+
|
|
37
|
+
require 'rio/base'
|
|
38
|
+
|
|
39
|
+
module RIO
|
|
40
|
+
# See also: RIO::Doc::SYNOPSIS; RIO::Doc::INTRO; RIO::Doc::HOWTO.
|
|
41
|
+
class Rio < Base #:doc:
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if $0 == __FILE__
|
|
46
|
+
eval DATA.read, nil, $0, __LINE__+4
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
__END__
|
|
50
|
+
|
|
51
|
+
puts
|
|
52
|
+
puts("Run the tests that came with the distribution")
|
|
53
|
+
puts("From the distribution directory use 'test/runtests.rb'")
|
|
54
|
+
puts
|
data/lib/rio/dir.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
|
@@ -43,9 +43,6 @@ module RIO
|
|
|
43
43
|
module Dir #:nodoc: all
|
|
44
44
|
class Base < State::Base
|
|
45
45
|
include Ops::Path::Str
|
|
46
|
-
def self.copy_(src,dst)
|
|
47
|
-
Impl::U.cp_r(src,dst)
|
|
48
|
-
end
|
|
49
46
|
def open?() !ioh.nil? end
|
|
50
47
|
end
|
|
51
48
|
|
|
@@ -60,21 +57,27 @@ module RIO
|
|
|
60
57
|
|
|
61
58
|
def check?() self.directory? end
|
|
62
59
|
def when_missing(sym,*args) dopen() end
|
|
60
|
+
|
|
61
|
+
protected
|
|
62
|
+
|
|
63
|
+
def stream_rl_
|
|
64
|
+
self.rl.dir_rl()
|
|
65
|
+
#RIO::Dir::RL.new(self.to_uri, {:fs => self.fs})
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
public
|
|
69
|
+
|
|
63
70
|
def dopen()
|
|
64
|
-
self.rl =
|
|
71
|
+
self.rl = self.stream_rl_
|
|
65
72
|
become 'Dir::Open'
|
|
66
73
|
end
|
|
67
74
|
end
|
|
68
75
|
class Open < Base
|
|
69
76
|
def check?() true end
|
|
70
|
-
def open(m=nil,*args)
|
|
71
|
-
open_(*args)
|
|
72
|
-
end
|
|
77
|
+
def open(m=nil,*args) open_(*args) end
|
|
73
78
|
def open_(*args)
|
|
74
79
|
unless open?
|
|
75
|
-
|
|
76
|
-
self.ioh = IOH::Dir.new(ios)
|
|
77
|
-
# self.ioh = self.rl.open()
|
|
80
|
+
self.ioh = self.rl.open()
|
|
78
81
|
end
|
|
79
82
|
self
|
|
80
83
|
end
|
|
@@ -96,18 +99,14 @@ module RIO
|
|
|
96
99
|
class Stream < Base
|
|
97
100
|
include Ops::Dir::Stream
|
|
98
101
|
def check?() open? end
|
|
99
|
-
def when_missing(sym,*args)
|
|
100
|
-
#p callstr('when_missing',sym,*args)
|
|
101
|
-
retryreset()
|
|
102
|
-
end
|
|
102
|
+
def when_missing(sym,*args) retryreset() end
|
|
103
103
|
def base_state() 'Dir::Close' end
|
|
104
|
-
|
|
105
|
-
def reset()
|
|
106
|
-
self.close.softreset()
|
|
107
|
-
end
|
|
104
|
+
def reset() self.close.softreset() end
|
|
108
105
|
alias :copyclose :reset
|
|
109
106
|
end
|
|
110
107
|
class Close < Base
|
|
108
|
+
def reopen(*args) self.close_.softreset.open(*args) end
|
|
109
|
+
|
|
111
110
|
def close()
|
|
112
111
|
#p callstr('close')+" mode='#{mode?}' ioh=#{self.ioh} open?=#{open?}"
|
|
113
112
|
return self unless self.open?
|
data/lib/rio/doc/HOWTO.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# ===============================================================================
|
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
|
4
4
|
# All rights reserved
|
|
5
5
|
#
|
|
6
6
|
# This file is part of the Rio library for ruby.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
24
|
# To create the documentation for Rio run the command
|
|
25
|
-
#
|
|
25
|
+
# ruby build_doc.rb
|
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
|
27
27
|
#
|
|
28
28
|
# Suggested Reading
|
|
@@ -269,7 +269,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
|
|
|
269
269
|
# method 1
|
|
270
270
|
array = ario['*.txt']
|
|
271
271
|
# method 2
|
|
272
|
-
array = ario[/\.txt
|
|
272
|
+
array = ario[/\.txt$/]
|
|
273
273
|
# method 3
|
|
274
274
|
array = ario.entries['*.txt']
|
|
275
275
|
|
|
@@ -277,7 +277,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
|
|
|
277
277
|
# method 1
|
|
278
278
|
array = ario.files['*.txt']
|
|
279
279
|
# method 2
|
|
280
|
-
array = ario.files[/\.txt
|
|
280
|
+
array = ario.files[/\.txt$/]
|
|
281
281
|
# method 3
|
|
282
282
|
array = ario.files['*.txt']
|
|
283
283
|
|
|
@@ -285,7 +285,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
|
|
|
285
285
|
# method 1
|
|
286
286
|
array = ario.all['*.txt']
|
|
287
287
|
# method 2
|
|
288
|
-
array = ario.all[/\.txt
|
|
288
|
+
array = ario.all[/\.txt$/]
|
|
289
289
|
# method 3
|
|
290
290
|
array = ario.all.entries['*.txt']
|
|
291
291
|
|
|
@@ -294,7 +294,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
|
|
|
294
294
|
# method 1
|
|
295
295
|
array = ario.norecurse('.svn').all['*.txt']
|
|
296
296
|
# method 2
|
|
297
|
-
array = ario.norecurse(/^\.svn$/).all[/\.txt
|
|
297
|
+
array = ario.norecurse(/^\.svn$/).all[/\.txt$/]
|
|
298
298
|
# method 3
|
|
299
299
|
array = ario.norecurse('.svn').entries['*.txt']
|
|
300
300
|
# method 4
|
|
@@ -302,6 +302,17 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
|
|
|
302
302
|
# method 5
|
|
303
303
|
array = ario.norecurse('.svn')['*.txt']
|
|
304
304
|
|
|
305
|
+
* Put all directories (recursively) into an array
|
|
306
|
+
# method 1
|
|
307
|
+
array = ario.dirs[]
|
|
308
|
+
# method 2
|
|
309
|
+
array = ario.dirs.to_a
|
|
310
|
+
|
|
311
|
+
* Put all entries (recursively) into an array, but limit the depth of recursion to 2
|
|
312
|
+
# method 1
|
|
313
|
+
array = ario.norecurse(3).to_a
|
|
314
|
+
|
|
315
|
+
|
|
305
316
|
* Iterate through ruby files in a directory and subdirectories skipping
|
|
306
317
|
those in the '.svn', and 'pkg' directories
|
|
307
318
|
# method 1
|
|
@@ -337,7 +348,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
|
|
|
337
348
|
# method 1
|
|
338
349
|
array = ario.skipdirs['.svn']
|
|
339
350
|
# method 2
|
|
340
|
-
array = ario.skipdirs[/^\.svn
|
|
351
|
+
array = ario.skipdirs[/^\.svn$/]
|
|
341
352
|
# method 3
|
|
342
353
|
array = ario.skipdirs('.svn').to_a
|
|
343
354
|
# method 4
|
|
@@ -649,6 +660,11 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
|
|
|
649
660
|
htmfile.rename.extname = '.html'
|
|
650
661
|
end
|
|
651
662
|
|
|
663
|
+
* Move a file in an arbitrary directory into the current working directory.
|
|
664
|
+
# method 1
|
|
665
|
+
rio('arb/i/trary/di/rec/tory/afile').rename.dirname = '.'
|
|
666
|
+
|
|
667
|
+
|
|
652
668
|
---
|
|
653
669
|
|
|
654
670
|
=== Manipulate a Rio's path
|