rio 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/ChangeLog +225 -0
  2. data/README +12 -0
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/doc/ANNOUNCE +160 -71
  6. data/doc/RELEASE_NOTES +71 -2
  7. data/ex/colx.rb +1 -1
  8. data/ex/passwd_report.rb +4 -8
  9. data/ex/riocat +5 -5
  10. data/ex/riogunzip +1 -1
  11. data/ex/riogzip +6 -6
  12. data/ex/rioprompt.rb +6 -0
  13. data/lib/rio.rb +3 -13
  14. data/lib/rio/arycopy.rb +1 -1
  15. data/lib/rio/base.rb +1 -5
  16. data/lib/rio/construct.rb +75 -0
  17. data/lib/rio/constructor.rb +42 -11
  18. data/lib/rio/context.rb +1 -1
  19. data/lib/rio/context/dir.rb +50 -23
  20. data/lib/rio/context/methods.rb +5 -3
  21. data/lib/rio/{cxdir.rb → context/skip.rb} +24 -36
  22. data/lib/rio/context/stream.rb +38 -16
  23. data/lib/rio/cp.rb +24 -5
  24. data/lib/rio/dir.rb +8 -7
  25. data/lib/rio/doc/HOWTO.rb +33 -33
  26. data/lib/rio/doc/INTRO.rb +416 -256
  27. data/lib/rio/doc/MISC.rb +3 -1
  28. data/lib/rio/doc/SYNOPSIS.rb +28 -33
  29. data/lib/rio/entrysel.rb +76 -9
  30. data/lib/rio/file.rb +2 -1
  31. data/lib/rio/filter.rb +95 -0
  32. data/lib/rio/filter/closeoneof.rb +1 -1
  33. data/lib/rio/grande.rb +0 -74
  34. data/lib/rio/if.rb +2 -1
  35. data/lib/rio/if/basic.rb +1 -1
  36. data/lib/rio/if/csv.rb +1 -1
  37. data/lib/rio/if/dir.rb +1 -220
  38. data/lib/rio/if/fileordir.rb +26 -12
  39. data/lib/rio/if/grande.rb +55 -6
  40. data/lib/rio/if/grande_entry.rb +355 -0
  41. data/lib/rio/if/{methods.rb → grande_stream.rb} +69 -88
  42. data/lib/rio/if/path.rb +25 -3
  43. data/lib/rio/if/stream.rb +62 -37
  44. data/lib/rio/if/temp.rb +2 -2
  45. data/lib/rio/if/test.rb +23 -0
  46. data/lib/rio/impl/path.rb +5 -0
  47. data/lib/rio/match.rb +6 -3
  48. data/lib/rio/matchrecord.rb +50 -46
  49. data/lib/rio/{filter/chomp.rb → ops/construct.rb} +12 -20
  50. data/lib/rio/ops/create.rb +3 -0
  51. data/lib/rio/ops/dir.rb +12 -6
  52. data/lib/rio/ops/either.rb +17 -3
  53. data/lib/rio/ops/path.rb +4 -1
  54. data/lib/rio/ops/stream/input.rb +6 -1
  55. data/lib/rio/ops/stream/read.rb +1 -3
  56. data/lib/rio/{context/chomp.rb → prompt.rb} +17 -13
  57. data/lib/rio/rl/base.rb +1 -1
  58. data/lib/rio/rl/builder.rb +3 -1
  59. data/lib/rio/state.rb +7 -13
  60. data/lib/rio/stream.rb +8 -5
  61. data/lib/rio/stream/open.rb +1 -1
  62. data/lib/rio/version.rb +1 -1
  63. data/test/mswin32.rb +1 -1
  64. data/test/runtests_gem.rb +1 -1
  65. data/test/tc/all.rb +3 -0
  66. data/test/tc/copy-from.rb +13 -13
  67. data/test/tc/copy-to.rb +1 -1
  68. data/test/tc/copy.rb +1 -1
  69. data/test/tc/copydir.rb +0 -24
  70. data/test/tc/copysymlink.rb +39 -0
  71. data/test/tc/csv.rb +2 -2
  72. data/test/tc/csv2.rb +4 -4
  73. data/test/tc/misc.rb +16 -16
  74. data/test/tc/nolines.rb +26 -26
  75. data/test/tc/noqae.rb +74 -74
  76. data/test/tc/overload.rb +28 -28
  77. data/test/tc/riorl.rb +36 -0
  78. data/test/tc/selnosel.rb +36 -0
  79. data/test/tc/skip.rb +58 -0
  80. data/test/tc/skiplines.rb +42 -0
  81. data/test/tc/symlink.rb +1 -1
  82. data/test/tc/symlink0.rb +1 -1
  83. data/test/tc/temp.rb +1 -1
  84. data/test/tc/tempdir.rb +1 -1
  85. data/test/tc/testcase.rb +7 -1
  86. metadata +14 -8
  87. data/lib/rio/matchcolumns.rb +0 -266
  88. data/lib/rio/rangemath.rb +0 -44
