rio 0.3.8 → 0.3.9

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.
Files changed (223) hide show
  1. data/README +18 -12
  2. data/Rakefile +57 -87
  3. data/build_doc.rb +19 -17
  4. data/doc/ANNOUNCE +3 -32
  5. data/doc/RELEASE_NOTES +4 -5
  6. data/doc/RIOIS +215 -0
  7. data/doc/generators/template/html/rio.css +428 -0
  8. data/doc/generators/template/html/rio.rb +18 -389
  9. data/doc/generators/template/html/ugly.rb +130 -0
  10. data/doc/pkg_def.rb +66 -0
  11. data/ex/catcsv.rb +64 -0
  12. data/ex/colx.rb +8 -0
  13. data/ex/findinruby +15 -0
  14. data/ex/findruby +14 -0
  15. data/ex/passwd_report.rb +8 -0
  16. data/ex/prompt.rb +25 -0
  17. data/ex/rgb.txt.gz +0 -0
  18. data/ex/riocat +42 -0
  19. data/ex/riogunzip +31 -0
  20. data/ex/riogzip +24 -0
  21. data/ex/rioprompt.rb +10 -0
  22. data/ex/targz2zip +17 -0
  23. data/ex/tonl +10 -0
  24. data/lib/rio.rb +16 -10
  25. data/lib/rio/abstract_method.rb +3 -4
  26. data/lib/rio/argv.rb +3 -4
  27. data/lib/rio/arycopy.rb +3 -4
  28. data/lib/rio/assert.rb +3 -4
  29. data/lib/rio/base.rb +3 -4
  30. data/lib/rio/callstr.rb +3 -4
  31. data/lib/rio/const.rb +3 -4
  32. data/lib/rio/construct.rb +3 -4
  33. data/lib/rio/constructor.rb +12 -8
  34. data/lib/rio/context.rb +15 -30
  35. data/lib/rio/context/autoclose.rb +3 -4
  36. data/lib/rio/context/copying.rb +3 -4
  37. data/lib/rio/context/cxx.rb +3 -4
  38. data/lib/rio/context/dir.rb +3 -4
  39. data/lib/rio/context/gzip.rb +3 -4
  40. data/lib/rio/context/methods.rb +16 -5
  41. data/lib/rio/context/skip.rb +3 -4
  42. data/lib/rio/context/stream.rb +42 -5
  43. data/lib/rio/cp.rb +7 -7
  44. data/lib/rio/def.rb +3 -4
  45. data/lib/rio/dir.rb +3 -4
  46. data/lib/rio/doc.rb +4 -5
  47. data/lib/rio/doc/EXAMPLES.rb +299 -0
  48. data/lib/rio/doc/HOWTO.rb +3 -4
  49. data/lib/rio/doc/INTRO.rb +86 -105
  50. data/lib/rio/doc/OPTIONAL.rb +4 -5
  51. data/lib/rio/doc/SYNOPSIS.rb +7 -6
  52. data/lib/rio/entrysel.rb +21 -23
  53. data/lib/rio/exception.rb +3 -4
  54. data/lib/rio/exception/copy.rb +3 -4
  55. data/lib/rio/exception/notimplemented.rb +57 -0
  56. data/lib/rio/exception/notsupported.rb +3 -4
  57. data/lib/rio/exception/open.rb +3 -4
  58. data/lib/rio/exception/state.rb +3 -4
  59. data/lib/rio/ext.rb +47 -13
  60. data/lib/rio/ext/csv.rb +4 -5
  61. data/lib/rio/ext/if.rb +45 -0
  62. data/lib/rio/ext/mp3info.rb +80 -0
  63. data/lib/rio/ext/splitlines.rb +253 -0
  64. data/lib/rio/ext/yaml.rb +9 -5
  65. data/lib/rio/ext/yaml/doc.rb +133 -0
  66. data/lib/rio/ext/yaml/tie.rb +149 -0
  67. data/lib/rio/ext/zipfile.rb +23 -4
  68. data/lib/rio/ext/zipfile/fs.rb +116 -0
  69. data/lib/rio/ext/zipfile/rl.rb +251 -0
  70. data/lib/rio/ext/zipfile/rootdir.rb +117 -0
  71. data/lib/rio/ext/zipfile/state.rb +161 -0
  72. data/lib/rio/ext/zipfile/wrap.rb +204 -0
  73. data/lib/rio/factory.rb +235 -27
  74. data/lib/rio/file.rb +4 -4
  75. data/lib/rio/filter.rb +3 -4
  76. data/lib/rio/filter/closeoneof.rb +3 -4
  77. data/lib/rio/filter/gzip.rb +9 -4
  78. data/lib/rio/fs/base.rb +3 -4
  79. data/lib/rio/fs/impl.rb +4 -5
  80. data/lib/rio/fs/native.rb +3 -4
  81. data/lib/rio/fs/stream.rb +3 -4
  82. data/lib/rio/fs/url.rb +3 -4
  83. data/lib/rio/ftp/conncache.rb +19 -5
  84. data/lib/rio/ftp/dir.rb +3 -4
  85. data/lib/rio/ftp/fs.rb +30 -24
  86. data/lib/rio/grande.rb +27 -7
  87. data/lib/rio/handle.rb +3 -4
  88. data/lib/rio/if.rb +19 -15
  89. data/lib/rio/if/basic.rb +7 -7
  90. data/lib/rio/if/csv.rb +5 -6
  91. data/lib/rio/if/dir.rb +120 -114
  92. data/lib/rio/if/file.rb +52 -44
  93. data/lib/rio/if/fileordir.rb +217 -211
  94. data/lib/rio/if/grande.rb +674 -644
  95. data/lib/rio/if/grande_entry.rb +321 -313
  96. data/lib/rio/if/grande_stream.rb +653 -553
  97. data/lib/rio/if/internal.rb +3 -4
  98. data/lib/rio/if/path.rb +425 -426
  99. data/lib/rio/if/rubyio.rb +681 -0
  100. data/lib/rio/if/string.rb +42 -5
  101. data/lib/rio/if/temp.rb +3 -4
  102. data/lib/rio/if/test.rb +245 -238
  103. data/lib/rio/if/yaml.rb +15 -41
  104. data/lib/rio/ioh.rb +7 -5
  105. data/lib/rio/iomode.rb +19 -7
  106. data/lib/rio/ios/fail.rb +4 -5
  107. data/lib/rio/ios/generic.rb +4 -5
  108. data/lib/rio/ios/mode.rb +4 -5
  109. data/lib/rio/ios/null.rb +6 -7
  110. data/lib/rio/iowrap.rb +3 -4
  111. data/lib/rio/kernel.rb +3 -5
  112. data/lib/rio/local.rb +3 -4
  113. data/lib/rio/match.rb +3 -4
  114. data/lib/rio/matchrecord.rb +3 -4
  115. data/lib/rio/no_warn.rb +3 -4
  116. data/lib/rio/nullio.rb +3 -4
  117. data/lib/rio/open3.rb +4 -5
  118. data/lib/rio/ops/construct.rb +3 -4
  119. data/lib/rio/ops/create.rb +11 -6
  120. data/lib/rio/ops/dir.rb +19 -8
  121. data/lib/rio/ops/either.rb +6 -5
  122. data/lib/rio/ops/file.rb +3 -4
  123. data/lib/rio/ops/path.rb +14 -35
  124. data/lib/rio/ops/stream.rb +3 -4
  125. data/lib/rio/ops/stream/input.rb +4 -7
  126. data/lib/rio/ops/stream/output.rb +3 -4
  127. data/lib/rio/ops/stream/read.rb +6 -5
  128. data/lib/rio/ops/stream/write.rb +3 -4
  129. data/lib/rio/ops/symlink.rb +3 -4
  130. data/lib/rio/path.rb +22 -18
  131. data/lib/rio/path/reset.rb +4 -5
  132. data/lib/rio/piper.rb +3 -4
  133. data/lib/rio/piper/cp.rb +3 -4
  134. data/lib/rio/prompt.rb +10 -5
  135. data/lib/rio/rectype.rb +5 -5
  136. data/lib/rio/rl/base.rb +17 -71
  137. data/lib/rio/rl/builder.rb +14 -38
  138. data/lib/rio/rl/chmap.rb +66 -0
  139. data/lib/rio/rl/fs2url.rb +82 -0
  140. data/lib/rio/rl/ioi.rb +4 -4
  141. data/lib/rio/rl/path.rb +44 -122
  142. data/lib/rio/rl/pathmethods.rb +19 -8
  143. data/lib/rio/rl/uri.rb +137 -60
  144. data/lib/rio/rl/withpath.rb +295 -0
  145. data/lib/rio/scheme/aryio.rb +3 -4
  146. data/lib/rio/scheme/cmdio.rb +3 -4
  147. data/lib/rio/scheme/cmdpipe.rb +4 -4
  148. data/lib/rio/scheme/fd.rb +3 -4
  149. data/lib/rio/scheme/ftp.rb +7 -7
  150. data/lib/rio/scheme/http.rb +4 -5
  151. data/lib/rio/scheme/null.rb +3 -4
  152. data/lib/rio/scheme/path.rb +3 -4
  153. data/lib/rio/scheme/stderr.rb +3 -4
  154. data/lib/rio/scheme/stdio.rb +3 -4
  155. data/lib/rio/scheme/strio.rb +3 -4
  156. data/lib/rio/scheme/sysio.rb +3 -4
  157. data/lib/rio/scheme/tcp.rb +3 -4
  158. data/lib/rio/scheme/temp.rb +6 -6
  159. data/lib/rio/state.rb +18 -46
  160. data/lib/rio/state/error.rb +3 -4
  161. data/lib/rio/stream.rb +4 -4
  162. data/lib/rio/stream/base.rb +3 -4
  163. data/lib/rio/stream/duplex.rb +3 -4
  164. data/lib/rio/stream/open.rb +3 -8
  165. data/lib/rio/symantics.rb +3 -4
  166. data/lib/rio/tempdir.rb +2 -2
  167. data/lib/rio/to_rio.rb +3 -4
  168. data/lib/rio/to_rio/all.rb +3 -4
  169. data/lib/rio/to_rio/array.rb +4 -5
  170. data/lib/rio/to_rio/io.rb +4 -5
  171. data/lib/rio/to_rio/object.rb +4 -5
  172. data/lib/rio/to_rio/string.rb +4 -5
  173. data/lib/rio/uri/file.rb +41 -5
  174. data/lib/rio/util.rb +3 -4
  175. data/lib/rio/version.rb +4 -5
  176. data/setup.rb +368 -339
  177. data/test/bin/list_dir.rb +1 -1
  178. data/test/ftp/anon_misc.rb +13 -1
  179. data/test/ftp/anon_special.rb +6 -6
  180. data/test/ftp/anon_write.rb +10 -3
  181. data/test/ftp/ftp2ftp.rb +2 -2
  182. data/test/ftp/testdef.rb +9 -6
  183. data/test/http/all.rb +3 -0
  184. data/test/http/copy-from-http.rb +140 -0
  185. data/test/lib/temp_server.rb +44 -0
  186. data/test/runalltests.rb +3 -1
  187. data/test/runhttp.rb +12 -0
  188. data/test/runhttptests.rb +1 -1
  189. data/test/runtests.rb +41 -3
  190. data/test/tc/abs.rb +9 -5
  191. data/test/tc/all.rb +9 -4
  192. data/test/tc/base.rb +1 -1
  193. data/test/tc/base2.rb +87 -0
  194. data/test/tc/{methods.rb → clone.rb} +72 -50
  195. data/test/tc/closeoncopy.rb +13 -2
  196. data/test/tc/copy-dir-samevar.rb +91 -0
  197. data/test/tc/dir_iter.rb +0 -1
  198. data/test/tc/empty.rb +6 -2
  199. data/test/tc/expand_path.rb +36 -54
  200. data/test/tc/ext.rb +42 -18
  201. data/test/tc/gzip.rb +30 -3
  202. data/test/tc/likeio.rb +5 -1
  203. data/test/tc/line_record_row.rb +51 -0
  204. data/test/tc/noqae.rb +71 -70
  205. data/test/tc/path_parts.rb +175 -0
  206. data/test/tc/programs_util.rb +3 -3
  207. data/test/tc/rename.rb +4 -5
  208. data/test/tc/riorl.rb +9 -7
  209. data/test/tc/skip.rb +35 -6
  210. data/test/tc/skiplines.rb +34 -5
  211. data/test/tc/split.rb +8 -50
  212. data/test/tc/splitlines.rb +65 -0
  213. data/test/tc/splitpath.rb +83 -0
  214. data/test/tc/testcase.rb +1 -1
  215. data/test/tc/truncate.rb +39 -0
  216. data/test/tc/yaml.rb +9 -8
  217. metadata +261 -207
  218. data/ChangeLog +0 -1418
  219. data/VERSION +0 -1
  220. data/lib/rio/doc/MISC.rb +0 -259
  221. data/lib/rio/if/stream.rb +0 -680
  222. data/lib/rio/impl/path.rb +0 -87
  223. data/test/tc/copy-from-http.rb +0 -89
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.8
@@ -1,259 +0,0 @@
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
-
38
- module RIO
39
- module Doc
40
- =begin rdoc
41
-
42
-
43
-
44
- The following example are provided without comment
45
-
46
- array = rio('afile').readlines
47
-
48
- rio('afile') > rio('acopy')
49
-
50
- ary = rio('afile').chomp.lines[0...10]
51
-
52
- rio('adir').rename.all.files('*.htm') do |file|
53
- file.ext = '.html'
54
- end
55
-
56
- A basic familiarity with ruby and shell operations should allow a casual reader to guess what
57
- these examples will do. How they are being performed may not be what a casual reader might expect.
58
- I will explain these example to illustrate the Rio basics.
59
-
60
- For many more examples please read the HOWTO document and the rdoc documentation.
61
-
62
- == Example 1.
63
-
64
- array = rio('afile').readlines
65
-
66
- This uses IO#readlines to read the lines of 'afile' into an array.
67
-
68
- === Creating a Rio
69
-
70
- Rio extends the module Kernel by adding one function _rio_, which acts as a constructor returning a Rio. This
71
- constructor builds a description of the resource the Rio will access (usually a path). It does not open the
72
- resource, check for its existance, or do anything except remember its specifcation. _rio_ returns the Rio
73
- which can be chained to a Rio method as in this example or stored in a variable. This coud have been written
74
-
75
- ario = rio('afile')
76
- array = ario.readlines
77
-
78
- ario = rio('afile')
79
-
80
- In this case the resource specified is a relative path. After the first line
81
- the Rio does know or care whether it
82
- is a path to a file nor whether it exists. Rio provides many methods that only deal with a resource
83
- at this level, much as the standard library classes Pathname and URI. It should be noted at this
84
- point that Rio paths stored internally as a URL as specified in RFC 1738 and therefore use slashes as
85
- separators. A resource can also be specified without separators, because _rio_ interprets multiple arguments
86
- as parts of a path to be joined, and an array as an array of parts to be joined. So the following
87
- all specify the same resource.
88
-
89
- rio('adir/afile')
90
- rio('adir','afile')
91
- rio(%w/adir afile/)
92
-
93
- The rio constructor can be used to specify non-file-system resources, but for this example we will restrict
94
- our discussion to paths to entities on file-systems.
95
-
96
- array = ario.readlines
97
-
98
- Now that we have a Rio, we can call one of its methods; in this case _readlines_. This is an example of using
99
- a Rio as a proxy for the builtin IO#readlines. Given the method _readlines_, the Rio opens 'afile' for reading,
100
- calls readlines on the resulting IO object, closes the IO object, and returns the lines read.
101
-
102
- == Example 2
103
-
104
- rio('afile') > rio('acopy')
105
-
106
- This copies the file 'afile' into the file 'acopy'.
107
-
108
- The first things that happen here are the creation of the Rios. As described in Example 1, when created
109
- a Rio simply remembers the specifcation of its resource. In this case, a relative path 'afile' on the
110
- left and a relative path 'acopy' on the right.
111
-
112
- Next the Rio#> (copy-to) method is called on the 'afile' Rio with the 'acopy' Rio as its argument. If that
113
- looks like a greater-than operator to you, think Unix shell, with Rios '>' is the copy-to operator.
114
-
115
- Upon seeing the copy-to operator, the Rio has all the information it needs to proceed. It determines that
116
- it must be opened for reading, that its argument must be opened for writing, and that it's contents must
117
- be copied to the resource referenced by it' argument -- and that is what it does. Then it closes itself and
118
- its argument.
119
-
120
- Consider if we had written this example this way.
121
-
122
- afile = rio('afile')
123
- acopy = rio('acopy')
124
- afile > acopy
125
-
126
- In this case we would still have variables referencing the Rios, and perhaps we would like do things a little
127
- differently than described above. Be assured that the selection of mode and automatic closing of files are the
128
- default behaviour and can be changed. Say we wanted 'afile' to remain open so that we could rewind it and make
129
- a second copy, we might do something like this:
130
-
131
- afile = rio('afile').nocloseoneof
132
- afile > rio('acopy1')
133
- afile.rewind > rio('acopy2')
134
- afile.close
135
-
136
- Actually the 'thinking process' of the Rio when it sees a copy-to operator is much more complex that described above.
137
- If its argument had been a rio referencing a directory, it would not have opened itself for reading,
138
- but instead used FileUtils#cp to copy itself; if its argument had been a string, its contents would have ended up
139
- in the string; If its argument had been an array, its lines would been elements of that array; if its argument had
140
- been a socket, the its contents would have been copied to the socket. See the documentation for details.
141
-
142
- == Example 3.
143
-
144
- array = rio('afile').chomp.lines[0...10]
145
-
146
- This fills +array+ with the first ten lines of 'afile', with each line chomped
147
-
148
- The casual observer mentioned above might think that +lines+ returns an array of lines and that this
149
- is a simple rewording of <tt>array = rio('afile').readlines[0...10]</tt> or even of
150
- <tt>array = File.new('afile').readlines[0...10]</tt>. They would be wrong.
151
-
152
- +chomp+ is a configuration method which turns on chomp-mode and returns the Rio. Chomp-mode causes all
153
- line oriented read operations to perform a String#chomp on each line
154
-
155
- === Reading files
156
-
157
- Rio provides four methods to select which part of the file is read and how the file is divided. They are +lines+,
158
- +records+, +rows+ and +bytes+. Briefly, +lines+ specifies that the file should be read line by line and +bytes(n)+
159
- specifies that the file should be read in _n_ byte chunks. All four take arguments which can be used to
160
- filter lines or chunks in or out. For simple Rios +records+ and +rows+ only specify the filter arguments and
161
- are provided for use be extensions. For example, the CSV extension returns an array of the columns in a line
162
- when +records+ is used. In the absence of an extension +records+ and +rows+ behave like +lines+.
163
-
164
- First lets rewrite our example as:
165
-
166
- array = rio('afile').chomp.lines(0...10).to_a
167
-
168
- The arguments to lines specify which records are to be read.
169
- Arguments are interpreted based on their class as follows:
170
- * Range - interpreted as a range of record numbers to be read
171
- * Integer - interpreted as a one-element range
172
- * RegExp - only matching records are processed
173
- * Symbol - sent to each record, which is processed unless the result is false or nil
174
- * Proc - called for each record, the record is processed unless the return value is false or nil
175
- See the documentation for details and examples.
176
-
177
- In our example we have specified the Range (0...10). The +lines+ method is just configuring the Rio, it does
178
- not trigger
179
- any IO operation. The fact that it was called and the arguments it was called with are stored away and the Rio
180
- is returned for further configuration or an actual IO operation. When an IO operation is called the Range will be
181
- used to limit processing to the first ten records. For example:
182
- rio('afile').lines(0...10).each { |line| ... } # block will be called for the first 10 records
183
- rio('afile').lines(0...10).to_a # the first 10 records will be returned in an array
184
- rio('afile').lines(0...10) > rio('acopy') # the first 10 records will be copied to 'acopy'
185
-
186
- "But wait", you say, "In our original example the range was an argument to the subscript operator, not to +lines+".
187
- This works because the subscript operator processes its arguments as if they had been arguments to the
188
- most-recently-called selection method and then calls +to_a+ on the rio. So our rewrite of the example
189
- does precisely the same thing as the original
190
-
191
- The big difference between the original example and the casual-observer's solution is that hers
192
- creates an array of the entire contents and only returns the first 10 while the original only puts
193
- 10 records into the array.
194
-
195
- As a sidenote, Rios also have an optimization that can really help in certain situations. If records are only
196
- selected using Ranges, it stops iterating when it is beyond the point where it could possibly ever match. This
197
- can make a dramatic difference when one is only interested in the first few lines of very large files.
198
-
199
- == Example 4.
200
-
201
- rio('adir').rename.all.files('*.htm') do |file|
202
- file.ext = '.html'
203
- end
204
-
205
- This changes the extension of all .htm files below 'adir' to '.html'
206
-
207
- First we create the rio as always.
208
-
209
- Next we process the +rename+ method. When used as it is here -- without arguments -- it just turns on rename-mode
210
- and returns the Rio.
211
-
212
- +all+ is another configuration method, which causes directories to be processed recursively
213
-
214
- +files+ is another configuration method. In example 3 we used +lines+ to select what to process when
215
- iterating through a file. +files+ is used to select what to process when iterating through
216
- directories. The arguments to +files+ can be the same as those for +lines+ except that Ranges can not
217
- be used and globs can.
218
-
219
- In our example, the argument to +files+ is a string which is treated as a glob. As with +lines+, +files+
220
- does not trigger any IO, it just configures the Rio.
221
-
222
- === There's no action
223
-
224
- The previous examples had something that triggered IO: +readlines+, +to_a+, +each+, <tt>> (copy-to)</tt>. This example
225
- does not. This example illustrates Rio's 'implied each'. All the configuration methods will call each for you
226
- if a block is given. So, because a block follows the files method, it calls +each+ and passes it the block.
227
-
228
- Let's recap. At this point we have a Rio with a resource specified. We have configured with a couple of modes,
229
- 'rename', and 'all', and we have limited the elements we want to process to entries that are files and
230
- match the glob '*.htm'. +each+ causes the Rio to open the directory and call the block for each entry that is
231
- both a file and matches the glob. It was also configured with +all+,so it descends into subdirectories to
232
- find further matches and calles the block for each of them. The argument passed to the block is a Rio
233
- referencing the entry on the file-system.
234
-
235
- The _rename_mode_ we set has had no effect on our iteration at all, so why is it there? In general,
236
- configuration options that are not applicable to a Rio are silently ignored, however, for directories
237
- some of them are passed on to the Rios for each entry when iterating. Since +rename+ is one such option,
238
- The example could have been written:
239
-
240
- rio('adir').all.files('*.htm') do |file|
241
- file.rename.ext = '.html'
242
- end
243
-
244
- The rename-with-no-args method affects the behaviour of the <tt>ext=</tt> option. In this case,
245
- setting it for the directory, rather than for each file in the block seems to make the intent
246
- of the code more clear, but that is a matter of personal taste. See the documentation for more
247
- information on the rename-with-no-args method
248
-
249
- == Suggested Reading
250
- * RIO::Doc::SYNOPSIS
251
- * RIO::Doc::INTRO
252
- * RIO::Doc::HOWTO
253
- * RIO::Rio
254
-
255
- =end
256
- module MISC
257
- end
258
- end
259
- end
@@ -1,680 +0,0 @@
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
-
38
- module RIO
39
- class Rio
40
- # Calls IO#gets
41
- #
42
- # Reads the next line from the Rio; lines are separated by sep_string.
43
- # A separator of nil reads the entire contents, and a zero-length separator reads
44
- # the input a paragraph at a time (two successive newlines in the input separate paragraphs).
45
- #
46
- # Returns nil if called at end of file.
47
- #
48
- # astring = rio('afile.txt').gets # read the first line of afile.txt into astring
49
- #
50
- def gets(sep_string=$/) target.gets(sep_string) end
51
-
52
- # Slurps the contents of the rio into a string.
53
- #
54
- # astring = rio('afile.txt').contents # slurp the entire contents of afile.txt into astring
55
- #
56
- def contents() target.contents() end
57
-
58
-
59
- # Rio#each_record
60
- #
61
- #
62
- #def each_record(&block) target.each_record(&block); self end
63
-
64
-
65
- # Rio#each_row
66
- #
67
- #
68
- #def each_row(&block) target.each_row(&block); self end
69
-
70
-
71
- # Calls IO#lineno
72
- #
73
- # Returns the current line number of a Rio.
74
- #
75
- # The Rio will be opened for reading if not already.
76
- # lineno counts the number of times gets is called, rather than the number of newlines encountered --
77
- # so lineno will only be accurate if the file is read exclusively with line-oriented methods
78
- # (Rio#readline, Rio#each_line, Rio#gets etc.)
79
- #
80
- # See also the $. variable and Rio#recno
81
- # f = rio("testfile")
82
- # f.lineno #=> 0
83
- # f.gets #=> "This is line one\n"
84
- # f.lineno #=> 1
85
- # f.gets #=> "This is line two\n"
86
- # f.lineno #=> 2
87
- def lineno() target.lineno() end
88
-
89
- # Calls IO#lineno=
90
- # ario.lineno = integer => integer
91
- # Manually sets the current line number to the given value. <tt>$.</tt> is
92
- # updated only on the next read.
93
- #
94
- # f = rio("testfile")
95
- # f.gets #=> "This is line one\n"
96
- # $. #=> 1
97
- # f.lineno = 1000
98
- # f.lineno #=> 1000
99
- # $. # lineno of last read #=> 1
100
- # f.gets #=> "This is line two\n"
101
- # $. # lineno of last read #=> 1001
102
- #
103
- #
104
- def lineno=(integer) target.lineno = integer end
105
-
106
- # Returns the current record number of a Rio. The +recno+ is the index
107
- # used by the grande selection methods. It represents the zero-based index of the
108
- # last record read. Returns nil until a record has been read.
109
- #
110
- # see Rio#lines Rio#bytes and Rio#records
111
- #
112
- # To illustrate: Given a file containing three lines "L0\n","L1\n","L2\n"
113
- # and a Range (0..1)
114
- # Each of the following would fill anarray with ["L0\n", "L1\n"]
115
- #
116
- # Given:
117
- # anarray = []
118
- # range = (0..1)
119
- #
120
- # all_lines = rio('afile').readlines
121
- # all_lines.each_with_index do |line,i|
122
- # anarray << line if range === i
123
- # end
124
- # # anarray == ["L0\n", "L1\n"]
125
- #
126
- # anarray = rio('afile').lines[0..1] # anarray == ["L0\n", "L1\n"]
127
- #
128
- # +recno+ counts the number of times Rio#getrec or Rio#each is used to get a record.
129
- # so +recno+ will only concern parts of the file read with grande methods
130
- # Rio#each, Rio#[], Rio#getrec
131
- #
132
- # See also Rio#lineno
133
- def recno() target.recno() end
134
-
135
-
136
- # Calls IO#binmode
137
- #
138
- # Puts rio into binary mode. This is useful only in MS-DOS/Windows environments.
139
- # Once a stream is in binary mode, it cannot be reset to nonbinary mode.
140
- #
141
- # Returns the Rio.
142
- #
143
- # rio('afile.exe').binmode.bytes(512).to_a # read a file in 512 byte blocks
144
- #
145
- def binmode() target.binmode(); self end
146
-
147
-
148
- # Calls IO#flush
149
- # ario.flush => ario
150
- # Flushes any buffered data within _ario_ to the underlying operating
151
- # system (note that this is Ruby internal buffering only; the OS may
152
- # buffer the data as well).
153
- #
154
- def flush() target.flush(); self end
155
-
156
-
157
- # Calls IO#each_byte
158
- # ario.each_byte {|byte| block } => ario
159
- # Calls the given block once for each byte (0..255) in _ario_, passing
160
- # the byte as an argument.
161
- #
162
- def each_byte(*args,&block) target.each_byte(*args,&block); self end
163
-
164
-
165
- # Rio#each_bytes
166
- #
167
- #
168
- #def each_bytes(nb,*args,&block) target.each_bytes(nb,*args,&block); self end
169
-
170
-
171
- # Calls IO#each_line
172
- # ario.each_line(sep_string=$/) {|line| block } => ario
173
- # Executes the block for every line in _ario_, where lines are
174
- # separated by _sep_string_.
175
- #
176
- def each_line(*args,&block) target.each_line(*args,&block); self end
177
-
178
-
179
- # Calls IO#readlines
180
- #
181
- # Reads all of the lines in a Rio, and returns them in anArray.
182
- # Lines are separated by the optional aSepString.
183
- # The stream must be opened for reading or an IOerror will be raised.
184
- #
185
- # an_array = rio('afile.txt').readlines # read afile.txt into an array
186
- # an_array = rio('afile.txt').chomp.readlines # read afile.txt into an array with each line chomped
187
- #
188
- def readlines(*args,&block) target.readlines(*args,&block) end
189
-
190
- # Calls IO#readline
191
- # ario.readline(sep_string=$/) => string
192
- # Reads a line as with +IO#gets+, but raises an +EOFError+ on end of
193
- # file.
194
- #
195
- def readline(*args) target.readline(*args) end
196
-
197
-
198
- # Calls IO#readpartial
199
- #
200
- # Reads at most maxlen bytes from the I/O stream but it blocks
201
- # only if ios has no data immediately available. If the optional
202
- # outbuf argument is present, it must reference a String, which
203
- # will receive the data. It raises EOFError on end of file.
204
- #
205
- # readpartial is designed for streams such as pipe, socket, tty, etc. It
206
- # blocks only when no data immediately available. This means that it
207
- # blocks only when following all conditions hold.
208
- #
209
- # * the buffer in the IO object is empty.
210
- # * the content of the stream is empty.
211
- # * the stream is not reached to EOF.
212
- #
213
- # When readpartial blocks, it waits data or EOF on the stream. If some
214
- # data is reached, readpartial returns with the data. If EOF is reached,
215
- # readpartial raises EOFError.
216
- #
217
- # When readpartial doesn�t blocks, it returns or raises immediately. If
218
- # the buffer is not empty, it returns the data in the buffer. Otherwise
219
- # if the stream has some content, it returns the data in the
220
- # stream. Otherwise if the stream is reached to EOF, it raises EOFError.
221
- #
222
- # r, w = IO.pipe # buffer pipe content
223
- # w << "abc" # "" "abc".
224
- # r.readpartial(4096) #=> "abc" "" ""
225
- # r.readpartial(4096) # blocks because buffer and pipe is empty.
226
- #
227
- # r, w = IO.pipe # buffer pipe content
228
- # w << "abc" # "" "abc"
229
- # w.close # "" "abc" EOF
230
- # r.readpartial(4096) #=> "abc" "" EOF
231
- # r.readpartial(4096) # raises EOFError
232
- #
233
- # r, w = IO.pipe # buffer pipe content
234
- # w << "abc\ndef\n" # "" "abc\ndef\n"
235
- # r.gets #=> "abc\n" "def\n" ""
236
- # w << "ghi\n" # "def\n" "ghi\n"
237
- # r.readpartial(4096) #=> "def\n" "" "ghi\n"
238
- # r.readpartial(4096) #=> "ghi\n" "" ""
239
- #
240
- # Note that readpartial is nonblocking-flag insensitive. It blocks even
241
- # if the nonblocking-flag is set.
242
- #
243
- # Also note that readpartial behaves similar to sysread in blocking
244
- # mode. The behavior is identical when the buffer is empty.
245
- # ios.reopen(other_IO) => ios ios.reopen(path, mode_str) => ios
246
- #
247
- # Reassociates ios with the I/O stream given in other_IO or to a new
248
- # stream opened on path. This may dynamically change the actual class of
249
- # this stream.
250
- #
251
- # f1 = File.new("testfile")
252
- # f2 = File.new("testfile")
253
- # f2.readlines[0] #=> "This is line one\n"
254
- # f2.reopen(f1) #=> #<File:testfile>
255
- # f2.readlines[0] #=> "This is line one\n"
256
- #
257
- def readpartial(*args) target.readpartial(*args) end
258
-
259
-
260
- # Calls IO::print
261
- #
262
- # Writes the given object(s) to the Rio. If the output record separator ($\) is not nil,
263
- # it will be appended to the output. If no arguments are given, prints $_.
264
- # Objects that aren't strings will be converted by calling their to_s method.
265
- # Returns the Rio.
266
- #
267
- # rio('f.txt').print("Hello Rio\n") # print the string to f.txt
268
- # rio(?-).print("Hello Rio\n") # print the string to stdout
269
- #
270
- def print(*args,&block) target.print(*args,&block); self end
271
-
272
- # Writes the given objects to the rio as with Rio#print and then closes the Rio.
273
- # Returns the Rio.
274
- #
275
- # Equivalent to rio.print(*args).close
276
- #
277
- # rio('f.txt').print!("Hello Rio\n") # print the string to f.txt then close it
278
- #
279
- def print!(*args,&block) target.print!(*args,&block); self end
280
-
281
-
282
- # Writes the given objects to the rio as with Rio#printf and then closes the rio.
283
- # Returns the rio.
284
- #
285
- # Equivalent to rio.printf(*args).close
286
- #
287
- def printf!(*argv) target.printf!(*argv); self end
288
-
289
-
290
- # Calls IO#printf
291
- # ario.printf(format_string [, obj, ...] ) => ario
292
- # Formats and writes to _ario_, converting parameters under control of
293
- # the format string. See +Kernel#sprintf+ for details.
294
- #
295
- def printf(*argv) target.printf(*argv); self end
296
-
297
-
298
- # Writes the given objects to the rio as with Rio#putc and then closes the rio.
299
- # Returns the rio.
300
- #
301
- # Equivalent to rio.putc(*args).close
302
- #
303
- def putc!(*argv) target.putc!(*argv); self end
304
-
305
-
306
- # Calls IO#putc
307
- # ario.putc(obj) => ario
308
- # If _obj_ is +Numeric+, write the character whose code is _obj_,
309
- # otherwise write the first character of the string representation of
310
- # _obj_ to _ario_.
311
- #
312
- # stdout = rio(?-)
313
- # stdout.putc "A"
314
- # stdout.putc 65
315
- #
316
- # _produces:_
317
- #
318
- # AA
319
- #
320
- def putc(*argv) target.putc(*argv); self end
321
-
322
-
323
- # Calls IO#puts
324
- #
325
- # Writes the given objects to the rio as with Rio#print.
326
- # Writes a record separator (typically a newline) after any that do not already end with a newline sequence.
327
- # If called with an array argument, writes each element on a new line.
328
- # If called without arguments, outputs a single record separator.
329
- # Returns the rio.
330
- def puts(*args) target.puts(*args); self end
331
-
332
- # Writes the given objects to the rio as with Rio#puts and then closes the rio.
333
- # Returns the rio.
334
- #
335
- # Equivalent to rio.puts(*args).close
336
- #
337
- # rio('f.txt').puts!('Hello Rio') # print the string to f.txt then close it
338
- #
339
- def puts!(*args) target.puts!(*args); self end
340
-
341
-
342
- # Writes the given objects to the rio as with Rio#write and then closes the rio.
343
- #
344
- # Equivalent to
345
- # ario.write(*args)
346
- # ario.close
347
- #
348
- def write!(*argv) target.write!(*argv) end
349
-
350
-
351
- # Calls IO#write
352
- # ario.write(string) => integer
353
- # Writes the given string to _ario_. If the argument is not a string,
354
- # it will be converted to a
355
- # string using +to_s+. Returns the number of bytes written.
356
- #
357
- def write(*argv) target.write(*argv) end
358
-
359
-
360
- # Calls IO#eof?
361
- # ario.eof => true or false
362
- # Returns true if _ario_ is at end of file. The stream must be opened
363
- # for reading or an +IOError+ will be raised.
364
- #
365
- def eof?() target.eof? end
366
-
367
- # Provides direct access to the IO handle (as would be returned by ::IO#new) *with* filtering.
368
- # Reading from and writing to this handle will be affected
369
- # by such things as Rio#gzip and Rio#chomp if they were specified for the Rio.
370
- #
371
- # Compare this with Rio#ios
372
- #
373
- def ioh(*args) target.ioh() end
374
-
375
- # Provides direct access to the IO handle (as would be returned by ::IO#new)
376
- # Reading from and writing to this handle
377
- # is *not* affected by such things as Rio#gzip and Rio#chomp.
378
- #
379
- # Compare this with Rio#ioh
380
- #
381
- def ios(*args) target.ios() end
382
-
383
- #def open(m,*args) target.open(m,*args); self end
384
-
385
- # Explicitly set the mode with which a Rio will be opened.
386
- # ario.mode('r+') => ario
387
- # Normally one needs never open a Rio or specify its mode -- the mode is determined by the
388
- # operation the Rio is asked to perform. (i.e. Rio#print requires write access, Rio#readlines requires
389
- # read access). However there are times when one wishes to be specific about the mode with which a Rio
390
- # will be opened. Note that explicitly setting the mode overrides all of Rio's internal mode
391
- # logic. If a mode is specified via Rio#mode or Rio#open that mode will be used. Period.
392
- #
393
- # Returns the Rio.
394
- #
395
- # See also Rio#mode?
396
- #
397
- # If the mode is given as a String, it must be one of the values listed in the following table.
398
- #
399
- # Mode | Meaning
400
- # -----+--------------------------------------------------------
401
- # "r" | Read-only, starts at beginning of file (default mode).
402
- # -----+--------------------------------------------------------
403
- # "r+" | Read-write, starts at beginning of file.
404
- # -----+--------------------------------------------------------
405
- # "w" | Write-only, truncates existing file
406
- # | to zero length or creates a new file for writing.
407
- # -----+--------------------------------------------------------
408
- # "w+" | Read-write, truncates existing file to zero length
409
- # | or creates a new file for reading and writing.
410
- # -----+--------------------------------------------------------
411
- # "a" | Write-only, starts at end of file if file exists,
412
- # | otherwise creates a new file for writing.
413
- # -----+--------------------------------------------------------
414
- # "a+" | Read-write, starts at end of file if file exists,
415
- # | otherwise creates a new file for reading and
416
- # | writing.
417
- # -----+--------------------------------------------------------
418
- # "b" | (DOS/Windows only) Binary file mode (may appear with
419
- # | any of the key letters listed above).
420
- #
421
- # ario = rio('afile').mode('r+').nocloseoneof # file will be opened in r+ mode
422
- # # don't want the file closed at eof
423
- # ario.seek(apos).gets # read the string at apos in afile
424
- # ario.rewind.gets # read the string at the beginning of the file
425
- # ario.close
426
- #
427
- # TODO:
428
- # * Add support for integer modes
429
- #
430
- def mode(m,*args) target.mode(m,*args); self end
431
-
432
- # Query a Rio's mode
433
- # ario.mode? #=> a mode string
434
- #
435
- # See Rio#mode
436
- #
437
- # ario = rio('afile')
438
- # ario.puts("Hello World")
439
- # ario.mode? #=> 'w' Rio#puts requires write access
440
- #
441
- # ario = rio('afile')
442
- # ario.gets
443
- # ario.mode? #=> 'r' Rio#gets requires read access
444
- #
445
- # ario = rio('afile').mode('w+').nocloseoneof
446
- # ario.gets
447
- # ario.mode? #=> 'w+' Set explictly
448
- #
449
- def mode?() target.mode?() end
450
-
451
-
452
-
453
- # Calls IO#close
454
- # ario.close => nil
455
- # Closes _ario_ and flushes any pending writes to the operating
456
- # system. The stream is unavailable for any further data operations;
457
- # an +IOError+ is raised if such an attempt is made. I/O streams are
458
- # automatically closed when they are claimed by the garbage
459
- # collector.
460
- #
461
- def close() target.close(); self end
462
-
463
- # Calls IO#fcntl
464
- # ario.fcntl(integer_cmd, arg) => integer
465
- # Provides a mechanism for issuing low-level commands to control or
466
- # query file-oriented I/O streams. Arguments and results are platform
467
- # dependent. If _arg_ is a number, its value is passed directly. If
468
- # it is a string, it is interpreted as a binary sequence of bytes
469
- # (<tt>Array#pack</tt> might be a useful way to build this string). On Unix
470
- # platforms, see <tt>fcntl(2)</tt> for details. Not implemented on all
471
- # platforms.
472
- #
473
- #
474
- def fcntl(integer_cmd,arg) target.fcntl(integer_cmd,arg) end
475
-
476
- # Calls IO#ioctl
477
- # ario.ioctl(integer_cmd, arg) => integer
478
- # Provides a mechanism for issuing low-level commands to control or
479
- # query I/O devices. Arguments and results are platform dependent. If
480
- # _arg_ is a number, its value is passed directly. If it is a string,
481
- # it is interpreted as a binary sequence of bytes. On Unix platforms,
482
- # see +ioctl(2)+ for details. Not implemented on all platforms.
483
- #
484
- #
485
- def ioctl(integer_cmd,arg) target.ioctl(integer_cmd,arg) end
486
-
487
- # Calls IO#fileno
488
- # ario.fileno => fixnum
489
- # ario.to_i => fixnum
490
- # Returns an integer representing the numeric file descriptor for
491
- # _ario_.
492
- #
493
- def fileno() target.fileno() end
494
-
495
-
496
- # Calls IO#fsync
497
- # ario.fsync => ario
498
- # Immediately writes all buffered data in _ario_ to disk and
499
- # return _ario_.
500
- # Does nothing if the underlying operating system does not support
501
- # _fsync(2)_. Note that +fsync+ differs from using Rio#sync. The
502
- # latter ensures that data is flushed from Ruby's buffers, but
503
- # doesn't not guarantee that the underlying operating system actually
504
- # writes it to disk.
505
- #
506
- def fsync() target.fsync end
507
-
508
- # Calls IO#pid
509
- # ario.pid => fixnum
510
- # Returns the process ID of a child process associated with _ario_.
511
- # This will be set by <tt>IO::popen</tt>.
512
- #
513
- # pipe = IO.popen("-")
514
- # if pipe
515
- # $stderr.puts "In parent, child pid is #{pipe.pid}"
516
- # else
517
- # $stderr.puts "In child, pid is #{$$}"
518
- # end
519
- #
520
- # produces:
521
- #
522
- # In child, pid is 26209
523
- # In parent, child pid is 26209
524
- #
525
- #
526
- def pid() target.pid end
527
-
528
-
529
- # Calls IO#putc
530
- # ario.putc(obj) => obj
531
- # If _obj_ is +Numeric+, write the character whose code is _obj_,
532
- # otherwise write the first character of the string representation of
533
- # _obj_ to _ario_.
534
- #
535
- # $stdout.putc "A"
536
- # $stdout.putc 65
537
- #
538
- # _produces:_
539
- #
540
- # AA
541
- #
542
- #
543
-
544
-
545
- # Calls IO#getc
546
- # ario.getc => fixnum or nil
547
- # Gets the next 8-bit byte (0..255) from _ario_. Returns +nil+ if
548
- # called at end of file.
549
- #
550
- # f = File.new("testfile")
551
- # f.getc #=> 84
552
- # f.getc #=> 104
553
- #
554
- #
555
- def getc() target.getc() end
556
-
557
- # Calls IO#readchar
558
- # ario.readchar => fixnum
559
- # Reads a character as with +IO#getc+, but raises an +EOFError+ on
560
- # end of file.
561
- #
562
- #
563
-
564
- # Calls IO#reopen
565
- # ario.reopen(other_IO) => ios
566
- # ario.reopen(path, mode_str) => ios
567
- # Reassociates _ario_ with the I/O stream given in _other_IO_ or to a
568
- # new stream opened on _path_. This may dynamically change the actual
569
- # class of this stream.
570
- #
571
- # f1 = File.new("testfile")
572
- # f2 = File.new("testfile")
573
- # f2.readlines[0] #=> "This is line one\n"
574
- # f2.reopen(f1) #=> #<File:testfile>
575
- # f2.readlines[0] #=> "This is line one\n"
576
- #
577
- #
578
- #def reopen(m) target.reopen(m) end
579
-
580
-
581
- # Calls IO#stat
582
- # ario.stat => stat
583
- # Returns status information for _ario_ as an object of type
584
- # +File::Stat+.
585
- #
586
- # f = File.new("testfile")
587
- # s = f.stat
588
- # "%o" % s.mode #=> "100644"
589
- # s.blksize #=> 4096
590
- # s.atime #=> Wed Apr 09 08:53:54 CDT 2003
591
- #
592
- #
593
-
594
- # Calls IO#to_i
595
- # to_i()
596
- # Alias for #fileno
597
- #
598
- #
599
- def to_i() target.to_i() end
600
-
601
- # Calls IO#to_io
602
- # ario.to_io -> ios
603
- # Returns _ario_.
604
- #
605
- #
606
- def to_io() target.to_io() end
607
-
608
- # Calls IO#tty?
609
- # ario.tty? => true or false
610
- # Returns +true+ if _ario_ is associated with a terminal device (tty),
611
- # +false+ otherwise.
612
- #
613
- # rio("testfile").tty? #=> false
614
- # rio("/dev/tty").tty? #=> true
615
- #
616
- #
617
- def tty?() target.tty?() end
618
-
619
- # Calls IO#ungetc
620
- # ario.ungetc(integer) => ario
621
- # Pushes back one character (passed as a parameter) onto _ario_, such
622
- # that a subsequent buffered read will return it. Only one character
623
- # may be pushed back before a subsequent read operation (that is, you
624
- # will be able to read only the last of several characters that have
625
- # been pushed back).
626
- #
627
- # f = rio("testfile") #=> #<Rio:testfile>
628
- # c = f.getc #=> 84
629
- # f.ungetc(c).getc #=> 84
630
- #
631
- def ungetc(*args) target.ungetc(*args); self end
632
-
633
- # Sets the 'sync-mode' of the underlying IO using IO#sync=
634
- # ario.sync(boolean=true,&block) => ario
635
- # Sets the Rio so that its 'sync mode' will be set to +true+ or +false+ when opened, or set
636
- # it immediately if already open. When sync mode is
637
- # true, all output is immediately flushed to the underlying operating
638
- # system and is not buffered internally. Returns the rio. See
639
- # also Rio#fsync, Rio#nosync, Rio#sync?.
640
- #
641
- # If a block is given behaves like <tt>ario.sync(arg).each(&block)</tt>
642
- #
643
- # f = rio("testfile").sync.puts("Hello World")
644
- # f.sync? # => true
645
- #
646
- def sync(arg=true,&block) target.sync(arg,&block); self end
647
-
648
- # Similar to IO#sync= false
649
- # ario.nosync(&block) => ario
650
- # Sets the Rio so that its 'sync mode' will be set to +false+ when opened, or set
651
- # it immediately if already open. When sync mode is
652
- # true, all output is immediately flushed to the underlying operating
653
- # system and is not buffered internally. Returns the rio. See
654
- # also Rio#fsync, Rio#sync, Rio#sync?.
655
- #
656
- # If a block is given behaves like <tt>ario.nosync.each(&block)</tt>
657
- #
658
- # f = rio("testfile").sync.puts("Hello World")
659
- # f.sync? # => true
660
- # f.nosync
661
- # f.sync? # => false
662
- #
663
- def nosync(arg=false,&block) target.nosync(arg,&block); self end
664
-
665
- # Query the current "sync mode" with IO#sync
666
- # ario.sync? => true or false
667
- # Returns the current "sync mode" of _ario_. When sync mode is true,
668
- # all output is immediately flushed to the underlying operating
669
- # system and is not buffered by Ruby internally. See also Rio#fsync,
670
- # Rio#sync, Rio#nosync
671
- #
672
- # f = rio("testfile")
673
- # f.sync? #=> false
674
- #
675
- def sync?() target.sync?() end
676
-
677
-
678
-
679
- end
680
- end