rio 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -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
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/handle.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/if/basic.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/if/csv.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/if/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/if/file.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
|
@@ -52,6 +52,30 @@ module RIO
|
|
52
52
|
#
|
53
53
|
def touch() target.touch(); self end
|
54
54
|
|
55
|
+
# Calls File#truncate
|
56
|
+
#
|
57
|
+
# Truncates a file referenced by a Rio to be at most +sz+ bytes long.
|
58
|
+
# Not available on all platforms.
|
59
|
+
#
|
60
|
+
# f = rio("out")
|
61
|
+
# f.print!("1234567890")
|
62
|
+
# f.size #=> 10
|
63
|
+
# f.truncate(5)
|
64
|
+
# f.size() #=> 5
|
65
|
+
#
|
66
|
+
# If called with no arguments, truncates the Rio at the
|
67
|
+
# value returned by Rio#pos().
|
68
|
+
# f.read(2)
|
69
|
+
# f.truncate.size #=> 2
|
70
|
+
# f.contents #=> "12"
|
71
|
+
#
|
72
|
+
# Returns the Rio
|
73
|
+
#
|
74
|
+
def truncate(sz=pos()) target.truncate(sz); self end
|
55
75
|
|
76
|
+
# Calls Rio#truncate(0)
|
77
|
+
#
|
78
|
+
def clear() target.clear(); self end
|
79
|
+
|
56
80
|
end
|
57
81
|
end
|
data/lib/rio/if/fileordir.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
|
@@ -40,16 +40,6 @@ module RIO
|
|
40
40
|
|
41
41
|
# undocumented
|
42
42
|
def open(m,*args,&block) target.open(m,*args,&block); self end
|
43
|
-
# if block_given?
|
44
|
-
# old_closeoncopy,old_closeoneof = closeoncopy?,closeoneof?
|
45
|
-
# begin
|
46
|
-
# return yield(nocloseoncopy.nocloseoneof)
|
47
|
-
# ensure
|
48
|
-
# reset.closeoncopy(old_closeoncopy).closeoneof(old_closeoneof)
|
49
|
-
# end
|
50
|
-
# end
|
51
|
-
# self
|
52
|
-
# end
|
53
43
|
|
54
44
|
# Creates a symbolic link _dest_ which points to the Rio's Rio#fspath.
|
55
45
|
# Raises a NotImplementedError exception on platforms that do not support symbolic links.
|
@@ -123,10 +113,10 @@ module RIO
|
|
123
113
|
def rename!(*args,&block) target.rename!(*args,&block); self end
|
124
114
|
|
125
115
|
|
126
|
-
# For directories
|
116
|
+
# For directories calls Dir#read, otherwise calls IO#read
|
127
117
|
#
|
128
|
-
#
|
129
|
-
#
|
118
|
+
# For streams calls IO#read
|
119
|
+
# ario.read([integer [, buffer]]) => string, buffer, or nil
|
130
120
|
# Reads at most _integer_ bytes from the I/O stream, or to the end of
|
131
121
|
# file if _integer_ is omitted or is +nil+. If the optional _buffer_
|
132
122
|
# argument is present, it must reference a String, which will receive
|
@@ -137,15 +127,15 @@ module RIO
|
|
137
127
|
#
|
138
128
|
# rio("testfile").read(16) #=> "This is line one"
|
139
129
|
#
|
140
|
-
#
|
141
|
-
#
|
130
|
+
# For directories calls Dir#read
|
131
|
+
# dir.read => ario or nil
|
142
132
|
#------------------------------------------------------------------------
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
133
|
+
# Reads the next entry from _dir_ and returns it as a Rio. Returns
|
134
|
+
# +nil+ at the end of the stream.
|
135
|
+
# d = rio("testdir")
|
136
|
+
# d.read #=> rio(".")
|
137
|
+
# d.read #=> rio("..")
|
138
|
+
# d.read #=> rio("config.h")
|
149
139
|
#
|
150
140
|
def read(*args) target.read(*args)end
|
151
141
|
|
@@ -166,18 +156,18 @@ module RIO
|
|
166
156
|
# f.rewind.readline #=> "This is line one\n"
|
167
157
|
#
|
168
158
|
# Proxy for Dir#rewind
|
169
|
-
#
|
159
|
+
# ario.rewind => ario
|
170
160
|
#------------------------------------------------------------------------
|
171
|
-
#
|
161
|
+
# Repositions _ario_ to the first entry.
|
172
162
|
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
163
|
+
# d = rio("testdir")
|
164
|
+
# d.read #=> rio(".")
|
165
|
+
# d.rewind.read #=> rio(".")
|
176
166
|
def rewind(&block) target.rewind(&block); self end
|
177
167
|
|
178
|
-
# For directories
|
168
|
+
# For directories calls Dir#seek, otherwise calls IO#seek
|
179
169
|
#
|
180
|
-
#
|
170
|
+
# For streams calls IO#seek
|
181
171
|
# ario.seek(amount, whence=SEEK_SET) -> ario
|
182
172
|
# Seeks to a given offset _amount_ in the stream according to the
|
183
173
|
# value of _whence_:
|
@@ -194,25 +184,25 @@ module RIO
|
|
194
184
|
# f = rio("testfile")
|
195
185
|
# f.seek(-28, IO::SEEK_END).readline #=> "happily ever after. The End\n"
|
196
186
|
#
|
197
|
-
#
|
187
|
+
# For directories calls Dir#seek
|
198
188
|
# ario.seek( integer ) => ario
|
199
189
|
# Seeks to a particular location in _ario_. _integer_ must be a value
|
200
|
-
# returned by
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
#
|
190
|
+
# returned by Rio#tell.
|
191
|
+
#
|
192
|
+
# d = rio("testdir") #=> #<RIO::Rio:0x401b3c40>
|
193
|
+
# d.read #=> rio(".")
|
194
|
+
# i = d.tell #=> 12
|
195
|
+
# d.read #=> rio("..")
|
196
|
+
# d.seek(i) #=> #<RIO::Rio:0x401b3c40>
|
197
|
+
# d.read #=> rio("..")
|
208
198
|
def seek(*args) target.seek(*args); self end
|
209
199
|
#def seek(amount,whence=IO::SEEK_SET) target.seek(amount,whence) end
|
210
200
|
|
211
201
|
|
212
202
|
|
213
|
-
# For directories
|
203
|
+
# For directories calls Dir#pos, otherwise calls IO#pos
|
214
204
|
#
|
215
|
-
#
|
205
|
+
# For streams calls IO#pos
|
216
206
|
# ario.pos => integer
|
217
207
|
# ario.tell => integer
|
218
208
|
# Returns the current offset (in bytes) of _ario_.
|
@@ -223,24 +213,24 @@ module RIO
|
|
223
213
|
# f.pos #=> 17
|
224
214
|
#
|
225
215
|
#
|
226
|
-
#
|
216
|
+
# For directories calls Dir#pos
|
227
217
|
# ario.pos => integer
|
228
218
|
# ario.tell => integer
|
229
219
|
# Returns the current position in _dir_. See also +Rio#seek+.
|
230
220
|
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
221
|
+
# d = rio("testdir")
|
222
|
+
# d.pos #=> 0
|
223
|
+
# d.read #=> rio(".")
|
224
|
+
# d.pos #=> 12
|
235
225
|
#
|
236
226
|
def pos() target.pos end
|
237
227
|
|
238
228
|
# See Rio#pos
|
239
229
|
def tell() target.tell end
|
240
230
|
|
241
|
-
# For directories
|
231
|
+
# For directories calls Dir#pos=, otherwise calls IO#pos=
|
242
232
|
#
|
243
|
-
#
|
233
|
+
# For streams calls IO#pos=
|
244
234
|
# ario.pos = integer => 0
|
245
235
|
# Seeks to the given position (in bytes) in _ario_.
|
246
236
|
#
|
@@ -248,7 +238,7 @@ module RIO
|
|
248
238
|
# f.pos = 17
|
249
239
|
# f.gets #=> "This is line two\n"
|
250
240
|
#
|
251
|
-
#
|
241
|
+
# For directories calls Dir#pos=
|
252
242
|
# ario.pos = integer => integer
|
253
243
|
#------------------------------------------------------------------------
|
254
244
|
# Synonym for +Rio#seek+, but returns the position parameter.
|
@@ -261,6 +251,11 @@ module RIO
|
|
261
251
|
# d.read #=> rio("..")
|
262
252
|
#
|
263
253
|
def pos=(integer) target.pos = integer end
|
254
|
+
|
255
|
+
# For Streams calls IO#reopen, otherwise closes and re-opens
|
256
|
+
# the Rio.
|
257
|
+
#
|
258
|
+
def reopen(mode=nil) target.reopen(mode); self end
|
264
259
|
end
|
265
260
|
end
|
266
261
|
|
data/lib/rio/if/grande.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
|
@@ -34,7 +34,7 @@
|
|
34
34
|
# <b>Rio is pre-alpha software.
|
35
35
|
# The documented interface and behavior is subject to change without notice.</b>
|
36
36
|
|
37
|
-
|
37
|
+
require 'rio/no_warn'
|
38
38
|
module RIO
|
39
39
|
class Rio
|
40
40
|
# module IF
|
@@ -87,9 +87,11 @@ module RIO
|
|
87
87
|
# range:: specifies a range of records to be selected (zero based)
|
88
88
|
# regexp:: matching records will be selected.
|
89
89
|
# integer:: treated like a one element range
|
90
|
-
# symbol:: the symbol is sent to
|
91
|
-
#
|
92
|
-
#
|
90
|
+
# symbol:: the symbol is sent to each record. Record is selected
|
91
|
+
# unless false is returned
|
92
|
+
# proc:: the proc is called with the record as an argument.
|
93
|
+
# Record is selected unless false is returned
|
94
|
+
# array:: the array may contain any of the other selector types. Record is selected
|
93
95
|
# unless any of the selectors returns false. (a logical and)
|
94
96
|
#
|
95
97
|
# A record matching *any* of the selectors will be included in the array. (acts like an _or_)
|
@@ -401,7 +403,12 @@ module RIO
|
|
401
403
|
# file on a web site into a local gzipped csv file that uses semi-colons as separators
|
402
404
|
# rio('http://domain/file.csv.gz').columns(0,7..9).gzip.csv[0..9] > rio('localfile.csv.gz').csv(';').gzip
|
403
405
|
#
|
404
|
-
def >(destination)
|
406
|
+
def >(destination)
|
407
|
+
RIO::no_warn {
|
408
|
+
target > destination;
|
409
|
+
}
|
410
|
+
self
|
411
|
+
end
|
405
412
|
|
406
413
|
# Alias for Rio#> (copy-to grande operator)
|
407
414
|
def copy_to(destination) target.copy_to(destination); self end
|
@@ -468,8 +475,7 @@ module RIO
|
|
468
475
|
# rio('afile') >> rio('anotherfile') # append the contents of 'afile' to 'anotherfile'
|
469
476
|
# rio('afile') >> rio('adir') # copies 'afile' to the directory 'adir'
|
470
477
|
# rio('adir') >> rio('anotherdir') # copy directory 'adir' recursively to 'anotherdir'
|
471
|
-
# rio('adir') >> array #
|
472
|
-
# rio('adir') >> ary # a Rio for each entry in the directory will be appended to ary
|
478
|
+
# rio('adir') >> array # a Rio for each entry in the directory will be appended to ary
|
473
479
|
def >>(destination) target >> destination; self end
|
474
480
|
|
475
481
|
|
@@ -577,7 +583,12 @@ module RIO
|
|
577
583
|
#
|
578
584
|
# See also Rio#> (copy-to), Rio#each, Rio#[]
|
579
585
|
#
|
580
|
-
def <(source)
|
586
|
+
def <(source)
|
587
|
+
RIO::no_warn {
|
588
|
+
target < source
|
589
|
+
}
|
590
|
+
self
|
591
|
+
end
|
581
592
|
|
582
593
|
# Alias for Rio#< (copy-from grande operator)
|
583
594
|
def copy_from(source) target.copy_from(source); self end
|
@@ -658,5 +669,16 @@ module RIO
|
|
658
669
|
# Rio#skipdirs, and Rio#skipentries.
|
659
670
|
#
|
660
671
|
def skip(*args,&block) target.skip(*args,&block); self end
|
672
|
+
|
673
|
+
|
674
|
+
# Returns true if the referenced file or directory is empty after honoring the grande
|
675
|
+
# selection methods.
|
676
|
+
#
|
677
|
+
# rio('f0').delete!.touch.empty? #=> true
|
678
|
+
# rio('f1').puts!("Not Empty\n").empty? #=> false
|
679
|
+
# rio('d0').delete!.mkdir.empty? #=> true
|
680
|
+
#
|
681
|
+
def empty?() target.empty? end
|
682
|
+
|
661
683
|
end
|
662
684
|
end
|
data/lib/rio/if/grande_entry.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,12 +43,14 @@ module RIO
|
|
43
43
|
# ario.files(*args) do |f|
|
44
44
|
# f.directory? #=> true
|
45
45
|
# end
|
46
|
+
#
|
46
47
|
# No aguments selects all directories.
|
47
48
|
# if _args_ are:
|
48
49
|
# Regexp:: selects matching directories
|
49
50
|
# glob:: selects matching directories
|
50
51
|
# Proc:: called for each directory. the directory is processed unless the proc returns false
|
51
52
|
# Symbol:: sent to each directory. Each directory is processed unless the symbol returns false
|
53
|
+
# Fixnum:: matched against the "depth" of the directory
|
52
54
|
#
|
53
55
|
# If a block is given, behaves like <tt>ario.dirs(*args).each(&block)</tt>
|
54
56
|
#
|
@@ -252,10 +254,14 @@ module RIO
|
|
252
254
|
# is a shortcut for
|
253
255
|
# rio('adir').files('*.rb').to_a
|
254
256
|
#
|
257
|
+
# and
|
258
|
+
#
|
255
259
|
# rio('adir')['*.rb']
|
256
260
|
# is a shortcut for
|
257
261
|
# rio('adir').entries('*.rb').to_a
|
258
262
|
#
|
263
|
+
# and
|
264
|
+
#
|
259
265
|
# rio('afile').lines[0..10]
|
260
266
|
# is a shortcut for
|
261
267
|
# rio('afile').lines(0..10).to_a
|
@@ -328,6 +334,8 @@ module RIO
|
|
328
334
|
# glob:: recurse into matching subdirectories
|
329
335
|
# Proc:: called for each directory. The directory is recursed into unless the proc returns false
|
330
336
|
# Symbol:: sent to each directory. Each directory is recursed into unless the symbol returns false
|
337
|
+
# Fixnum:: recurse into directories only at the given depth
|
338
|
+
# Range:: recurse into directories at a range of depths
|
331
339
|
#
|
332
340
|
# If a block is given, behaves like <tt>ario.recurse(*args).each(&block)</tt>
|
333
341
|
#
|
@@ -347,6 +355,8 @@ module RIO
|
|
347
355
|
#
|
348
356
|
# rio('adir').norecurse('.svn') { |drio| ... } # recurse, skipping subversion directories
|
349
357
|
#
|
358
|
+
# rio('adir').norecurse(3) {|drio| ... } # only recurse 2 levels deep into a directory structure
|
359
|
+
#
|
350
360
|
def norecurse(*args,&block) target.norecurse(*args,&block); self end
|
351
361
|
|
352
362
|
|
data/lib/rio/if/grande_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
|
@@ -40,7 +40,7 @@ module RIO
|
|
40
40
|
|
41
41
|
# Sets the rio to read lines and returns the Rio
|
42
42
|
#
|
43
|
-
# If called with a block behaves as if lines(*args).each(&block) had been called
|
43
|
+
# If called with a block behaves as if <tt>lines(*args).each(&block)</tt> had been called
|
44
44
|
#
|
45
45
|
# +lines+ returns the Rio which called it. This might seem counter-intuitive at first.
|
46
46
|
# One might reasonably assume that
|
@@ -231,6 +231,16 @@ module RIO
|
|
231
231
|
# to 'a','a+','w','w+','r' and 'r+' respectively.
|
232
232
|
def a() target.a(); self end
|
233
233
|
|
234
|
+
# Unary Plus. Alternate form of Rio#a
|
235
|
+
# rio('f1') > rio('f2') # copy f1 to f2
|
236
|
+
# rio('f1') > rio('f2').a # append f1 to f2
|
237
|
+
# rio('f1') > +rio('f2') # same thing
|
238
|
+
# rio('f1') >> rio('f2') # same thing
|
239
|
+
#
|
240
|
+
def +@()
|
241
|
+
RIO::no_warn { +target }
|
242
|
+
self
|
243
|
+
end
|
234
244
|
|
235
245
|
# Sets the implicit output mode to 'a+'.
|
236
246
|
#
|
@@ -298,7 +308,7 @@ module RIO
|
|
298
308
|
# ario.closeoneof(&block) => ario
|
299
309
|
#
|
300
310
|
# +closeoneof+ causes a Rio to be closed automatically whenever the end of
|
301
|
-
# file is reached. This
|
311
|
+
# file is reached. This affects
|
302
312
|
# all methods that read from a rio (Rio#readlines, Rio#to_a, Rio#each Rio#gets etc.)
|
303
313
|
# Because +closeoneof+ must be on for many of Rio's most useful idioms,
|
304
314
|
# it is on by default. +closeoneof+ can be turned off using Rio#nocloseoneof.
|
@@ -421,8 +431,8 @@ module RIO
|
|
421
431
|
#
|
422
432
|
# rio('afile') < a_string # put a string into a file
|
423
433
|
# rio('afile') < an_array # put an array into a file
|
424
|
-
# rio('afile') < rio('anotherfile').lines(
|
425
|
-
# rio('afile.gz').gzip < rio('anotherfile').lines(
|
434
|
+
# rio('afile') < rio('anotherfile').lines(0..9) # copy the first 10 lines of anotherfile into afile
|
435
|
+
# rio('afile.gz').gzip < rio('anotherfile').lines(0..9) # same thing into a gzipped file
|
426
436
|
#
|
427
437
|
# In each of these cases, 'afile' would remain open after the copy and furthermore
|
428
438
|
# since the destination Rio was not saved in a variable, There is no way to close file.
|
@@ -450,9 +460,7 @@ module RIO
|
|
450
460
|
#
|
451
461
|
# In perl the rio's destructor would be called, because there are no remaining references to the Rio
|
452
462
|
# However, it my understanding and experience that in Ruby the finalizer will not necessarily be
|
453
|
-
# called at this point.
|
454
|
-
# and there is a way to make this work without closeoncopy,
|
455
|
-
# please contact the author.
|
463
|
+
# called at this point.
|
456
464
|
#
|
457
465
|
def closeoncopy(arg=true,&block) target.closeoncopy(arg,&block); self end
|
458
466
|
|
@@ -475,25 +483,6 @@ module RIO
|
|
475
483
|
def closeoncopy?() target.closeoncopy?() end
|
476
484
|
|
477
485
|
|
478
|
-
# Rio#autorewind?
|
479
|
-
#
|
480
|
-
#
|
481
|
-
#def autorewind?() target.autorewind?() end
|
482
|
-
|
483
|
-
|
484
|
-
# Sets a Rio to 'autorewind'.
|
485
|
-
# autorewind is not a well thought out concept and probably will be
|
486
|
-
# removed. Do not use it.
|
487
|
-
#
|
488
|
-
def autorewind(*args,&block) target.autorewind(*args,&block); self end
|
489
|
-
|
490
|
-
|
491
|
-
# Rio#noautorewind
|
492
|
-
#
|
493
|
-
#
|
494
|
-
#def noautorewind(arg=false,&block) target.noautorewind(arg,&block); self end
|
495
|
-
|
496
|
-
|
497
486
|
# Queries the Rio's chomp-mode.
|
498
487
|
# See Rio#chomp.
|
499
488
|
#
|
data/lib/rio/if/internal.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/if/path.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
|
@@ -67,11 +67,11 @@ module RIO
|
|
67
67
|
|
68
68
|
# Returns the path for the Rio on the underlying file system
|
69
69
|
# Returns nil if the Rio is not on the filesystem (i.e. stdin: or http: Rios)
|
70
|
-
def fspath(
|
70
|
+
def fspath() target.fspath() end
|
71
71
|
|
72
72
|
# Returns the path portion of the URL representation of the rio
|
73
73
|
# Returns nil if the Rio URL has no path (i.e. stdin: or http: Rios)
|
74
|
-
def urlpath(
|
74
|
+
def urlpath() target.urlpath() end
|
75
75
|
|
76
76
|
# Proxy for File#expand_path
|
77
77
|
#
|
@@ -417,8 +417,9 @@ module RIO
|
|
417
417
|
|
418
418
|
# Calls URI#merge
|
419
419
|
#
|
420
|
-
# Merges two Rios. URI#merge does not document exactly what merging
|
421
|
-
# join the
|
420
|
+
# Merges two Rios. URI#merge does not document exactly what merging two URIs means.
|
421
|
+
# This appears to join the paths like <tt>other + path</tt>.
|
422
|
+
# See URI#merge for less information.
|
422
423
|
#
|
423
424
|
def merge(other) target.merge(other) end
|
424
425
|
|