rio 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. data/ChangeLog +49 -0
  2. data/VERSION +1 -1
  3. data/doc/ANNOUNCE +19 -2
  4. data/doc/RELEASE_NOTES +17 -0
  5. data/ex/colx.rb +3 -1
  6. data/ex/passwd_report.rb +12 -0
  7. data/lib/rio.rb +8 -9
  8. data/lib/rio/argv.rb +0 -4
  9. data/lib/rio/base.rb +3 -1
  10. data/lib/rio/doc/INTRO.rb +74 -1
  11. data/lib/rio/ext/csv.rb +34 -5
  12. data/lib/rio/factory.rb +2 -2
  13. data/lib/rio/if.rb +3 -0
  14. data/lib/rio/if/csv.rb +76 -0
  15. data/lib/rio/if/dir.rb +14 -6
  16. data/lib/rio/if/fileordir.rb +6 -0
  17. data/lib/rio/if/grande.rb +28 -0
  18. data/lib/rio/if/internal.rb +75 -2
  19. data/lib/rio/if/methods.rb +4 -3
  20. data/lib/rio/if/string.rb +46 -0
  21. data/lib/rio/if/temp.rb +46 -0
  22. data/lib/rio/matchcolumns.rb +266 -0
  23. data/lib/rio/rangemath.rb +44 -0
  24. data/lib/rio/scheme/temp.rb +4 -1
  25. data/lib/rio/version.rb +1 -1
  26. data/test/tc/all.rb +4 -1
  27. data/test/tc/copy-from.rb +1 -1
  28. data/test/tc/csv2.rb +135 -0
  29. data/test/tc/csv_columns.rb +37 -0
  30. data/test/tc/csvutil.rb +56 -0
  31. data/test/tc/ext.rb +1 -1
  32. data/test/tc/methods.rb +1 -1
  33. data/test/tc/tempfile.rb +17 -0
  34. metadata +11 -228
  35. data/doc/rdoc/classes/Kernel.html +0 -181
  36. data/doc/rdoc/classes/Kernel.src/M000182.html +0 -18
  37. data/doc/rdoc/classes/RIO.html +0 -543
  38. data/doc/rdoc/classes/RIO.src/M000001.html +0 -18
  39. data/doc/rdoc/classes/RIO.src/M000002.html +0 -18
  40. data/doc/rdoc/classes/RIO.src/M000003.html +0 -18
  41. data/doc/rdoc/classes/RIO/Doc.html +0 -138
  42. data/doc/rdoc/classes/RIO/Doc/HOWTO.html +0 -1035
  43. data/doc/rdoc/classes/RIO/Doc/INTRO.html +0 -1335
  44. data/doc/rdoc/classes/RIO/Doc/MISC.html +0 -443
  45. data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +0 -355
  46. data/doc/rdoc/classes/RIO/Rio.html +0 -6358
  47. data/doc/rdoc/classes/RIO/Rio.src/M000004.html +0 -18
  48. data/doc/rdoc/classes/RIO/Rio.src/M000005.html +0 -20
  49. data/doc/rdoc/classes/RIO/Rio.src/M000006.html +0 -27
  50. data/doc/rdoc/classes/RIO/Rio.src/M000007.html +0 -27
  51. data/doc/rdoc/classes/RIO/Rio.src/M000008.html +0 -16
  52. data/doc/rdoc/classes/RIO/Rio.src/M000009.html +0 -18
  53. data/doc/rdoc/classes/RIO/Rio.src/M000010.html +0 -20
  54. data/doc/rdoc/classes/RIO/Rio.src/M000011.html +0 -16
  55. data/doc/rdoc/classes/RIO/Rio.src/M000012.html +0 -16
  56. data/doc/rdoc/classes/RIO/Rio.src/M000013.html +0 -16
  57. data/doc/rdoc/classes/RIO/Rio.src/M000014.html +0 -16
  58. data/doc/rdoc/classes/RIO/Rio.src/M000015.html +0 -16
  59. data/doc/rdoc/classes/RIO/Rio.src/M000016.html +0 -16
  60. data/doc/rdoc/classes/RIO/Rio.src/M000017.html +0 -16
  61. data/doc/rdoc/classes/RIO/Rio.src/M000018.html +0 -16
  62. data/doc/rdoc/classes/RIO/Rio.src/M000019.html +0 -16
  63. data/doc/rdoc/classes/RIO/Rio.src/M000020.html +0 -16
  64. data/doc/rdoc/classes/RIO/Rio.src/M000021.html +0 -16
  65. data/doc/rdoc/classes/RIO/Rio.src/M000022.html +0 -16
  66. data/doc/rdoc/classes/RIO/Rio.src/M000023.html +0 -16
  67. data/doc/rdoc/classes/RIO/Rio.src/M000024.html +0 -16
  68. data/doc/rdoc/classes/RIO/Rio.src/M000025.html +0 -16
  69. data/doc/rdoc/classes/RIO/Rio.src/M000026.html +0 -16
  70. data/doc/rdoc/classes/RIO/Rio.src/M000027.html +0 -16
  71. data/doc/rdoc/classes/RIO/Rio.src/M000028.html +0 -16
  72. data/doc/rdoc/classes/RIO/Rio.src/M000029.html +0 -16
  73. data/doc/rdoc/classes/RIO/Rio.src/M000030.html +0 -16
  74. data/doc/rdoc/classes/RIO/Rio.src/M000031.html +0 -16
  75. data/doc/rdoc/classes/RIO/Rio.src/M000032.html +0 -16
  76. data/doc/rdoc/classes/RIO/Rio.src/M000033.html +0 -16
  77. data/doc/rdoc/classes/RIO/Rio.src/M000034.html +0 -16
  78. data/doc/rdoc/classes/RIO/Rio.src/M000035.html +0 -16
  79. data/doc/rdoc/classes/RIO/Rio.src/M000036.html +0 -16
  80. data/doc/rdoc/classes/RIO/Rio.src/M000037.html +0 -16
  81. data/doc/rdoc/classes/RIO/Rio.src/M000038.html +0 -16
  82. data/doc/rdoc/classes/RIO/Rio.src/M000039.html +0 -16
  83. data/doc/rdoc/classes/RIO/Rio.src/M000040.html +0 -16
  84. data/doc/rdoc/classes/RIO/Rio.src/M000041.html +0 -16
  85. data/doc/rdoc/classes/RIO/Rio.src/M000042.html +0 -16
  86. data/doc/rdoc/classes/RIO/Rio.src/M000043.html +0 -16
  87. data/doc/rdoc/classes/RIO/Rio.src/M000044.html +0 -16
  88. data/doc/rdoc/classes/RIO/Rio.src/M000045.html +0 -16
  89. data/doc/rdoc/classes/RIO/Rio.src/M000046.html +0 -16
  90. data/doc/rdoc/classes/RIO/Rio.src/M000047.html +0 -16
  91. data/doc/rdoc/classes/RIO/Rio.src/M000048.html +0 -16
  92. data/doc/rdoc/classes/RIO/Rio.src/M000049.html +0 -16
  93. data/doc/rdoc/classes/RIO/Rio.src/M000050.html +0 -16
  94. data/doc/rdoc/classes/RIO/Rio.src/M000051.html +0 -16
  95. data/doc/rdoc/classes/RIO/Rio.src/M000052.html +0 -16
  96. data/doc/rdoc/classes/RIO/Rio.src/M000053.html +0 -16
  97. data/doc/rdoc/classes/RIO/Rio.src/M000054.html +0 -16
  98. data/doc/rdoc/classes/RIO/Rio.src/M000055.html +0 -16
  99. data/doc/rdoc/classes/RIO/Rio.src/M000056.html +0 -16
  100. data/doc/rdoc/classes/RIO/Rio.src/M000057.html +0 -16
  101. data/doc/rdoc/classes/RIO/Rio.src/M000058.html +0 -16
  102. data/doc/rdoc/classes/RIO/Rio.src/M000059.html +0 -16
  103. data/doc/rdoc/classes/RIO/Rio.src/M000060.html +0 -16
  104. data/doc/rdoc/classes/RIO/Rio.src/M000061.html +0 -16
  105. data/doc/rdoc/classes/RIO/Rio.src/M000062.html +0 -16
  106. data/doc/rdoc/classes/RIO/Rio.src/M000063.html +0 -16
  107. data/doc/rdoc/classes/RIO/Rio.src/M000064.html +0 -16
  108. data/doc/rdoc/classes/RIO/Rio.src/M000065.html +0 -16
  109. data/doc/rdoc/classes/RIO/Rio.src/M000066.html +0 -16
  110. data/doc/rdoc/classes/RIO/Rio.src/M000067.html +0 -16
  111. data/doc/rdoc/classes/RIO/Rio.src/M000068.html +0 -16
  112. data/doc/rdoc/classes/RIO/Rio.src/M000069.html +0 -16
  113. data/doc/rdoc/classes/RIO/Rio.src/M000070.html +0 -16
  114. data/doc/rdoc/classes/RIO/Rio.src/M000071.html +0 -16
  115. data/doc/rdoc/classes/RIO/Rio.src/M000072.html +0 -16
  116. data/doc/rdoc/classes/RIO/Rio.src/M000073.html +0 -16
  117. data/doc/rdoc/classes/RIO/Rio.src/M000074.html +0 -16
  118. data/doc/rdoc/classes/RIO/Rio.src/M000075.html +0 -16
  119. data/doc/rdoc/classes/RIO/Rio.src/M000076.html +0 -16
  120. data/doc/rdoc/classes/RIO/Rio.src/M000077.html +0 -16
  121. data/doc/rdoc/classes/RIO/Rio.src/M000078.html +0 -16
  122. data/doc/rdoc/classes/RIO/Rio.src/M000079.html +0 -16
  123. data/doc/rdoc/classes/RIO/Rio.src/M000080.html +0 -16
  124. data/doc/rdoc/classes/RIO/Rio.src/M000081.html +0 -16
  125. data/doc/rdoc/classes/RIO/Rio.src/M000082.html +0 -16
  126. data/doc/rdoc/classes/RIO/Rio.src/M000083.html +0 -16
  127. data/doc/rdoc/classes/RIO/Rio.src/M000084.html +0 -16
  128. data/doc/rdoc/classes/RIO/Rio.src/M000085.html +0 -16
  129. data/doc/rdoc/classes/RIO/Rio.src/M000086.html +0 -16
  130. data/doc/rdoc/classes/RIO/Rio.src/M000087.html +0 -16
  131. data/doc/rdoc/classes/RIO/Rio.src/M000088.html +0 -16
  132. data/doc/rdoc/classes/RIO/Rio.src/M000089.html +0 -16
  133. data/doc/rdoc/classes/RIO/Rio.src/M000090.html +0 -16
  134. data/doc/rdoc/classes/RIO/Rio.src/M000091.html +0 -16
  135. data/doc/rdoc/classes/RIO/Rio.src/M000092.html +0 -16
  136. data/doc/rdoc/classes/RIO/Rio.src/M000093.html +0 -16
  137. data/doc/rdoc/classes/RIO/Rio.src/M000094.html +0 -16
  138. data/doc/rdoc/classes/RIO/Rio.src/M000095.html +0 -16
  139. data/doc/rdoc/classes/RIO/Rio.src/M000096.html +0 -16
  140. data/doc/rdoc/classes/RIO/Rio.src/M000097.html +0 -16
  141. data/doc/rdoc/classes/RIO/Rio.src/M000098.html +0 -16
  142. data/doc/rdoc/classes/RIO/Rio.src/M000099.html +0 -16
  143. data/doc/rdoc/classes/RIO/Rio.src/M000100.html +0 -16
  144. data/doc/rdoc/classes/RIO/Rio.src/M000101.html +0 -16
  145. data/doc/rdoc/classes/RIO/Rio.src/M000102.html +0 -16
  146. data/doc/rdoc/classes/RIO/Rio.src/M000103.html +0 -16
  147. data/doc/rdoc/classes/RIO/Rio.src/M000104.html +0 -16
  148. data/doc/rdoc/classes/RIO/Rio.src/M000105.html +0 -16
  149. data/doc/rdoc/classes/RIO/Rio.src/M000106.html +0 -16
  150. data/doc/rdoc/classes/RIO/Rio.src/M000107.html +0 -16
  151. data/doc/rdoc/classes/RIO/Rio.src/M000108.html +0 -16
  152. data/doc/rdoc/classes/RIO/Rio.src/M000109.html +0 -16
  153. data/doc/rdoc/classes/RIO/Rio.src/M000110.html +0 -16
  154. data/doc/rdoc/classes/RIO/Rio.src/M000111.html +0 -16
  155. data/doc/rdoc/classes/RIO/Rio.src/M000112.html +0 -16
  156. data/doc/rdoc/classes/RIO/Rio.src/M000113.html +0 -16
  157. data/doc/rdoc/classes/RIO/Rio.src/M000114.html +0 -16
  158. data/doc/rdoc/classes/RIO/Rio.src/M000115.html +0 -16
  159. data/doc/rdoc/classes/RIO/Rio.src/M000116.html +0 -16
  160. data/doc/rdoc/classes/RIO/Rio.src/M000117.html +0 -16
  161. data/doc/rdoc/classes/RIO/Rio.src/M000118.html +0 -16
  162. data/doc/rdoc/classes/RIO/Rio.src/M000119.html +0 -16
  163. data/doc/rdoc/classes/RIO/Rio.src/M000120.html +0 -16
  164. data/doc/rdoc/classes/RIO/Rio.src/M000121.html +0 -16
  165. data/doc/rdoc/classes/RIO/Rio.src/M000122.html +0 -16
  166. data/doc/rdoc/classes/RIO/Rio.src/M000123.html +0 -16
  167. data/doc/rdoc/classes/RIO/Rio.src/M000124.html +0 -16
  168. data/doc/rdoc/classes/RIO/Rio.src/M000125.html +0 -16
  169. data/doc/rdoc/classes/RIO/Rio.src/M000126.html +0 -16
  170. data/doc/rdoc/classes/RIO/Rio.src/M000127.html +0 -16
  171. data/doc/rdoc/classes/RIO/Rio.src/M000128.html +0 -16
  172. data/doc/rdoc/classes/RIO/Rio.src/M000129.html +0 -16
  173. data/doc/rdoc/classes/RIO/Rio.src/M000130.html +0 -16
  174. data/doc/rdoc/classes/RIO/Rio.src/M000131.html +0 -16
  175. data/doc/rdoc/classes/RIO/Rio.src/M000132.html +0 -16
  176. data/doc/rdoc/classes/RIO/Rio.src/M000133.html +0 -16
  177. data/doc/rdoc/classes/RIO/Rio.src/M000134.html +0 -16
  178. data/doc/rdoc/classes/RIO/Rio.src/M000135.html +0 -16
  179. data/doc/rdoc/classes/RIO/Rio.src/M000136.html +0 -16
  180. data/doc/rdoc/classes/RIO/Rio.src/M000137.html +0 -16
  181. data/doc/rdoc/classes/RIO/Rio.src/M000138.html +0 -16
  182. data/doc/rdoc/classes/RIO/Rio.src/M000139.html +0 -16
  183. data/doc/rdoc/classes/RIO/Rio.src/M000140.html +0 -16
  184. data/doc/rdoc/classes/RIO/Rio.src/M000141.html +0 -16
  185. data/doc/rdoc/classes/RIO/Rio.src/M000142.html +0 -16
  186. data/doc/rdoc/classes/RIO/Rio.src/M000143.html +0 -16
  187. data/doc/rdoc/classes/RIO/Rio.src/M000144.html +0 -16
  188. data/doc/rdoc/classes/RIO/Rio.src/M000145.html +0 -16
  189. data/doc/rdoc/classes/RIO/Rio.src/M000146.html +0 -16
  190. data/doc/rdoc/classes/RIO/Rio.src/M000147.html +0 -16
  191. data/doc/rdoc/classes/RIO/Rio.src/M000148.html +0 -16
  192. data/doc/rdoc/classes/RIO/Rio.src/M000149.html +0 -16
  193. data/doc/rdoc/classes/RIO/Rio.src/M000150.html +0 -16
  194. data/doc/rdoc/classes/RIO/Rio.src/M000151.html +0 -16
  195. data/doc/rdoc/classes/RIO/Rio.src/M000152.html +0 -16
  196. data/doc/rdoc/classes/RIO/Rio.src/M000153.html +0 -16
  197. data/doc/rdoc/classes/RIO/Rio.src/M000154.html +0 -16
  198. data/doc/rdoc/classes/RIO/Rio.src/M000155.html +0 -16
  199. data/doc/rdoc/classes/RIO/Rio.src/M000156.html +0 -16
  200. data/doc/rdoc/classes/RIO/Rio.src/M000157.html +0 -16
  201. data/doc/rdoc/classes/RIO/Rio.src/M000158.html +0 -16
  202. data/doc/rdoc/classes/RIO/Rio.src/M000159.html +0 -16
  203. data/doc/rdoc/classes/RIO/Rio.src/M000160.html +0 -16
  204. data/doc/rdoc/classes/RIO/Rio.src/M000161.html +0 -16
  205. data/doc/rdoc/classes/RIO/Rio.src/M000162.html +0 -16
  206. data/doc/rdoc/classes/RIO/Rio.src/M000163.html +0 -16
  207. data/doc/rdoc/classes/RIO/Rio.src/M000164.html +0 -16
  208. data/doc/rdoc/classes/RIO/Rio.src/M000165.html +0 -16
  209. data/doc/rdoc/classes/RIO/Rio.src/M000166.html +0 -16
  210. data/doc/rdoc/classes/RIO/Rio.src/M000167.html +0 -16
  211. data/doc/rdoc/classes/RIO/Rio.src/M000168.html +0 -16
  212. data/doc/rdoc/classes/RIO/Rio.src/M000169.html +0 -16
  213. data/doc/rdoc/classes/RIO/Rio.src/M000170.html +0 -16
  214. data/doc/rdoc/classes/RIO/Rio.src/M000171.html +0 -16
  215. data/doc/rdoc/classes/RIO/Rio.src/M000172.html +0 -16
  216. data/doc/rdoc/classes/RIO/Rio.src/M000173.html +0 -16
  217. data/doc/rdoc/classes/RIO/Rio.src/M000174.html +0 -16
  218. data/doc/rdoc/classes/RIO/Rio.src/M000175.html +0 -16
  219. data/doc/rdoc/classes/RIO/Rio.src/M000176.html +0 -16
  220. data/doc/rdoc/classes/RIO/Rio.src/M000177.html +0 -16
  221. data/doc/rdoc/classes/RIO/Rio.src/M000178.html +0 -16
  222. data/doc/rdoc/classes/RIO/Rio.src/M000179.html +0 -16
  223. data/doc/rdoc/classes/RIO/Rio.src/M000180.html +0 -16
  224. data/doc/rdoc/classes/RIO/Rio.src/M000181.html +0 -16
  225. data/doc/rdoc/created.rid +0 -1
  226. data/doc/rdoc/files/README.html +0 -215
  227. data/doc/rdoc/files/lib/rio/constructor_rb.html +0 -142
  228. data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +0 -135
  229. data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +0 -135
  230. data/doc/rdoc/files/lib/rio/doc/MISC_rb.html +0 -135
  231. data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +0 -135
  232. data/doc/rdoc/files/lib/rio/if/basic_rb.html +0 -135
  233. data/doc/rdoc/files/lib/rio/if/dir_rb.html +0 -135
  234. data/doc/rdoc/files/lib/rio/if/file_rb.html +0 -135
  235. data/doc/rdoc/files/lib/rio/if/fileordir_rb.html +0 -135
  236. data/doc/rdoc/files/lib/rio/if/grande_rb.html +0 -135
  237. data/doc/rdoc/files/lib/rio/if/internal_rb.html +0 -135
  238. data/doc/rdoc/files/lib/rio/if/methods_rb.html +0 -135
  239. data/doc/rdoc/files/lib/rio/if/path_rb.html +0 -135
  240. data/doc/rdoc/files/lib/rio/if/stream_rb.html +0 -135
  241. data/doc/rdoc/files/lib/rio/if/test_rb.html +0 -135
  242. data/doc/rdoc/files/lib/rio/kernel_rb.html +0 -142
  243. data/doc/rdoc/files/lib/rio_rb.html +0 -153
  244. data/doc/rdoc/fr_class_index.html +0 -34
  245. data/doc/rdoc/fr_file_index.html +0 -44
  246. data/doc/rdoc/fr_method_index.html +0 -209
  247. data/doc/rdoc/index.html +0 -24
  248. data/doc/rdoc/rdoc-style.css +0 -384