data/ChangeLog CHANGED
@@ -1,4 +1,229 @@
1
1
  ------------------------------------------------------------------------
2
+ r97 | kit | 2005-09-06 16:51:50 -0700 (Tue, 06 Sep 2005) | 1 line
3
+ Changed paths:
4
+ M /rio/trunk/doc/ANNOUNCE
5
+ M /rio/trunk/doc/RELEASE_NOTES
6
+ M /rio/trunk/lib/rio/base.rb
7
+ M /rio/trunk/lib/rio/entrysel.rb
8
+ M /rio/trunk/lib/rio/grande.rb
9
+ M /rio/trunk/lib/rio/if/grande_stream.rb
10
+ D /rio/trunk/lib/rio/if/methods.rb
11
+ M /rio/trunk/lib/rio/if.rb
12
+ M /rio/trunk/test/tc/temp.rb
13
+ M /rio/trunk/test/tc/tempdir.rb
14
+
15
+ Prepare for Release
16
+ ------------------------------------------------------------------------
17
+ r95 | kit | 2005-09-06 15:36:32 -0700 (Tue, 06 Sep 2005) | 1 line
18
+ Changed paths:
19
+ M /rio/trunk/Rakefile
20
+
21
+ Rakefile modified
22
+ ------------------------------------------------------------------------
23
+ r94 | kit | 2005-09-06 15:28:19 -0700 (Tue, 06 Sep 2005) | 1 line
24
+ Changed paths:
25
+ M /rio/trunk/lib/rio/base.rb
26
+ A /rio/trunk/lib/rio/construct.rb
27
+ M /rio/trunk/lib/rio/if/path.rb
28
+ M /rio/trunk/lib/rio/if/temp.rb
29
+ M /rio/trunk/lib/rio/if/test.rb
30
+ M /rio/trunk/lib/rio/impl/path.rb
31
+ A /rio/trunk/lib/rio/ops/construct.rb
32
+ M /rio/trunk/lib/rio/ops/create.rb
33
+ M /rio/trunk/lib/rio/ops/either.rb
34
+ M /rio/trunk/lib/rio/ops/path.rb
35
+ M /rio/trunk/lib/rio/state.rb
36
+ M /rio/trunk/lib/rio/version.rb
37
+ M /rio/trunk/lib/rio.rb
38
+ A /rio/trunk/test/tc/skiplines.rb
39
+
40
+ skip tests and new constructor methods
41
+ ------------------------------------------------------------------------
42
+ r93 | kit | 2005-09-05 20:22:06 -0700 (Mon, 05 Sep 2005) | 1 line
43
+ Changed paths:
44
+ M /rio/trunk/lib/rio/context/stream.rb
45
+ M /rio/trunk/lib/rio/if/grande.rb
46
+ M /rio/trunk/lib/rio/if/grande_stream.rb
47
+ M /rio/trunk/lib/rio/if/methods.rb
48
+ M /rio/trunk/lib/rio/ops/dir.rb
49
+ M /rio/trunk/lib/rio/ops/stream/input.rb
50
+ M /rio/trunk/test/tc/all.rb
51
+ M /rio/trunk/test/tc/skip.rb
52
+
53
+ skip lines, and document skip
54
+ ------------------------------------------------------------------------
55
+ r92 | kit | 2005-09-05 13:32:45 -0700 (Mon, 05 Sep 2005) | 1 line
56
+ Changed paths:
57
+ A /rio/trunk/lib/rio/context/skip.rb
58
+ A /rio/trunk/lib/rio/if/grande_entry.rb
59
+ A /rio/trunk/lib/rio/if/grande_stream.rb
60
+ A /rio/trunk/test/tc/copysymlink.rb
61
+ A /rio/trunk/test/tc/skip.rb
62
+
63
+ skip
64
+ ------------------------------------------------------------------------
65
+ r91 | kit | 2005-09-05 13:29:28 -0700 (Mon, 05 Sep 2005) | 1 line
66
+ Changed paths:
67
+ M /rio/trunk/lib/rio/context/dir.rb
68
+ M /rio/trunk/lib/rio/dir.rb
69
+ M /rio/trunk/lib/rio/entrysel.rb
70
+ M /rio/trunk/lib/rio/grande.rb
71
+ M /rio/trunk/lib/rio/if/dir.rb
72
+ M /rio/trunk/lib/rio/if/fileordir.rb
73
+ M /rio/trunk/lib/rio/if/grande.rb
74
+ M /rio/trunk/lib/rio/if/methods.rb
75
+ M /rio/trunk/lib/rio/if/path.rb
76
+ M /rio/trunk/lib/rio/if/stream.rb
77
+ M /rio/trunk/lib/rio/if.rb
78
+ M /rio/trunk/lib/rio/match.rb
79
+ M /rio/trunk/lib/rio/ops/dir.rb
80
+ M /rio/trunk/lib/rio/ops/either.rb
81
+ M /rio/trunk/lib/rio.rb
82
+ M /rio/trunk/test/tc/all.rb
83
+ A /rio/trunk/test/tc/selnosel.rb
84
+
85
+ selection changes; documentation corrections
86
+ ------------------------------------------------------------------------
87
+ r90 | kit | 2005-09-03 10:26:43 -0700 (Sat, 03 Sep 2005) | 1 line
88
+ Changed paths:
89
+ M /rio/trunk/doc/RELEASE_NOTES
90
+ M /rio/trunk/lib/rio/context/dir.rb
91
+ M /rio/trunk/lib/rio/context/methods.rb
92
+ M /rio/trunk/lib/rio/context/stream.rb
93
+ D /rio/trunk/lib/rio/cxdir.rb
94
+ M /rio/trunk/lib/rio/dir.rb
95
+ M /rio/trunk/lib/rio/doc/HOWTO.rb
96
+ M /rio/trunk/lib/rio/doc/INTRO.rb
97
+ M /rio/trunk/lib/rio/doc/SYNOPSIS.rb
98
+ M /rio/trunk/lib/rio/entrysel.rb
99
+ M /rio/trunk/lib/rio/file.rb
100
+ M /rio/trunk/lib/rio/grande.rb
101
+ M /rio/trunk/lib/rio/if/csv.rb
102
+ M /rio/trunk/lib/rio/if/dir.rb
103
+ M /rio/trunk/lib/rio/if/grande.rb
104
+ M /rio/trunk/lib/rio/if/methods.rb
105
+ M /rio/trunk/lib/rio/ops/dir.rb
106
+ M /rio/trunk/lib/rio/ops/either.rb
107
+ M /rio/trunk/lib/rio/ops/stream/input.rb
108
+ M /rio/trunk/misc/addsrcheaders.rb
109
+ M /rio/trunk/misc/mktoc.rb
110
+ M /rio/trunk/test/mswin32.rb
111
+ M /rio/trunk/test/tc/all.rb
112
+ M /rio/trunk/test/tc/nolines.rb
113
+ M /rio/trunk/test/tc/noqae.rb
114
+
115
+ fixed selection issues, phase one
116
+ ------------------------------------------------------------------------
117
+ r89 | kit | 2005-08-30 09:10:34 -0700 (Tue, 30 Aug 2005) | 1 line
118
+ Changed paths:
119
+ M /rio/trunk/doc/RELEASE_NOTES
120
+
121
+ Documentation
122
+ ------------------------------------------------------------------------
123
+ r88 | kit | 2005-08-29 19:33:43 -0700 (Mon, 29 Aug 2005) | 1 line
124
+ Changed paths:
125
+ M /rio/trunk/doc/RELEASE_NOTES
126
+ M /rio/trunk/lib/rio/doc/INTRO.rb
127
+ M /rio/trunk/lib/rio/entrysel.rb
128
+ M /rio/trunk/lib/rio/if/grande.rb
129
+ M /rio/trunk/lib/rio/if/methods.rb
130
+ M /rio/trunk/lib/rio/matchrecord.rb
131
+
132
+ selection using arrays (logical AND)
133
+ ------------------------------------------------------------------------
134
+ r87 | kit | 2005-08-29 17:11:58 -0700 (Mon, 29 Aug 2005) | 1 line
135
+ Changed paths:
136
+ M /rio/trunk/lib/rio/constructor.rb
137
+ M /rio/trunk/lib/rio/rl/builder.rb
138
+ M /rio/trunk/test/tc/riorl.rb
139
+
140
+ allow symbols in the constructor; documentation
141
+ ------------------------------------------------------------------------
142
+ r86 | kit | 2005-08-29 08:41:48 -0700 (Mon, 29 Aug 2005) | 1 line
143
+ Changed paths:
144
+ M /rio/trunk/lib/rio/cp.rb
145
+ M /rio/trunk/lib/rio/doc/HOWTO.rb
146
+ M /rio/trunk/lib/rio/doc/INTRO.rb
147
+ M /rio/trunk/lib/rio/doc/MISC.rb
148
+ M /rio/trunk/lib/rio/filter/closeoneof.rb
149
+ M /rio/trunk/lib/rio/if/dir.rb
150
+ M /rio/trunk/lib/rio/if/grande.rb
151
+ M /rio/trunk/lib/rio/if/methods.rb
152
+ M /rio/trunk/lib/rio/if/stream.rb
153
+ M /rio/trunk/lib/rio/ops/stream/read.rb
154
+ M /rio/trunk/lib/rio/rl/builder.rb
155
+ M /rio/trunk/lib/rio/stream/open.rb
156
+ M /rio/trunk/test/tc/copy-from.rb
157
+ M /rio/trunk/test/tc/copy-to.rb
158
+ M /rio/trunk/test/tc/copydir.rb
159
+ M /rio/trunk/test/tc/csv.rb
160
+ M /rio/trunk/test/tc/csv2.rb
161
+ M /rio/trunk/test/tc/misc.rb
162
+ M /rio/trunk/test/tc/overload.rb
163
+ M /rio/trunk/test/tc/symlink.rb
164
+ M /rio/trunk/test/tc/symlink0.rb
165
+ M /rio/trunk/test/tc/testcase.rb
166
+
167
+ removed #slurp in favor of #contents
168
+ ------------------------------------------------------------------------
169
+ r85 | kit | 2005-08-26 13:02:42 -0700 (Fri, 26 Aug 2005) | 1 line
170
+ Changed paths:
171
+ M /rio/trunk/README
172
+ M /rio/trunk/test/runtests_gem.rb
173
+
174
+ Documented rubygems installation
175
+ ------------------------------------------------------------------------
176
+ r84 | kit | 2005-08-26 12:07:17 -0700 (Fri, 26 Aug 2005) | 1 line
177
+ Changed paths:
178
+ M /rio/trunk/lib/rio/arycopy.rb
179
+ M /rio/trunk/lib/rio/cp.rb
180
+ M /rio/trunk/lib/rio/if/basic.rb
181
+ M /rio/trunk/lib/rio/if/grande.rb
182
+ M /rio/trunk/lib/rio/if/path.rb
183
+ M /rio/trunk/lib/rio/ops/path.rb
184
+ M /rio/trunk/lib/rio/rl/base.rb
185
+ M /rio/trunk/lib/rio/state.rb
186
+ M /rio/trunk/test/tc/copy.rb
187
+ M /rio/trunk/test/tc/misc.rb
188
+ M /rio/trunk/test/tc/overload.rb
189
+
190
+ removed copy, added (copy|append)_(to|from), changed + and =~ to use to_str
191
+ ------------------------------------------------------------------------
192
+ r83 | kit | 2005-08-25 14:23:54 -0700 (Thu, 25 Aug 2005) | 1 line
193
+ Changed paths:
194
+ M /rio/trunk/README
195
+ M /rio/trunk/lib/rio/doc/INTRO.rb
196
+ M /rio/trunk/lib/rio/doc/SYNOPSIS.rb
197
+ M /rio/trunk/lib/rio/if/dir.rb
198
+
199
+ Documentation
200
+ ------------------------------------------------------------------------
201
+ r82 | kit | 2005-08-24 09:06:42 -0700 (Wed, 24 Aug 2005) | 1 line
202
+ Changed paths:
203
+ M /rio/trunk/doc/ANNOUNCE
204
+ M /rio/trunk/ex/colx.rb
205
+ M /rio/trunk/ex/passwd_report.rb
206
+ M /rio/trunk/ex/riocat
207
+ M /rio/trunk/ex/riogunzip
208
+ M /rio/trunk/ex/riogzip
209
+ A /rio/trunk/ex/rioprompt.rb
210
+ D /rio/trunk/lib/rio/context/chomp.rb
211
+ M /rio/trunk/lib/rio/context/methods.rb
212
+ M /rio/trunk/lib/rio/context.rb
213
+ D /rio/trunk/lib/rio/filter/chomp.rb
214
+ A /rio/trunk/lib/rio/filter.rb
215
+ A /rio/trunk/lib/rio/prompt.rb
216
+ M /rio/trunk/lib/rio/state.rb
217
+ M /rio/trunk/lib/rio/stream.rb
218
+
219
+ chomp and strip
220
+ ------------------------------------------------------------------------
221
+ r81 | kit | 2005-08-23 11:57:02 -0700 (Tue, 23 Aug 2005) | 1 line
222
+ Changed paths:
223
+ M /rio/trunk/lib/rio/doc/INTRO.rb
224
+
225
+ Documentation
226
+ ------------------------------------------------------------------------
2
227
  r79 | kit | 2005-08-19 17:01:44 -0700 (Fri, 19 Aug 2005) | 1 line
