doc/ANNOUNCE in rio-0.3.9 vs doc/ANNOUNCE in rio-0.4.0
- old
+ new
@@ -1,23 +1,41 @@
-Rio 0.3.9
+Rio 0.4.0
+= Rio - Ruby I/O Facilitator
+
== Overview
-Rio is a Ruby I/O convenience class wrapping much of the functionality
-of IO, File and Dir. Rio also uses FileUtils, Tempfile, StringIO,
-OpenURI, Net::FTP, Zlib, and CSV to provide similar functionality
-using a simple consistent interface. In addition to forwarding the
-interfaces provided by IO, File, and Dir to an appropriate object, Rio
-provides a "grande" interface that allows many common application
-level I/O and file-system tasks to be expressed succinctly.
+Rio is a facade for most of the standard ruby classes that deal with I/O;
+providing a simple, intuitive, succinct interface to the functionality
+provided by IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI
+and others. Rio also provides an application level interface which allows many
+common I/O idioms to be expressed succinctly.
-= SYNOPSIS
+== SYNOPSIS
+
+fa-cil-i-tate: To make easy or easier [http://www.thefreedictionary.com/facilitate]
+
For the following assume:
astring = ""
anarray = []
+Iterate over the .rb files in a directory.
+ rio('adir').files('*.rb') { |entrio| ... }
+
+Return an array of the .rb files in a directory.
+ rio('adir').files['*.rb']
+
+Copy the .rb files in a directory.to another directory.
+ rio('adir').files('*.rb') > rio('another_directory')
+
+Iterate over the .rb files in a directory and its subdirectories.
+ rio('adir').all.files('*.rb') { |entrio| ... }
+
+Return an array of the .rb files in a directory and its subdirectories.
+ rio('adir').all.files['*.rb']
+
Copy or append a file to a string
rio('afile') > astring # copy
rio('afile') >> astring # append
Copy or append a string to a file
@@ -33,79 +51,76 @@
rio('afile') >> rio('another_file')
Copy a file to a directory
rio('adir') << rio('afile')
-Copy a directory structure to another directory
+Copy a directory to another directory
rio('adir') >> rio('another_directory')
Copy a web-page to a file
rio('http://rubydoc.org/') > rio('afile')
+Read a web-page into a string
+ astring = rio('http://rubydoc.org/').read
+
Ways to get the chomped lines of a file into an array
anarray = rio('afile').chomp[] # subscript operator
rio('afile').chomp > anarray # copy-to operator
anarray = rio('afile').chomp.to_a # to_a
anarray = rio('afile').chomp.readlines # IO#readlines
+Iterate over selected lines of a file
+ rio('adir').lines(0..3) { |aline| ... } # a range of lines
+ rio('adir').lines(/re/) { |aline| ... } # by regular expression
+ rio('adir').lines(0..3,/re/) { |aline| ... } # or both
+
+Return selected lines of a file as an array
+ rio('adir').lines[0..3] # a range of lines
+ rio('adir').lines[/re/] # by regular expression
+ rio('adir').lines[0..3,/re/] # or both
+
+Iterate over selected chomped lines of a file
+ rio('adir').chomp.lines(0..3) { |aline| ... } # a range of lines
+ rio('adir').chomp.lines(/re/) { |aline| ... } # by regular expression
+
+Return selected chomped lines of a file as an array
+ rio('adir').chomp[0..3] # a range of lines
+ rio('adir').chomp[/re/] # by regular expression
+
Copy a gzipped file un-gzipping it
rio('afile.gz').gzip > rio('afile')
Copy a plain file, gzipping it
rio('afile.gz').gzip < rio('afile')
Copy a file from a ftp server into a local file un-gzipping it
rio('ftp://host/afile.gz').gzip > rio('afile')
-Iterate over the entries in a directory
- rio('adir').entries { |entrio| ... }
+Return an array of .rb files excluding symlinks to .rb files
+ rio('adir').files('*.rb').skip[:symlink?]
-Iterate over only the files in a directory
- rio('adir').files { |entrio| ... }
+Put the first 10 chomped lines of a gzipped file into an array
+ anarray = rio('afile.gz').chomp.gzip[0...10]
-Iterate over only the .rb files in a directory
- rio('adir').files('*.rb') { |entrio| ... }
+Copy lines 0 and 3 thru 5 of a gzipped file on an ftp server to stdout
+ rio('ftp://host/afile.gz').gzip.lines(0,3..5) > ?-
-Iterate over .rb files but not symlinks to .rb files
- rio('adir').files('*.rb').skip(:symlink?) { |entrio| ... }
+Return an array of files in a directory and its subdirectories, without descending into .svn directories.
+ rio('adir').norecurse(/^\.svn$/).files[]
-Iterate over only the _dot_ files in a directory
- rio('adir').files(/^\./) { |entrio| ... }
-
-Iterate over the files in a directory and its subdirectories, skipping
-'.svn' and 'CVS' directories
-
- rio('adir').norecurse(/^\.svn$/,'CVS').files { |entrio| ... }
-
-Create an array of the .rb entries in a directory
- anarray = rio('adir')['*.rb']
-
-Create an array of the .rb entries in a directory and its
-subdirectories.
- anarray = rio('adir').all['*.rb']
-
-Iterate over the .rb files in a directory and its subdirectories
- rio('adir').all.files('*.rb') { |entrio| ... }
-
Iterate over the non-empty, non-comment chomped lines of a file
- rio('afile').chomp.skip.lines(:empty?,/^\s*#/) { |line| ... }
+ rio('afile').chomp.skip(:empty?,/^\s*#/) { |line| ... }
-Copy the output of th ps command into an array, skipping the header
-line and the ps command entry
- rio(?-,'ps -a').skip.lines(0,/ps$/) > anarray
+Copy the output of th ps command into an array, skipping the header line and the ps command entry
+ rio(?-,'ps -a').skiplines(0,/ps$/) > anarray
Prompt for input and return what was typed
ans = rio(?-).print("Type Something: ").chomp.gets
-Change the extension of all .htm files in a directory and its
-subdirectories to .html
+Change the extension of all .htm files in a directory and its subdirectories to .html
rio('adir').rename.all.files('*.htm') do |htmfile|
htmfile.extname = '.html'
end
-
-Create a symbolic link 'asymlink' in 'adir' which refers to
-'adir/afile'
- rio('adir/afile').symlink('adir/asymlink')
Copy a CSV file, changing the separator to a semicolon
rio('comma.csv').csv > rio('semicolon.csv').csv(';')
Iterate through a CSVfile with each line parsed into an array