data/lib/rio/if/dir.rb CHANGED
@@ -127,7 +127,15 @@ module RIO
127
127
  #
128
128
  def entries(*args,&block) target.entries(*args,&block); self end
129
129
 
130
+ # Grande Directory Entry Rejection Method
131
+ #
132
+ # No aguments rejects all entries.
133
+ #
134
+ # Behaves like Rio#entries, except that matching entries are excluded.
135
+ #
136
+ def noentries(*args,&block) target.noentries(*args,&block); self end
130
137
 
138
+
131
139
  # Grande File Selection Method
132
140
  #
133
141
  # Sets the rio to return files. +args+ can be used to select which files are returned.
@@ -136,9 +144,9 @@ module RIO
136
144
  # end
137
145
  # No aguments selects all files.
138
146
  #
139
- # If +args+ are:
147
+ # +args+ may be one or more of the following:
140
148
  # Regexp:: selects matching files
141
- # glob:: selects matching files
149
+ # String:: treated as a glob, and selects matching files
142
150
  # Proc:: called for each file. the file is processed unless the proc returns false
143
151
  # Symbol:: sent to each file. Each file is processed unless the symbol returns false
144
152
  #
@@ -153,7 +161,7 @@ module RIO
153
161
  # rio('adir').files[/\.rb$/] # same thing using a regular expression
