rio 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +49 -0
- data/VERSION +1 -1
- data/doc/ANNOUNCE +19 -2
- data/doc/RELEASE_NOTES +17 -0
- data/ex/colx.rb +3 -1
- data/ex/passwd_report.rb +12 -0
- data/lib/rio.rb +8 -9
- data/lib/rio/argv.rb +0 -4
- data/lib/rio/base.rb +3 -1
- data/lib/rio/doc/INTRO.rb +74 -1
- data/lib/rio/ext/csv.rb +34 -5
- data/lib/rio/factory.rb +2 -2
- data/lib/rio/if.rb +3 -0
- data/lib/rio/if/csv.rb +76 -0
- data/lib/rio/if/dir.rb +14 -6
- data/lib/rio/if/fileordir.rb +6 -0
- data/lib/rio/if/grande.rb +28 -0
- data/lib/rio/if/internal.rb +75 -2
- data/lib/rio/if/methods.rb +4 -3
- data/lib/rio/if/string.rb +46 -0
- data/lib/rio/if/temp.rb +46 -0
- data/lib/rio/matchcolumns.rb +266 -0
- data/lib/rio/rangemath.rb +44 -0
- data/lib/rio/scheme/temp.rb +4 -1
- data/lib/rio/version.rb +1 -1
- data/test/tc/all.rb +4 -1
- data/test/tc/copy-from.rb +1 -1
- data/test/tc/csv2.rb +135 -0
- data/test/tc/csv_columns.rb +37 -0
- data/test/tc/csvutil.rb +56 -0
- data/test/tc/ext.rb +1 -1
- data/test/tc/methods.rb +1 -1
- data/test/tc/tempfile.rb +17 -0
- metadata +11 -228
- data/doc/rdoc/classes/Kernel.html +0 -181
- data/doc/rdoc/classes/Kernel.src/M000182.html +0 -18
- data/doc/rdoc/classes/RIO.html +0 -543
- data/doc/rdoc/classes/RIO.src/M000001.html +0 -18
- data/doc/rdoc/classes/RIO.src/M000002.html +0 -18
- data/doc/rdoc/classes/RIO.src/M000003.html +0 -18
- data/doc/rdoc/classes/RIO/Doc.html +0 -138
- data/doc/rdoc/classes/RIO/Doc/HOWTO.html +0 -1035
- data/doc/rdoc/classes/RIO/Doc/INTRO.html +0 -1335
- data/doc/rdoc/classes/RIO/Doc/MISC.html +0 -443
- data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +0 -355
- data/doc/rdoc/classes/RIO/Rio.html +0 -6358
- data/doc/rdoc/classes/RIO/Rio.src/M000004.html +0 -18
- data/doc/rdoc/classes/RIO/Rio.src/M000005.html +0 -20
- data/doc/rdoc/classes/RIO/Rio.src/M000006.html +0 -27
- data/doc/rdoc/classes/RIO/Rio.src/M000007.html +0 -27
- data/doc/rdoc/classes/RIO/Rio.src/M000008.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000009.html +0 -18
- data/doc/rdoc/classes/RIO/Rio.src/M000010.html +0 -20
- data/doc/rdoc/classes/RIO/Rio.src/M000011.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000012.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000013.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000014.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000015.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000016.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000017.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000018.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000019.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000020.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000021.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000022.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000023.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000024.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000025.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000026.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000027.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000028.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000029.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000030.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000031.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000032.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000033.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000034.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000035.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000036.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000037.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000038.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000039.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000040.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000041.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000042.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000043.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000044.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000045.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000046.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000047.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000048.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000049.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000050.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000051.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000052.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000053.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000054.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000055.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000056.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000057.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000058.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000059.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000060.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000061.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000062.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000063.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000064.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000065.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000066.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000067.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000068.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000069.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000070.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000071.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000072.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000073.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000074.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000075.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000076.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000077.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000078.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000079.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000080.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000081.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000082.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000083.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000084.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000085.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000086.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000087.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000088.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000089.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000090.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000091.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000092.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000093.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000094.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000095.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000096.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000097.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000098.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000099.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000100.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000101.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000102.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000103.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000104.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000105.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000106.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000107.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000108.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000109.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000110.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000111.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000112.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000113.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000114.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000115.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000116.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000117.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000118.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000119.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000120.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000121.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000122.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000123.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000124.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000125.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000126.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000127.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000128.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000129.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000130.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000131.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000132.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000133.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000134.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000135.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000136.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000137.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000138.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000139.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000140.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000141.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000142.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000143.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000144.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000145.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000146.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000147.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000148.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000149.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000150.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000151.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000152.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000153.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000154.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000155.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000156.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000157.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000158.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000159.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000160.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000161.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000162.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000163.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000164.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000165.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000166.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000167.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000168.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000169.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000170.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000171.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000172.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000173.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000174.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000175.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000176.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000177.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000178.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000179.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000180.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000181.html +0 -16
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/README.html +0 -215
- data/doc/rdoc/files/lib/rio/constructor_rb.html +0 -142
- data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/doc/MISC_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/basic_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/dir_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/file_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/fileordir_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/grande_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/internal_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/methods_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/path_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/stream_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/if/test_rb.html +0 -135
- data/doc/rdoc/files/lib/rio/kernel_rb.html +0 -142
- data/doc/rdoc/files/lib/rio_rb.html +0 -153
- data/doc/rdoc/fr_class_index.html +0 -34
- data/doc/rdoc/fr_file_index.html +0 -44
- data/doc/rdoc/fr_method_index.html +0 -209
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -384
data/ChangeLog
CHANGED
@@ -1,4 +1,53 @@
|
|
1
1
|
------------------------------------------------------------------------
|
2
|
+
r79 | kit | 2005-08-19 17:01:44 -0700 (Fri, 19 Aug 2005) | 1 line
|
3
|
+
Changed paths:
|
4
|
+
M /rio/trunk/doc/ANNOUNCE
|
5
|
+
M /rio/trunk/doc/RELEASE_NOTES
|
6
|
+
A /rio/trunk/ex/passwd_report.rb
|
7
|
+
M /rio/trunk/lib/rio/version.rb
|
8
|
+
|
9
|
+
Prepare for release
|
10
|
+
------------------------------------------------------------------------
|
11
|
+
r78 | kit | 2005-08-19 15:56:33 -0700 (Fri, 19 Aug 2005) | 1 line
|
12
|
+
Changed paths:
|
13
|
+
M /rio/trunk/lib/rio/doc/INTRO.rb
|
14
|
+
M /rio/trunk/lib/rio/ext/csv.rb
|
15
|
+
M /rio/trunk/lib/rio/if/csv.rb
|
16
|
+
M /rio/trunk/lib/rio/if/internal.rb
|
17
|
+
M /rio/trunk/lib/rio.rb
|
18
|
+
M /rio/trunk/test/tc/all.rb
|
19
|
+
A /rio/trunk/test/tc/csv2.rb
|
20
|
+
A /rio/trunk/test/tc/csv_columns.rb
|
21
|
+
A /rio/trunk/test/tc/csvutil.rb
|
22
|
+
M /rio/trunk/test/tc/tempfile.rb
|
23
|
+
|
24
|
+
CSV support and documentation for same
|
25
|
+
------------------------------------------------------------------------
|
26
|
+
r77 | kit | 2005-08-17 13:03:03 -0700 (Wed, 17 Aug 2005) | 1 line
|
27
|
+
Changed paths:
|
28
|
+
M /rio/trunk/doc/ANNOUNCE
|
29
|
+
M /rio/trunk/ex/colx.rb
|
30
|
+
M /rio/trunk/lib/rio/argv.rb
|
31
|
+
M /rio/trunk/lib/rio/base.rb
|
32
|
+
M /rio/trunk/lib/rio/factory.rb
|
33
|
+
A /rio/trunk/lib/rio/if/csv.rb
|
34
|
+
M /rio/trunk/lib/rio/if/dir.rb
|
35
|
+
M /rio/trunk/lib/rio/if/fileordir.rb
|
36
|
+
M /rio/trunk/lib/rio/if/grande.rb
|
37
|
+
M /rio/trunk/lib/rio/if/internal.rb
|
38
|
+
M /rio/trunk/lib/rio/if/methods.rb
|
39
|
+
A /rio/trunk/lib/rio/if/string.rb
|
40
|
+
A /rio/trunk/lib/rio/if/temp.rb
|
41
|
+
M /rio/trunk/lib/rio/if.rb
|
42
|
+
M /rio/trunk/lib/rio/scheme/temp.rb
|
43
|
+
M /rio/trunk/lib/rio.rb
|
44
|
+
M /rio/trunk/test/tc/copy-from.rb
|
45
|
+
M /rio/trunk/test/tc/ext.rb
|
46
|
+
M /rio/trunk/test/tc/methods.rb
|
47
|
+
M /rio/trunk/test/tc/tempfile.rb
|
48
|
+
|
49
|
+
documentation
|
50
|
+
------------------------------------------------------------------------
|
2
51
|
r74 | kit | 2005-08-16 11:00:55 -0700 (Tue, 16 Aug 2005) | 1 line
|
3
52
|
Changed paths:
|
4
53
|
M /rio/trunk/doc/ANNOUNCE
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/doc/ANNOUNCE
CHANGED
@@ -10,7 +10,24 @@ provided by IO, File, and Dir to an appropriate object, Rio provides
|
|
10
10
|
a "grande" interface that allows many common application-level I/O and
|
11
11
|
file-system tasks to be expressed succinctly.
|
12
12
|
|
13
|
-
|
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")
|
25
|
+
|
26
|
+
Project:: http://rubyforge.org/projects/rio/
|
27
|
+
Documentation:: http://rio.rubyforge.org/
|
28
|
+
Bugs:: http://rubyforge.org/tracker/?group_id=821
|
29
|
+
|
30
|
+
|
14
31
|
== New for version 0.3.2
|
15
32
|
|
16
33
|
* Based on a suggestion by Wybo Decker and code attributed to Nobu Nokada,
|
@@ -82,6 +99,6 @@ Copyright (c) 2005, Christopher Kleckner. All rights reserved
|
|
82
99
|
|
83
100
|
== License
|
84
101
|
Rio is released under the GNU General Public License
|
85
|
-
(http://www.gnu.org/licenses/
|
102
|
+
(http://www.gnu.org/licenses/gpl.html)
|
86
103
|
|
87
104
|
-Christopher Kleckner
|
data/doc/RELEASE_NOTES
CHANGED
@@ -24,6 +24,23 @@ Suggested Reading
|
|
24
24
|
* RIO::Doc::HOWTO
|
25
25
|
* RIO::Rio
|
26
26
|
|
27
|
+
== New for version 0.3.3
|
28
|
+
* Expanded support and documentation for CSV files
|
29
|
+
Examples:
|
30
|
+
* Copy, changing the separator to a semicolon
|
31
|
+
rio('comma.csv').csv > rio('semicolon.csv').csv(';')
|
32
|
+
* Iterate through a file with each line parsed into an array
|
33
|
+
rio('afile.csv').csv { |array_of_fields| ...}
|
34
|
+
* Create an array of arrays of selected fields
|
35
|
+
array_of_arrays = rio('afile.csv').csv.columns(1..3,7).to_a
|
36
|
+
* Create a tab separated file of accounts in a UNIX passwd file,
|
37
|
+
listing only the username, uid, and realname fields
|
38
|
+
rio('/etc/passwd').csv(':').columns(0,2,4) > rio('report).csv("\t")
|
39
|
+
|
40
|
+
Project:: http://rubyforge.org/projects/rio/
|
41
|
+
Documentation:: http://rio.rubyforge.org/
|
42
|
+
Bugs:: http://rubyforge.org/tracker/?group_id=821
|
43
|
+
|
27
44
|
== New for version 0.3.2
|
28
45
|
|
29
46
|
* Based on a suggestion by Wybo Decker and code attributed to Nobu Nokada,
|
data/ex/colx.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rio'
|
3
3
|
|
4
|
-
rio('
|
4
|
+
RGBFILE = rio(__FILE__).dirname/'rgb.txt.gz'
|
5
|
+
|
6
|
+
RGBFILE.gzip.lines(/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S.+)/) do |line,ma|
|
5
7
|
printf("#%02x%02x%02x\t%s\n",ma[1],ma[2],ma[3],ma[4])
|
6
8
|
end
|
data/ex/passwd_report.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rio'
|
3
|
+
|
4
|
+
rio('/etc/passwd').csv(':').columns(0,2,4) > rio(?-).csv("\t")
|
5
|
+
|
6
|
+
__END__
|
7
|
+
|
8
|
+
From Seattle,Wa
|
9
|
+
Take I-90 east, take exit 143 Gorge Amphitheatre. Follow amphitheatre signs approximately 6 miles.
|
10
|
+
|
11
|
+
206-242-8738
|
12
|
+
3:00
|
data/lib/rio.rb
CHANGED
@@ -111,20 +111,20 @@ module RIO
|
|
111
111
|
end
|
112
112
|
|
113
113
|
# returns the Rio#fspath, which is the path for the Rio on the underlying filesystem
|
114
|
-
def to_s(
|
115
|
-
|
114
|
+
def to_s() target.to_s end
|
115
|
+
alias :to_str :to_s
|
116
116
|
def dup
|
117
117
|
self.class.new(self.to_s)
|
118
118
|
end
|
119
119
|
|
120
|
-
|
121
|
-
|
120
|
+
def method_missing(sym,*args,&block) #:nodoc:
|
121
|
+
#p callstr('method_missing',sym,*args)
|
122
122
|
|
123
|
-
|
124
|
-
|
123
|
+
result = target.__send__(sym,*args,&block)
|
124
|
+
return result unless result.kind_of? State::Base and result.equal? target
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
self
|
127
|
+
end
|
128
128
|
|
129
129
|
def inspect()
|
130
130
|
cl = self.class.to_s[5..-1]
|
@@ -138,7 +138,6 @@ module RIO
|
|
138
138
|
require 'rio/if'
|
139
139
|
include Enumerable
|
140
140
|
end
|
141
|
-
|
142
141
|
protected
|
143
142
|
|
144
143
|
def target() @state.target end
|
data/lib/rio/argv.rb
CHANGED
data/lib/rio/base.rb
CHANGED
@@ -44,6 +44,7 @@ module RIO
|
|
44
44
|
KEEPSYM = {
|
45
45
|
'__id__' => true,
|
46
46
|
'__send__' => true,
|
47
|
+
'send' => true,
|
47
48
|
'class' => true,
|
48
49
|
'kind_of?' => true,
|
49
50
|
'instance_of?' => true,
|
@@ -52,7 +53,8 @@ module RIO
|
|
52
53
|
'object_id' => true,
|
53
54
|
'dup' => true,
|
54
55
|
'clone' => true,
|
55
|
-
|
56
|
+
'nil?' => true,
|
57
|
+
# 'to_s' => true,
|
56
58
|
}.freeze
|
57
59
|
instance_methods.each { |m| undef_method m unless KEEPSYM[m] }
|
58
60
|
end
|
data/lib/rio/doc/INTRO.rb
CHANGED
@@ -43,7 +43,7 @@ module Doc
|
|
43
43
|
|
44
44
|
Rio is a convenience class wrapping much of the functionality of
|
45
45
|
IO, File, Dir, Pathname, FileUtils,
|
46
|
-
Tempfile, StringIO, and OpenURI and uses Zlib, and CSV
|
46
|
+
Tempfile, StringIO, and OpenURI and uses Zlib, and CSV
|
47
47
|
to extend that functionality using a simple consistent interface.
|
48
48
|
Most of the instance methods of IO, File and Dir are simply forwarded to the appropriate handle
|
49
49
|
to provide identical functionality. Rio also provides a "grande" interface that
|
@@ -699,6 +699,79 @@ A Rio can also be opened explicitly using Rio#open. +open+ takes one parameter,
|
|
699
699
|
This also will override all of Rio's automatic mode selection.
|
700
700
|
|
701
701
|
|
702
|
+
==== CSV mode
|
703
|
+
|
704
|
+
Rio uses the CSV class from the Ruby standard library to provide support for reading
|
705
|
+
and writing comma-separated-value files. Normally using <tt>(no)records</tt> is
|
706
|
+
identical to <tt>(no)lines</tt> because while +records+ only selects and does not
|
707
|
+
specify the record-type, lines is the default, and so
|
708
|
+
rio('afile').records(1..2)
|
709
|
+
effectively means
|
710
|
+
rio('afile').lines.records(1..2)
|
711
|
+
|
712
|
+
The CSV extension distingishes between items selected using Rio#records and those
|
713
|
+
selected using Rio#lines. Rio returns records parsed into Arrays by the CSV
|
714
|
+
library when +records+ is used, and returns Strings as normal when +lines+ is used.
|
715
|
+
+records+ is the default
|
716
|
+
So:
|
717
|
+
rio('f.csv').puts!(["h0,h1","f0,f1"])
|
718
|
+
|
719
|
+
rio('f.csv').csv.records[] #==>[["h0", "h1"], ["f0", "f1"]]
|
720
|
+
rio('f.csv').csv[] #==> same thing
|
721
|
+
rio('f.csv').csv.lines[] #==>["h0,h1\n", "f0,f1\n"]
|
722
|
+
rio('f.csv').csv.records[0] #==>[["h0", "h1"]]
|
723
|
+
rio('f.csv').csv[0] #==> same thing
|
724
|
+
rio('f.csv').csv.lines[0] #==>["h0,h1\n"]
|
725
|
+
rio('f.csv').csv.norecords[0] #==>[["f0", "f1"]]
|
726
|
+
rio('f.csv').csv.nolines[0] #==>["f0,f1\n"]
|
727
|
+
|
728
|
+
This distinction, of course, applies equally when using the copy operators and +each+
|
729
|
+
rio('f.csv').csv[0] > rio('out').csv # out contains "f0,f1\n"
|
730
|
+
rio('f.csv').csv { |array_of_fields| ... }
|
731
|
+
|
732
|
+
Notice that +csv+ mode is called on both the input and output Rios. The +csv+ on the
|
733
|
+
'out' Rio causes it to treat an array written to it as an array of records which is
|
734
|
+
converted into CSV format before writing. Without the +csv+, the output would be
|
735
|
+
written as if Array#to_s on [["f0","f1"]] had been called
|
736
|
+
rio('f.csv').csv[0] > rio('out') # out contains "f0f1"
|
737
|
+
|
738
|
+
The String representing a record that is returned when using +lines+ is extended with a
|
739
|
+
+to_a+ method which will parse it into an array of fields. Likewise the Array returned
|
740
|
+
when a record is returned using +records+ is extended with a modified +to_s+ which
|
741
|
+
treats it as an array CSV fields, rather than just an array of strings.
|
742
|
+
|
743
|
+
array_of_lines = rio('f.csv').csv.lines[1] #==>["f0,f1\n"]
|
744
|
+
array_of_records = rio('f.csv').csv.records[1] #==>[["f0", "f1"]]
|
745
|
+
|
746
|
+
array_of_lines[0].to_a #==>["f0", "f1"]
|
747
|
+
array_of_records[0].to_s #==>"f0,f1"
|
748
|
+
|
749
|
+
Rio#csv takes two optional parameters, which are passed on to the CSV library. They are
|
750
|
+
the +field_separator+ and the +record_separator+.
|
751
|
+
rio('semisep').puts!(["h0;h1","f0;f1"])
|
752
|
+
|
753
|
+
rio('semisep').csv(';').to_a #==>[["h0", "h1"], ["f0", "f1"]]
|
754
|
+
|
755
|
+
These are specified independently on the source and destination when using the
|
756
|
+
copy operators, So:
|
757
|
+
|
758
|
+
rio('semisep').csv(';') > rio('colonsep').csv(':')
|
759
|
+
rio('colonsep').slurp #==>"h0:h1\nf0:f1\n"
|
760
|
+
|
761
|
+
Rio provides two methods for selecting fields from CSV records in a manner similar
|
762
|
+
to that provided for selecting lines -- Rio#columns and Rio#nocolumns.
|
763
|
+
|
764
|
+
rio('f.csv').puts!(["h0,h1,h2,h3","f0,f1,f2,f3"])
|
765
|
+
|
766
|
+
rio('f.csv').csv.columns(0).to_a #==>[["h0"], ["f0"]]
|
767
|
+
rio('f.csv').csv.nocolumns(0).to_a #==>[["h1", "h2", "h3"], ["f1", "f2", "f3"]]
|
768
|
+
rio('f.csv').csv.columns(1..2).to_a #==>[["h1", "h2"], ["f1", "f2"]]
|
769
|
+
rio('f.csv').csv.nocolumns(1..2).to_a #==>[["h0", "h3"], ["f0", "f3"]]
|
770
|
+
|
771
|
+
Rio#columns can, of course be used with the +each+ and the copy operators:
|
772
|
+
|
773
|
+
rio('f.csv').csv.columns(0..1) > rio('out').csv
|
774
|
+
rio('out').slurp #==>"h0,h1\nf0,f1\n"
|
702
775
|
|
703
776
|
|
704
777
|
---
|
data/lib/rio/ext/csv.rb
CHANGED
@@ -59,6 +59,11 @@ module RIO
|
|
59
59
|
cx['col_args'] = ranges.flatten
|
60
60
|
cxx('columns',true,&block)
|
61
61
|
end
|
62
|
+
def nocolumns(*ranges,&block)
|
63
|
+
@cnames = nil
|
64
|
+
cx['nocol_args'] = ranges.flatten
|
65
|
+
cxx('columns',true,&block)
|
66
|
+
end
|
62
67
|
def columns?()
|
63
68
|
cxx?('columns')
|
64
69
|
end
|
@@ -109,12 +114,36 @@ module RIO
|
|
109
114
|
private
|
110
115
|
|
111
116
|
def trim(fields)
|
112
|
-
|
117
|
+
ycols = cx['col_args']
|
118
|
+
ncols = cx['nocol_args']
|
119
|
+
return [] if ncols and ncols.empty?
|
120
|
+
if ycols.nil? and ncols.nil?
|
121
|
+
return fields
|
122
|
+
end
|
123
|
+
ncols = [] if ncols.nil?
|
124
|
+
ycols = [(0...fields.size)] if ycols.nil? or ycols.empty?
|
125
|
+
cols = []
|
126
|
+
fields.each_index { |i|
|
127
|
+
yes = nil
|
128
|
+
no = nil
|
129
|
+
ycols.each { |yc|
|
130
|
+
if yc === i
|
131
|
+
yes = true
|
132
|
+
break
|
133
|
+
end
|
134
|
+
}
|
135
|
+
ncols.each { |nc|
|
136
|
+
if nc === i
|
137
|
+
no = true
|
138
|
+
break
|
139
|
+
end
|
140
|
+
}
|
141
|
+
|
142
|
+
cols << i if yes and !no
|
143
|
+
}
|
113
144
|
tfields = []
|
114
|
-
|
115
|
-
|
116
|
-
tfields << fields[i] if rng === i
|
117
|
-
end
|
145
|
+
cols.each do |i|
|
146
|
+
tfields << fields[i]
|
118
147
|
end
|
119
148
|
tfields
|
120
149
|
end
|
data/lib/rio/factory.rb
CHANGED
@@ -173,8 +173,8 @@ module RIO
|
|
173
173
|
|
174
174
|
'Temp::Reset' => 'rio/scheme/temp',
|
175
175
|
'Temp::Stream::Open' => 'rio/scheme/temp',
|
176
|
-
'Temp::Stream::Close' => 'rio/scheme/temp',
|
177
|
-
'Temp::Stream::InOut' => 'rio/scheme/temp',
|
176
|
+
#'Temp::Stream::Close' => 'rio/scheme/temp',
|
177
|
+
#'Temp::Stream::InOut' => 'rio/scheme/temp',
|
178
178
|
|
179
179
|
'FTP::State::Dir' => 'rio/ftp',
|
180
180
|
'FTP::State::File' => 'rio/ftp',
|
data/lib/rio/if.rb
CHANGED
data/lib/rio/if/csv.rb
ADDED
@@ -0,0 +1,76 @@
|
|
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 end
|
41
|
+
#def dir() target.dir end
|
42
|
+
|
43
|
+
# Puts a Rio in CSV mode and sets the field and record separators.
|
44
|
+
# In csv mode selecting with Rio#records will cause each line
|
45
|
+
# read to be parsed into a line with the CSV standard library.
|
46
|
+
# Specifying using Rio#lines to select will return unparsed strings
|
47
|
+
# as normal.
|
48
|
+
#
|
49
|
+
# # copy a csv file, changing the field separator
|
50
|
+
# rio('afile.csv').csv > rio('afile_semicolons.csv').csv(';')
|
51
|
+
#
|
52
|
+
# CSV mode also adds two methods Rio#columns and Rio#nocolumns which
|
53
|
+
# allows selecting columns by column index using Fixnums or Ranges
|
54
|
+
# in a way similar to how lines are selected.
|
55
|
+
#
|
56
|
+
# # iterate through every line but only get the first three columns
|
57
|
+
# rio("afile.csv").csv.columns(0..2) { |array_of_fields| ... }
|
58
|
+
#
|
59
|
+
# # iterate through every line but skip the columns 2 and 3 through 5
|
60
|
+
# rio("afile.csv").csv.nocolumns(2,3..5) { |array_of_fields| ... }
|
61
|
+
#
|
62
|
+
# # an array containg all but the first line returning columns 5,6 and 7
|
63
|
+
# rio("afile.csv").csv.columns(5..7).nolines[0]
|
64
|
+
#
|
65
|
+
# See RIO::Doc::INTRO for complete documentation on csv mode.
|
66
|
+
def csv(field_separator=',',record_separator=nil,&block)
|
67
|
+
target.csv(field_separator,record_separator,&block);
|
68
|
+
self
|
69
|
+
end
|
70
|
+
# Select columns from a CSV file. See Rio#csv and RIO::Doc::INTRO.
|
71
|
+
def columns(*ranges,&block) target.columns(*ranges,&block); self end
|
72
|
+
# Reject columns from a CSV file. See Rio#csv and RIO::Doc::INTRO.
|
73
|
+
def nocolumns(*ranges,&block) target.nocolumns(*ranges,&block); self end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|