3
228
  Changed paths:
4
229
  M /rio/trunk/doc/ANNOUNCE
data/README CHANGED
@@ -50,6 +50,14 @@ If you don't have rake installed, get it.
50
50
  Until you do, you may want to try
51
51
  ruby setup.rb
52
52
 
53
+ Rio is also available as a gem. If you have rubygems installed use:
54
+ gem install rio
55
+
56
+ To use Rio as a rubygem:
57
+ require 'rubygems'
58
+ require 'rio'
59
+
60
+
53
61
  To build the documentation without rake, try
54
62
  rdoc --op doc/rdoc -m RIO::Doc::SYNOPSIS README lib/rio/doc/*.rb lib/rio.rb lib/rio/if/*.rb lib/rio/kernel.rb
55
63
 
@@ -61,5 +69,9 @@ To read the documentation without running rdoc, read the files:
61
69
  * lib/rio/doc/HOWTO.rb
62
70
  * lib/rio/if/*.rb
63
71
 
72
+ Project:: http://rubyforge.org/projects/rio/
73
+ Documentation:: http://rio.rubyforge.org/
74
+ Bugs:: http://rubyforge.org/tracker/?group_id=821
75
+ Email:: rio4ruby@rubyforge.org
64
76
 
65
77
 
data/Rakefile CHANGED
@@ -125,7 +125,7 @@ end
125
125
  # rio(ZIP_DIR) << rio('pkg').files['*.tgz','*.tar.gz','*.zip','*.gem']
126
126
  #end
127
127
  task :ziparc do |var|
128
- require 'rio/kernel'
128
+ require 'rio'
129
129
  #$trace_states = true
130
130
  rio(ZIP_DIR) < rio('pkg').files['*.tgz','*.tar.gz','*.zip','*.gem']
131
131
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -1,98 +1,187 @@
1
- For your perusal -- Rio 0.3.2
1
+ New and Improved -- Rio 0.3.4
2
2
 
3
3
  == Overview
4
4
 
5
5
  Rio is a Ruby I/O convenience class wrapping much of the functionality
6
- of IO, File and Dir. Rio also uses Pathname, FileUtils, Tempfile,
7
- StringIO, OpenURI, Zlib, and CSV to provide similar functionality using
8
- a simple consistent interface. In addition to forwarding the interfaces
9
- provided by IO, File, and Dir to an appropriate object, Rio provides
10
- a "grande" interface that allows many common application-level I/O and
6
+ of IO, File and Dir. Rio also uses FileUtils, Tempfile, StringIO,
7
+ OpenURI, Zlib, and CSV to provide similar functionality using a simple
8
+ consistent interface. In addition to forwarding the interfaces
9
+ provided by IO, File, and Dir to an appropriate object, Rio provides a
10
+ "grande" interface that allows many common application-level I/O and
11
11
  file-system tasks to be expressed succinctly.
12
12
 
13
- == New for version 0.3.3
14
- * Expanded support and documentation for CSV files
15
- Examples:
16
- * Copy, changing the separator to a semicolon
17
- rio('comma.csv').csv > rio('semicolon.csv').csv(';')
18
- * Iterate through a file with each line parsed into an array
19
- rio('afile.csv').csv { |array_of_fields| ...}
20
- * Create an array of arrays of selected fields
21
- array_of_arrays = rio('afile.csv').csv.columns(1..3,7).to_a
22
- * Create a tab separated file of accounts in a UNIX passwd file,
23
- listing only the username, uid, and realname fields
24
- rio('/etc/passwd').csv(':').columns(0,2,4) > rio('report).csv("\t")
13
+ == SYNOPSIS
25
14
 
26
- Project:: http://rubyforge.org/projects/rio/
27
- Documentation:: http://rio.rubyforge.org/
28
- Bugs:: http://rubyforge.org/tracker/?group_id=821
15
+ For the following assume:
16
+ astring = ""
17
+ anarray = []
18
+
19
+ Copy or append a file to a string
20
+ rio('afile') > astring # copy
21
+ rio('afile') >> astring # append
22
+
23
+ Copy or append a string to a file
24
+ rio('afile') < astring # copy
25
+ rio('afile') << astring # append
26
+
27
+ Copy or append the lines of a file to an array
28
+ rio('afile') > anarray
29
+ rio('afile') >> anarray
30
+
31
+ Copy or append a file to another file
32
+ rio('afile') > rio('another_file')
33
+ rio('afile') >> rio('another_file')
34
+
35
+ Copy a file to a directory
36
+ rio('adir') << rio('afile')
37
+
38
+ Copy a directory structure to another directory
39
+ rio('adir') >> rio('another_directory')
40
+
41
+ Copy a web-page to a file
42
+ rio('http://rubydoc.org/') > rio('afile')
43
+
44
+ Ways to get the chomped lines of a file into an array
45
+ anarray = rio('afile').chomp[] # subscript operator
46
+ rio('afile').chomp > anarray # copy-to operator
47
+ anarray = rio('afile').chomp.to_a # to_a
48
+ anarray = rio('afile').chomp.readlines # IO#readlines
49
+
50
+ Copy a gzipped file un-gzipping it
51
+ rio('afile.gz').gzip > rio('afile')
52
+
53
+ Copy a plain file, gzipping it
54
+ rio('afile.gz').gzip < rio('afile')
55
+
56
+ Copy a file from a ftp server into a local file un-gzipping it
57
+ rio('ftp://host/afile.gz').gzip > rio('afile')
58
+
59
+ Iterate over the entries in a directory
60
+ rio('adir').entries { |entrio| ... }
61
+
62
+ Iterate over only the files in a directory
63
+ rio('adir').files { |entrio| ... }
64
+
65
+ Iterate over only the .rb files in a directory
66
+ rio('adir').files('*.rb') { |entrio| ... }
67
+
68
+ Iterate over .rb files but not symlinks to .rb files
69
+ rio('adir').files('*.rb').skip(:symlink?) { |entrio| ... }
29
70
 
30
-
31
- == New for version 0.3.2
71
+ Iterate over only the _dot_ files in a directory
72
+ rio('adir').files(/^\./) { |entrio| ... }
32
73
 
33
- * Based on a suggestion by Wybo Decker and code attributed to Nobu Nokada,
34
- Rio now supports temporary directories in addition to temporary files.
35
- * Bug fixes
36
- * More tests and documentation.
74
+ Iterate over the files in a directory and its subdirectories, skipping
75
+ '.svn' and 'CVS' directories
37
76
 
77
+ rio('adir').norecurse(/^\.svn$/,'CVS').files { |entrio| ... }
38
78
 
39
- == Version 0.3.1
79
+ Create an array of the .rb entries in a directory
80
+ anarray = rio('adir')['*.rb']
40
81
 
41
- A Rio is and can manipulate:
42
- * a path
43
- * the string representing that path
44
- * the file, directory, web-page, or IO object to which that path refers
45
- * the object created by opening that file or directory.
82
+ Create an array of the .rb entries in a directory and its
83
+ subdirectories.
84
+ anarray = rio('adir').all['*.rb']
46
85
 
47
- A Rio open itself, closes itself and selects its mode based on how it
48
- used and the object referenced.
86
+ Iterate over the .rb files in a directory and its subdirectories
87
+ rio('adir').all.files('*.rb') { |entrio| ... }
49
88
 
50
- == Grande interface
89
+ Iterate over the non-empty, non-comment chomped lines of a file
90
+ rio('afile').chomp.skip.lines(:empty?,/^\s*#/) { |line| ... }
51
91
 
52
- With the grande interface you can:
92
+ Copy the output of th ps command into an array, skipping the header
93
+ line and the ps command entry
94
+ rio(?-,'ps -a').skip.lines(0,/ps$/) > anarray
53
95
 
54
- Copy...
55
- rio('afile') > astring # a file into a string
56
- rio('afile') < astring # a string into a file
57
- rio('afile') > anarray # lines of a file into array
58
- rio('afile') < anarray # an array into a file
59
- rio('afile') > rio('another_file') # a file into another file
60
- rio('adir') > rio('another_directory') # a directory into another
61
- rio('http://rubydoc.org/') > rio('afile') # a web page into a file
96
+ Prompt for input and return what was typed
97
+ ans = rio(?-).print("Type Something: ").chomp.gets
62
98
 
63
- Iterate...
64
- rio('adir').entries { |entrio| ... } # over directory entries
65
- rio('adir').files { |entrio| ... } # over only files
66
- rio('adir').dirs { |entrio| ... } # over only directories
67
- rio('afile').lines { |line| ... } # over lines in a file
99
+ Change the extension of all .htm files in a directory and its
100
+ subdirectories to .html
101
+ rio('adir').rename.all.files('*.htm') do |htmfile|
102
+ htmfile.extname = '.html'
103
+ end
68
104
 
69
- Create an array...
70
- rio('adir').files[] # of files
71
- rio('adir').dirs[] # of directories
72
- rio('afile').lines[] # of lines
105
+ Create a symbolic link 'asymlink' in 'adir' which refers to
106
+ 'adir/afile'
107
+ rio('adir/afile').symlink('adir/asymlink')
73
108
 
74
- Whether copying, iterating or returning an array
75
- Rio provides common input manipulations
109
+ Copy a CSV file, changing the separator to a semicolon
110
+ rio('comma.csv').csv > rio('semicolon.csv').csv(';')
76
111
 
77
- rio('afile').chomp > anarray # chomped lines to an array
78
- anarray = rio('afile').chomp[] # same thing
79
- rio('afile.gz').gzip > rio('afile') # ungzip a file
80
- rio('afile.gz').gzip < rio('afile') # gzip a file
81
- rio('afile.gz').chomp { |line| ...} # iterate chomped lines
112
+ Iterate through a CSVfile with each line parsed into an array
113
+ rio('afile.csv').csv { |array_of_fields| ...}
82
114
 
83
- Whether copying, iterating or returning an array
84
- Rio provides simple input selection
115
+ Create a tab separated file of accounts in a UNIX passwd file,
116
+ listing only the username, uid, and realname fields
117
+ rio('/etc/passwd').csv(':').columns(0,2,4) > rio('rpt').csv("\t")
85
118
 
86
- rio('afile').lines(0..9) > rio('file2') # the first 10 lines
87
- rio('afile').lines(/Rio/) { |line| ...} # lines containing 'Rio'
88
- anarray = rio('adir').files['*.rb'] # ruby files
119
+ == New for version 0.3.4
89
120
 
90
- Manipulation and selection methods can be combined
121
+ * New Grande Selection parameter.
91
122
 
92
- rio('afile').gzip.lines(/Rio/) > astring # 'Rio' lines from gz file
93
- anarray = rio('afile').chomp[0..9] # first 10 lines chomped
123
+ A major weakness of Rio's selection methods (lines, files, etc.)
124
+ has always been that it only implemented a logical OR.
94
125
 
95
- Many more examples and documentation at http://rio.rubyforge.org/
126
+ rio('afile').lines(0..10,/Rio/) {...}
127
+ iterates through lines that are in the range 0..10 OR
128
+ contain 'Rio'.
129
+
130
+ rio('adir').files(:executable?,'*.rb') {...}
131
+ iterates through files that are executable OR match '*.rb'
132
+
133
+ Selecting files that matched both required using a proc.
134
+ rio('adir').files(proc{ |f| f.executable? and f.fnmatch?('*.rb')}) {...}
135
+
136
+ Rio's grande selection methods will now accept an array of conditions
137
+ which must all be matched, in order to be selected. A logical AND.
138
+
139
+ rio('adir').files([:executable?,'*.rb']) {...}
140
+
141
+ The array, of course, need not be the only paramter.
142
+
143
+ rio('adir').files('*.exe',[:executable?,'*.rb']) {...}
144
+
145
+ selects .exe files and .rb files that are executable.
146
+
147
+ * Renamed some of grande rejection methods.
148
+ (based on a suggestion by Gavin Sinclair)
149
+ nolines => skiplines
150
+ nofiles => skipfiles
151
+ etc.
152
+
153
+ * New skip() grande method
154
+ rio('afile').skip.lines(/Rio/) # same as skiplines(/Rio/)
155
+ rio('afile').lines(/Rio/).skip(0..9) # lines with 'Rio', exclude
156
+ # the first ten lines
157
+
158
+ * Alternative syntaxes for creating Rios that have no path.
159
+ rio(?-) # create a Rio refering to stdio
160
+ rio(:stdio) # same thing.
161
+ rio.stdio # same thing
162
+ RIO.stdio # ditto
163
+ RIO::Rio.stdio # once again
164
+
165
+ * From Pathname added
166
+ * root?
167
+ * mountpoint?
168
+ * realpath
169
+ * cleanpath
170
+
171
+ * Removed Rio#slurp in favor of Rio#contents.
172
+
173
+ * Added aliases for the copy operators. (suggested by Dave Burt)
174
+ * copy_to >
175
+ * append_to >>
176
+ * copy_from <
177
+ * append_from <<
178
+
179
+ * Bug fixes and corrections
180
+
181
+ Project:: http://rubyforge.org/projects/rio/
182
+ Documentation:: http://rio.rubyforge.org/
183
+ Bugs:: http://rubyforge.org/tracker/?group_id=821
184
+ Email:: rio4ruby@rubyforge.org
96
185
 
97
186
  == Copyright
98
187
  Copyright (c) 2005, Christopher Kleckner. All rights reserved
@@ -101,4 +190,4 @@ Copyright (c) 2005, Christopher Kleckner. All rights reserved
101
190
  Rio is released under the GNU General Public License
102
191
  (http://www.gnu.org/licenses/gpl.html)
103
192
 
104
- -Christopher Kleckner
193
+ -Christopher Kleckner