154
162
  # rio('adir').files[:symlink?] # an array of symlinks to files
155
163
  #
156
- # For Rios that refer to files, +files(*args)+ causes the file to be processed only if
164
+ # For Rios that refer to files, <tt>files(*args)</tt> causes the file to be processed only if
157
165
  # it meets the criteria specified by the args.
158
166
  #
159
167
  # rio('afile.z').files['*.z'] #=> [rio('afile.z')]
@@ -167,7 +175,7 @@ module RIO
167
175
  # directories. For the purposes of this problem, a Ruby program is defined as a file ending with .rb or a file
168
176
  # that is executable and whose shebang line contains 'ruby'
169
177
  #
170
- # rio(path).norecurse('.svn').files['*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }]
178
+ # rio(path).norecurse('.svn').files['*.rb',proc{ |f| f.executable? and f.gets =~ /^#!.+ruby/ }]
171
179
  #
172
180
  # Explanation:
173
181
  #
@@ -180,9 +188,9 @@ module RIO
180
188
  # Limit to files ending with '.rb'
181
189
  # rio(path).norecurse('.svn').files('*.rb')
182
190
  # Also allow files that are both executable and whose first line is a shebang-ruby line
183
- # rio(path).norecurse('.svn').files('*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ })
191
+ # rio(path).norecurse('.svn').files('*.rb',proc{ |f| f.executable? and f.gets =~ /^#!.+ruby/ })
184
192
  # Return an array rather than iterating thru them
185
- # rio(path).norecurse('.svn').files['*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }]
193
+ # rio(path).norecurse('.svn').files['*.rb',proc{ |f| f.executable? and f.gets =~ /^#!.+ruby/ }]
186
194
  #
187
195
  def files(*args,&block) target.files(*args,&block); self end
188
196
 
@@ -103,6 +103,12 @@ module RIO
103
103
  #
104
104
  def rename(*args,&block) target.rename(*args,&block); self end
105
105
 
106
+
107
+ # Behaves like Rio#rename, but also changes the calling Rio to
108
+ # refer to the renamed path
109
+ def rename!(*args,&block) target.rename!(*args,&block); self end
110
+
111
+
106
112
  # For directories proxies Dir#read, otherwise proxies IO#read
107
113
  #
108
114
  # Proxy for IO#read
data/lib/rio/if/grande.rb CHANGED
@@ -207,6 +207,31 @@ module RIO
207
207
  # So the existance of a block after many methods is taken as an implied
208
208
  # Rio#each
209
209
  #
210
+ # For Rios that refer to files, the item passed to the block is a String containing
211
+ # the line or block as selected by Rio#lines, or Rio#bytes. +lines+ is the default.
212
+ # rio('afile').lines.each { |line| ...}
213
+ #
214
+ # The block passed to +each+ will also accept an optional second parameter which will contain
215
+ # the result of the matching function. What this variable contains depends on the argument
216
+ # to +lines+ that resulted in the match as follows:
217
+ #
218
+ # Regexp:: The MatchData that resulted from the match.
219
+ # Range:: The record number of the matching record.
220
+ # Fixnum:: The record number of the matching record.
221
+ # Proc:: The value returned by the proc.
222
+ # Symbol:: The value resulting from sending the symbol to the String.
223
+ #
224
+ # If no selection arguments were used, this variable will simply contain +true+.
225
+ #
226
+ # rio(??).puts(%w[0:zero 1:one]).rewind.lines(/(\d+):([a-z]+)/) do |line,match|
227
+ # puts("#{match[1]} is spelled '#{match[2]}'")
228
+ # end
229
+ #
230
+ # Produces:
231
+ # 0 is spelled 'zero'
232
+ # 1 is spelled 'one'
233
+ #
234
+ #
210
235
  # For Rios that refer to directories, the item passed to the block is a Rio refering to
211
236
  # the directory entry.
212
237
  #
@@ -374,6 +399,9 @@ module RIO
374
399
  #
375
400
  def >(destination) target > destination; self end
376
401
 
402
+ # Alias for Rio#> (copy-to grande operator)
403
+ def copy(destination) target.copy(destination); self end
404
+
377
405
  # Grande Append-To Operator
378
406
  #
379
407
  # The append-to grande-operator is the same as Rio#> (copy-to) except that it opens the destination
@@ -43,11 +43,84 @@ module RIO
43
43
 
44
44
  # This is an internal function and should not normally be needed in client code.
45
45
  # It closes a Rio and returns it to its 'reset' state.
46
- def reset() target.reset() end
46
+ def reset() # :nodoc:
47
+ target.reset()
48
+ end
47
49
 
48
50
  # This is an internal function and is not needed in client code.
49
51
  # It returns the internal 'Rio Resource Locator' object.
50
- def rl() target.rl() end
52
+ def rl() # :nodoc:
53
+ target.rl()
54
+ end
55
+
56
+ # This is an internal function and is not needed in client code.
57
+ # It returns the internal 'Rio Resource Locator' object.
58
+ def to_rl() # :nodoc:
59
+ target.to_rl()
60
+ end
61
+
62
+ # This is an internal function and is not needed in client code.
63
+ # It returns the internal 'Rio Context' object.
64
+ def cx() # :nodoc:
65
+ target.cx()
66
+ end
67
+
68
+ # This is an internal function and is not needed in client code.
69
+ def cx=(arg) # :nodoc:
70
+ target.cx = arg
71
+ end
72
+
73
+ # This is an internal function and is not needed in client code.
74
+ def copyclose() # :nodoc:
75
+ target.copyclose
76
+ end
77
+
78
+ # This is an internal function and is not needed in client code.
79
+ def nostreamenum() # :nodoc:
80
+ target.nostreamenum
81
+ end
82
+
83
+ # This is an internal function and is not needed in client code.
84
+ def cpclose(*args,&block) # :nodoc:
85
+ target.cpclose(*args,&block)
86
+ end
87
+
88
+ # This is an internal function and is not needed in client code.
89
+ def each_record(*args,&block) # :nodoc:
90
+ target.each_record(*args,&block)
91
+ end
92
+
93
+ # This is an internal function and is not needed in client code.
94
+ def each_row(*args,&block) # :nodoc:
95
+ target.each_row(*args,&block)
96
+ end
97
+
98
+ # This is an internal function and is not needed in client code.
99
+ def outputmode?() # :nodoc:
100
+ target.outputmode?
101
+ end
102
+
103
+ # This is an internal function and is not needed in client code.
104
+ def inputmode?() # :nodoc:
105
+ target.inputmode?
106
+ end
107
+
108
+ # This is an internal function and is not needed in client code.
109
+ def iostate(sym) # :nodoc:
110
+ target.iostate(sym)
111
+ end
112
+
113
+ # This is an internal function and is not needed in client code.
114
+ def getwd(*args) # :nodoc:
115
+ target.getwd(*args)
116
+ end
117
+
118
+ # This is an internal function and is not needed in client code.
119
+ def stream_iter?() # :nodoc:
120
+ target.stream_iter?
121
+ end
122
+
123
+
51
124
 
52
125
  end
53
126
  end
@@ -465,10 +465,11 @@ module RIO
465
465
  #def autorewind?() target.autorewind?() end
466
466
 
467
467
 
468
- # Rio#autorewind
468
+ # Sets a Rio to 'autorewind'.
469
+ # autorewind is not a well thought out concept and probably will be
470
+ # removed. Do not use it.
469
471
  #
470
- #
471
- #def autorewind(arg=true,&block) target.autorewind(arg,&block); self end
472
+ def autorewind(*args,&block) target.autorewind(*args,&block); self end
472
473
 
473
474
 
474
475
  # Rio#noautorewind
@@ -0,0 +1,46 @@
1
+ #--
2
+ # ===============================================================================
3
+ # Copyright (c) 2005, 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
+ # rake rdoc
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
+ # Returns the String associated with a Rio which references a StringIO object.
41
+ # For any other type of Rio, is undefined.
42
+ def string() target.string end
43
+
44
+ end
45
+ end
46
+
@@ -0,0 +1,46 @@
1
+ #--
2
+ # ===============================================================================
3
+ # Copyright (c) 2005, 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
+ # rake rdoc
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
+ def file() target.file; self end
41
+ def dir() target.dir; self end
42
+
43
+
44
+ end
45
+ end
46
+
@@ -0,0 +1,266 @@
1
+ #--
2
+ # ===============================================================================
3
+ # Copyright (c) 2005, 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
+ # rake rdoc
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 Match #:nodoc: all
40
+ module Column
41
+
42
+ class Base
43
+ def initialize(arg)
44
+ @select_arg = arg
45
+ end
46
+ def inspect
47
+ @select_arg.inspect
48
+ end
49
+ def val()
50
+ @select_arg
51
+ end
52
+ def match_all?() false end
53
+ def match_none?() false end
54
+ end
55
+ class All < Base
56
+ def match?(colno) true end
57
+ def match_all?() true end
58
+ def =~(colno) true end
59
+ end
60
+ class None < Base
61
+ def match?(colno) false end
62
+ def match_none?() true end
63
+ def =~(colno) false end
64
+ end
65
+
66
+ class Range < Base
67
+ def match?(colno)
68
+ #p "match?(#{val},#{recno}) select_arg=#{@select_arg}"
69
+ @select_arg === colno
70
+ end
71
+ def =~(colno)
72
+ #p "=~(#{record},#{record.recno}) select_arg=#{@select_arg}"
73
+ @select_arg === colno
74
+ end
75
+ end
76
+ class Fixnum < Base
77
+ def match?(val,recno)
78
+ #p "match?(#{val},#{recno}) select_arg=#{@select_arg}"
79
+ @select_arg === recno
80
+ end
81
+ def =~(record)
82
+ #p "=~(#{record},#{record.recno}) select_arg=#{@select_arg}"
83
+ @select_arg === record.recno
84
+ end
85
+ end
86
+ class Proc < Base
87
+ def initialize(arg,therio)
88
+ super(arg)
89
+ @therio = therio
90
+ end
91
+ def match?(val,recno)
92
+ #p "match?(#{val},#{recno}) select_arg=#{@select_arg}"
93
+ @select_arg.call(val,recno,@therio)
94
+ end
95
+ def =~(record)
96
+ @select_arg.call(record,record.recno,@therio)
97
+ end
98
+ end
99
+ class Symbol < Base
100
+ def match?(val,recno)
101
+ #p "match?(#{val},#{recno}) select_arg=#{@select_arg}"
102
+ val.__send__(@select_arg)
103
+ end
104
+ def =~(record)
105
+ record.__send__(@select_arg)
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ module Match
112
+ module Record
113
+ # for a sellist
114
+ # nil indicates no call was made, so nothing selected
115
+ # empty indicates a call was made, so all selected
116
+ # contents should be checked for matches
117
+ # if contents are removed the list should become nil, not empty
118
+ class SelList
119
+ def initialize(therio,args)
120
+ if args.nil?
121
+ @list = nil
122
+ else
123
+ @list = []
124
+ args.each do |arg|
125
+ @list << create_sel(therio,arg)
126
+ end
127
+ end
128
+ #p "SelList(#{args.inspect},#{@list.inspect})"
129
+ end
130
+ def inspect
131
+ @list.inspect
132
+ end
133
+ def size() @list.size unless @list.nil? end
134
+ def only_one_fixnum?()
135
+ @list && @list.size == 1 && @list[0].kind_of?(Match::Record::Fixnum)
136
+ end
137
+ def delete_at(index)
138
+ @list.delete_at(index)
139
+ @list = nil if @list.empty?
140
+ end
141
+ def self.create(therio,args)
142
+ new(therio,args) unless args.nil?
143
+ end
144
+ def ranges()
145
+ @list.nil? ? [] : @list.select { |sel| sel.kind_of?(Record::Range) }
146
+ end
147
+ def remove_passed_ranges(n)
148
+ return nil if @list.nil?
149
+ return self if @list.empty?
150
+ newlist = []
151
+ @list.each do |sel|
152
+ newlist << sel unless sel.kind_of?(Match::Record::Range) and sel.val.max < n
153
+ end
154
+ @list = (newlist.empty? ? nil : newlist) if newlist.length != @list.length
155
+ @list.nil? ? nil : self
156
+ end
157
+ def create_sel(therio,arg)
158
+ case arg
159
+ when ::Regexp
160
+ Match::Record::RegExp.new(arg)
161
+ when ::Range
162
+ Match::Record::Range.new(arg)
163
+ when ::Proc
164
+ Match::Record::Proc.new(arg,therio)
165
+ when ::Symbol
166
+ Match::Record::Symbol.new(arg)
167
+ when ::Fixnum
168
+ Match::Record::Fixnum.new(arg)
169
+ else
170
+ raise ArgumentError,"Argument must be a Regexp,Range,Fixnum,Proc, or Symbol"
171
+ end
172
+ end
173
+ def match?(val,recno)
174
+ # !@list.nil? && (@list.empty? || @list.detect { |sel| sel.match?(val,recno) } || false) && true
175
+ return false if @list.nil?
176
+ return true if @list.empty?
177
+ as = nil
178
+ al = @list.detect { |sel| as = sel.match?(val,recno)
179
+ #p "1: #{$1} as[match?]: #{as.inspect}"
180
+ as
181
+ }
182
+ #p "[SelList.match?] as:#{as.inspect} al:#{al.inspect}"
183
+ return as if al
184
+ return false
185
+ end
186
+ def =~(el)
187
+ !@list.nil? && (@list.empty? || @list.detect { |sel| sel =~ el } || false) && true
188
+ end
189
+ def always?() !@list.nil? && @list.empty? end
190
+ def never?() @list.nil? end
191
+ end
192
+
193
+
194
+ class SelRej
195
+ def initialize(therio,sel_args,rej_args)
196
+ @sel = SelList.create(therio,sel_args)
197
+ @rej = SelList.create(therio,rej_args)
198
+ @always = init_always()
199
+ end
200
+ def only_one_fixnum?()
201
+ @rej.nil? && @sel && @sel.only_one_fixnum?
202
+ end
203
+ def init_always(reset=false)
204
+ if @sel.nil? and @rej.nil?
205
+ !reset
206
+ elsif @rej.nil? and @sel.always?
207
+ true
208
+ elsif @sel.nil?
209
+ false
210
+ elsif !@rej.nil? and @rej.always?
211
+ false
212
+ else
213
+ nil
214
+ end
215
+ end
216
+ def remove_passed_ranges(n)
217
+ @sel = @sel.remove_passed_ranges(n) unless @sel.nil?
218
+ @rej = @rej.remove_passed_ranges(n) unless @rej.nil?
219
+ @always = init_always(true)
220
+ self
221
+ end
222
+ def rangetops()
223
+ rtops = ranges.map { |r| r.val.max }.sort.uniq
224
+ rtops.empty? ? nil : rtops
225
+ end
226
+ def ranges()
227
+ (@sel.nil? ? [] : @sel.ranges) + (@rej.nil? ? [] : @rej.ranges)
228
+ end
229
+ def class_tail
230
+ self.class.to_s.sub(/^.+::/,'')
231
+ end
232
+ def inspect
233
+ sprintf("#<%s:0x%08x @always=%s @sel=%s @rej=%s>",self.class_tail,self.object_id,@always.inspect,
234
+ @sel.inspect,@rej.inspect)
235
+ end
236
+ def always?()
237
+ @always == true
238
+ end
239
+ def never?()
240
+ @always == false
241
+ end
242
+ def match?(val,recno)
243
+ #p "match?(#{val},#{recno}) #{self.inspect}"
244
+ return @always unless @always.nil?
245
+ as = nil
246
+ ok = ((!@sel.nil? && (as = @sel.match?(val,recno))) && !(!@rej.nil? && @rej.match?(val,recno)))
247
+ return (ok ? as : ok)
248
+ end
249
+ def =~(el)
250
+ return @always unless @always.nil?
251
+ (!@sel.nil? && (@sel =~ el)) && !(!@rej.nil? && (@rej =~ el))
252
+
253
+ #yes = (!@sel.nil? && (@sel =~ el))
254
+ #no = (!@rej.nil? && (@rej =~ el))
255
+ #p "yes=#{yes} no=#{no} el=#{el}"
256
+ #return yes && !no
257
+ #(@sel =~ el) && !(@rej =~ el)
258
+ end
259
+ end
260
+ end
261
+ end
262
+ end
263
+
264
+
265
+
266
+