[ANN] Rio 0.3.4

R

rio4ruby

New and Improved -- Rio 0.3.4

== 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, 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.

== SYNOPSIS

For the following assume:
astring = ""
anarray = []

Copy or append a file to a string
rio('afile') > astring # copy
rio('afile') >> astring # append

Copy or append a string to a file
rio('afile') < astring # copy
rio('afile') << astring # append

Copy or append the lines of a file to an array
rio('afile') > anarray
rio('afile') >> anarray

Copy or append a file to another file
rio('afile') > rio('another_file')
rio('afile') >> rio('another_file')

Copy a file to a directory
rio('adir') << rio('afile')

Copy a directory structure to another directory
rio('adir') >> rio('another_directory')

Copy a web-page to a file
rio('http://rubydoc.org/') > rio('afile')

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

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| ... }

Iterate over only the files in a directory
rio('adir').files { |entrio| ... }

Iterate over only the .rb files in a directory
rio('adir').files('*.rb') { |entrio| ... }

Iterate over .rb files but not symlinks to .rb files
rio('adir').files('*.rb').skip:)symlink?) { |entrio| ... }

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| ... }

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

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
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
rio('afile.csv').csv { |array_of_fields| ...}

Create a tab separated file of accounts in a UNIX passwd file,
listing only the username, uid, and realname fields
rio('/etc/passwd').csv(':').columns(0,2,4) > rio('rpt').csv("\t")

== New for version 0.3.4

* New Grande Selection parameter.

A major weakness of Rio's selection methods (lines, files, etc.)
has always been that it only implemented a logical OR.

rio('afile').lines(0..10,/Rio/) {...}
iterates through lines that are in the range 0..10 OR
contain 'Rio'.

rio('adir').files:)executable?,'*.rb') {...}
iterates through files that are executable OR match '*.rb'

Selecting files that matched both required using a proc.
rio('adir').files(proc{ |f| f.executable? and f.fnmatch?('*.rb')})
{...}

Rio's grande selection methods will now accept an array of conditions
which must all be matched, in order to be selected. A logical AND.

rio('adir').files([:executable?,'*.rb']) {...}

The array, of course, need not be the only paramter.

rio('adir').files('*.exe',[:executable?,'*.rb']) {...}

selects .exe files and .rb files that are executable.

* Renamed some of grande rejection methods.
(based on a suggestion by Gavin Sinclair)
nolines => skiplines
nofiles => skipfiles
etc.

* New skip() grande method
rio('afile').skip.lines(/Rio/) # same as skiplines(/Rio/)
rio('afile').lines(/Rio/).skip(0..9) # lines with 'Rio', exclude
# the first ten lines

* Alternative syntaxes for creating Rios that have no path.
rio(?-) # create a Rio refering to stdio
rio:)stdio) # same thing.
rio.stdio # same thing
RIO.stdio # ditto
RIO::Rio.stdio # once again

* From Pathname added
* root?
* mountpoint?
* realpath
* cleanpath

* Removed Rio#slurp in favor of Rio#contents.

* Added aliases for the copy operators. (suggested by Dave Burt)
* copy_to >
* append_to >>
* copy_from <
* append_from <<

* Bug fixes and corrections

Project:: http://rubyforge.org/projects/rio/
Documentation:: http://rio.rubyforge.org/
Bugs:: http://rubyforge.org/tracker/?group_id=821
Email:: (e-mail address removed)

== Copyright
Copyright (c) 2005, Christopher Kleckner. All rights reserved

== License
Rio is released under the GNU General Public License
(http://www.gnu.org/licenses/gpl.html)

-Christopher Kleckner
 
J

James Britt

rio4ruby said:
New and Improved -- Rio 0.3.4

== 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, 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.

== SYNOPSIS


This looks super sweet. My teeth hurt!

I also want to say that your announcement, with all the examples, as
well as those by Ara T. Howard (see his Traits release announcements),
are exemplary.

Really great!


Thanks,


James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
Z

Zed A. Shaw

Do people seriously like all these examples in the announcement? I really think this kind of information belongs on a web page showing you how to use it.

Then again, I've seen a disturbing trend of people ignoring anything that isn't in their blackberry. Is that it? Not in e-mail, doesn't exist?

Just curious which people prefer: examples in the announce or refer to a web page where examples are to be found?

Zed A. Shaw
http://www.zedshaw.com/
 
J

James Britt

Zed said:
Do people seriously like all these examples in the announcement? I really think this kind of information belongs on a web page showing you how to use it.

Then again, I've seen a disturbing trend of people ignoring anything that isn't in their blackberry. Is that it? Not in e-mail, doesn't exist?

Just curious which people prefer: examples in the announce or refer to a web page where examples are to be found?

I'm usually stunned that such examples exist at all. After that, I
really don't care where the author puts them.

I appreciate the time and effort spent on code, and the extra time and
effort spent on docs, so see no reason to be concerned.

But I'm willing to cut people some slack when they're offering free
software.


James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
G

Gavin Kistner

Do people seriously like all these examples in the announcement? I
really think this kind of information belongs on a web page showing
you how to use it.

Yes, I love documentation by example, and showing what a class/module/
library does by showing it in action is similar to the "picture worth
a thousand words", for me.

The announcement should, of course, ALSO refer to a web page where
more examples and rigorous documentation exist. But the teaser is
pleasing, to me.
 
C

Corey Lawson

------=_Part_13052_20355439.1126151221993
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Will a modification of IRB with RIO, and a few other things, possibly resul=
t=20
in a "ruby shell" that blows Monad away (but results in scripts that are=20
more or less portable between Win32, MacOS, and *nix?


=20
New and Improved -- Rio 0.3.4
=20
=3D=3D Overview
=20
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, 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.
=20
=3D=3D SYNOPSIS
=20
For the following assume:
astring =3D ""
anarray =3D []
=20
Copy or append a file to a string
rio('afile') > astring # copy
rio('afile') >> astring # append
=20
Copy or append a string to a file
rio('afile') < astring # copy
rio('afile') << astring # append
=20
Copy or append the lines of a file to an array
rio('afile') > anarray
rio('afile') >> anarray
=20
Copy or append a file to another file
rio('afile') > rio('another_file')
rio('afile') >> rio('another_file')
=20
Copy a file to a directory
rio('adir') << rio('afile')
=20
Copy a directory structure to another directory
rio('adir') >> rio('another_directory')
=20
Copy a web-page to a file
rio('http://rubydoc.org/') > rio('afile')
=20
Ways to get the chomped lines of a file into an array
anarray =3D rio('afile').chomp[] # subscript operator
rio('afile').chomp > anarray # copy-to operator
anarray =3D rio('afile').chomp.to_a # to_a
anarray =3D rio('afile').chomp.readlines # IO#readlines
=20
Copy a gzipped file un-gzipping it
rio('afile.gz').gzip > rio('afile')
=20
Copy a plain file, gzipping it
rio('afile.gz').gzip < rio('afile')
=20
Copy a file from a ftp server into a local file un-gzipping it
rio('ftp://host/afile.gz').gzip > rio('afile')
=20
Iterate over the entries in a directory
rio('adir').entries { |entrio| ... }
=20
Iterate over only the files in a directory
rio('adir').files { |entrio| ... }
=20
Iterate over only the .rb files in a directory
rio('adir').files('*.rb') { |entrio| ... }
=20
Iterate over .rb files but not symlinks to .rb files
rio('adir').files('*.rb').skip:)symlink?) { |entrio| ... }
=20
Iterate over only the _dot_ files in a directory
rio('adir').files(/^\./) { |entrio| ... }
=20
Iterate over the files in a directory and its subdirectories, skipping
'.svn' and 'CVS' directories
=20
rio('adir').norecurse(/^\.svn$/,'CVS').files { |entrio| ... }
=20
Create an array of the .rb entries in a directory
anarray =3D rio('adir')['*.rb']
=20
Create an array of the .rb entries in a directory and its
subdirectories.
anarray =3D rio('adir').all['*.rb']
=20
Iterate over the .rb files in a directory and its subdirectories
rio('adir').all.files('*.rb') { |entrio| ... }
=20
Iterate over the non-empty, non-comment chomped lines of a file
rio('afile').chomp.skip.lines:)empty?,/^\s*#/) { |line| ... }
=20
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
=20
Prompt for input and return what was typed
ans =3D rio(?-).print("Type Something: ").chomp.gets
=20
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 =3D '.html'
end
=20
Create a symbolic link 'asymlink' in 'adir' which refers to
'adir/afile'
rio('adir/afile').symlink('adir/asymlink')
=20
Copy a CSV file, changing the separator to a semicolon
rio('comma.csv').csv > rio('semicolon.csv').csv(';')
=20
Iterate through a CSVfile with each line parsed into an array
rio('afile.csv').csv { |array_of_fields| ...}
=20
Create a tab separated file of accounts in a UNIX passwd file,
listing only the username, uid, and realname fields
rio('/etc/passwd').csv(':').columns(0,2,4) > rio('rpt').csv("\t")
=20
=3D=3D New for version 0.3.4
=20
* New Grande Selection parameter.
=20
A major weakness of Rio's selection methods (lines, files, etc.)
has always been that it only implemented a logical OR.
=20
rio('afile').lines(0..10,/Rio/) {...}
iterates through lines that are in the range 0..10 OR
contain 'Rio'.
=20
rio('adir').files:)executable?,'*.rb') {...}
iterates through files that are executable OR match '*.rb'
=20
Selecting files that matched both required using a proc.
rio('adir').files(proc{ |f| f.executable? and f.fnmatch?('*.rb')})
{...}
=20
Rio's grande selection methods will now accept an array of conditions
which must all be matched, in order to be selected. A logical AND.
=20
rio('adir').files([:executable?,'*.rb']) {...}
=20
The array, of course, need not be the only paramter.
=20
rio('adir').files('*.exe',[:executable?,'*.rb']) {...}
=20
selects .exe files and .rb files that are executable.
=20
* Renamed some of grande rejection methods.
(based on a suggestion by Gavin Sinclair)
nolines =3D> skiplines
nofiles =3D> skipfiles
etc.
=20
* New skip() grande method
rio('afile').skip.lines(/Rio/) # same as skiplines(/Rio/)
rio('afile').lines(/Rio/).skip(0..9) # lines with 'Rio', exclude
# the first ten lines
=20
* Alternative syntaxes for creating Rios that have no path.
rio(?-) # create a Rio refering to stdio
rio:)stdio) # same thing.
rio.stdio # same thing
RIO.stdio # ditto
RIO::Rio.stdio # once again
=20
* From Pathname added
* root?
* mountpoint?
* realpath
* cleanpath
=20
* Removed Rio#slurp in favor of Rio#contents.
=20
* Added aliases for the copy operators. (suggested by Dave Burt)
* copy_to >
* append_to >>
* copy_from <
* append_from <<
=20
* Bug fixes and corrections
=20
Project:: http://rubyforge.org/projects/rio/
Documentation:: http://rio.rubyforge.org/
Bugs:: http://rubyforge.org/tracker/?group_id=3D821
Email:: (e-mail address removed)
=20
=3D=3D Copyright
Copyright (c) 2005, Christopher Kleckner. All rights reserved
=20
=3D=3D License
Rio is released under the GNU General Public License
(http://www.gnu.org/licenses/gpl.html)
=20
-Christopher Kleckner
=20
=20

------=_Part_13052_20355439.1126151221993--
 
J

Jerome

So is it for me. I would never gem install it at once if this brillant
vanilla synopsis wasn't posted. Great work !
 
L

Lloyd Zusman

rio4ruby said:
New and Improved -- Rio 0.3.4

[ ... ]

This looks great!

However, I'm seeing a problem. I installed this via "gem install rio",
but I get an error when I try to run it. Does anyone know how I
can prevent the error below?

Thanks in advance.

% gem list rio
*** LOCAL GEMS ***

rio (0.3.4)
Rio - Ruby I/O Comfort Class
% echo abc >/tmp/abc
% cat /tmp/abc
abc
% irb
irb(main):001:0> require_gem 'rio'
=> true
irb(main):002:0> rio('/tmp/abc') > rio('/tmp/xyz')
NameError: uninitialized constant RIO::Ops::FileOrDir::ExistOrNot
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/ops/file.rb:62
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require__'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/file.rb:39
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require__'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:197:in
`state2class'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:206:in
`try_state_proc'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:204:in `[]'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:120:in `become'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/path.rb:80:in
`efile'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/path.rb:65:in
`when_missing'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:134:in
`method_missing'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:136:in
`__send__'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:136:in
`method_missing'
from
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/if/grande.rb:402:in `>'
from (irb):2irb(main):003:0>
irb(main):004:0*
 
R

rio4ruby

Lloyd said:
% irb
irb(main):001:0> require_gem 'rio'
=> true
irb(main):002:0> rio('/tmp/abc') > rio('/tmp/xyz')
NameError: uninitialized constant RIO::Ops::FileOrDir::ExistOrNot
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/ops/file.rb:62
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
....
I can not reproduce this. My irb session looks like this:

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require_gem 'rio'
=> true
irb(main):003:0> rio('/tmp/abc') > rio('/tmp/xyz')
=> #<Rio:0x812ed94:"file:///tmp/abc" (Stream::Close)>
% cat /tmp/xyz
abc
%

The only difference between mine and yours, is "require 'rubygems'",
and when I leave that off I get an entirely different error:

irb(main):001:0> require_gem 'rio'
NoMethodError: undefined method `require_gem' for main:Object
from (irb):1
irb(main):002:0> rio('/tmp/abc') > rio('/tmp/xyz')
NoMethodError: undefined method `rio' for main:Object
from (irb):2

I admit that I have done very little testing on the gem installation
of Rio. If you figure this out please let me know, so I can document
it for other gem users.

Cheers,
-Christopher
 
L

Lloyd Zusman

rio4ruby said:
....
I can not reproduce this. My irb session looks like this:

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require_gem 'rio'
=> true
irb(main):003:0> rio('/tmp/abc') > rio('/tmp/xyz')
=> #<Rio:0x812ed94:"file:///tmp/abc" (Stream::Close)>
% cat /tmp/xyz
abc
%

The only difference between mine and yours, is "require 'rubygems'",
and when I leave that off I get an entirely different error:

irb(main):001:0> require_gem 'rio'
NoMethodError: undefined method `require_gem' for main:Object
from (irb):1
irb(main):002:0> rio('/tmp/abc') > rio('/tmp/xyz')
NoMethodError: undefined method `rio' for main:Object
from (irb):2

I admit that I have done very little testing on the gem installation
of Rio. If you figure this out please let me know, so I can document
it for other gem users.

Cheers,
-Christopher

Thanks for looking into this. I'll keep testing and see if I can
isolate the
problem.

By the way, the reason that I didn't need "require 'rubygems'" is because
I have the RUBYOPT environment variable set to "rubygems". If I unset
this variable and do a "require 'rubygems'" before the "require_gem 'rio'"
command, I get the same error.

Also, in case this might shed some light on my problem ...

% ruby --version
ruby 1.8.2 (2004-12-25) [i686-linux]
% gem --version
0.8.11

Prior to this, I had earlier problems with gems, and so I completely
uninstalled ruby (I had been using the 1.9.x version from cvs), and I
re-installed it from the official 1.8.2 version, totally from scratch with
none of my old libraries, scripts, or gems present on my system. It
was only then that I installed "gem", and then "rio".

Thanks again for any help you folks might be able to give me on this.
 
W

Wybo Dekker

--Boundary_(ID_v/Y3xKsxTjapmauGvYCETg)
Content-type: text/plain; charset=ISO-8859-1; format=flowed
Content-transfer-encoding: 7BIT

Lloyd said:
Prior to this, I had earlier problems with gems, and so I completely
uninstalled ruby (I had been using the 1.9.x version from cvs), and I
re-installed it from the official 1.8.2 version, totally from scratch with
none of my old libraries, scripts, or gems present on my system. It
was only then that I installed "gem", and then "rio".

I, too, have the problem and had ruby-1.9 before.

My test program:

#!/usr/bin/env ruby
require 'rio'
$VERBOSE = true
rio('/etc/passwd') > rio('/tmp/passwd')

This worked fine with rio-0.3.3 but fails with 0.3.4.
I have attached the output, for what it's worth.

wybo>ruby -v
ruby 1.8.2 (2004-12-25) [i686-linux]
wybo>gem -v
0.8.11

--
Wybo

--Boundary_(ID_v/Y3xKsxTjapmauGvYCETg)
Content-type: text/plain; name=riotestoutput
Content-transfer-encoding: 7BIT
Content-disposition: inline; filename=riotestoutput

wybo>gem list rio

*** LOCAL GEMS ***

rio (0.3.4, 0.3.3)
Rio - Ruby I/O Comfort Class
wybo>ls /tmp
wybo>cat riotest
#!/usr/bin/env ruby

require 'rio'
$VERBOSE = true

rio('/etc/passwd') > rio('/tmp/passwd')
wybo>riotest
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/cp.rb:190: warning: useless use of < in void context
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/cp.rb:290: warning: useless use of > in void context
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/ops/file.rb:62: uninitialized constant RIO::Ops::FileOrDir::ExistOrNot (NameError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/file.rb:39
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:197:in `state2class'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:206:in `try_state_proc'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:204:in `[]'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:120:in `become'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/path.rb:80:in `efile'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/path.rb:65:in `when_missing'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:134:in `method_missing'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:136:in `__send__'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:136:in `method_missing'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/if/grande.rb:402:in `>'
from ./riotest:6
wybo>ls /tmp
wybo>sudo gem uninstall rio -v 0.3.4
Attempting to uninstall gem 'rio'
Successfully uninstalled rio version 0.3.4
wybo>riotest
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.3/lib/rio/cp.rb:181: warning: useless use of < in void context
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.3/lib/rio/cp.rb:273: warning: useless use of > in void context
wybo>ls /tmp
passwd
wybo>

--Boundary_(ID_v/Y3xKsxTjapmauGvYCETg)--
 
L

Lloyd Zusman

Wybo Dekker said:
I, too, have the problem and had ruby-1.9 before.

I found a work-around for this problem, but I don't understand why it
fixes it, and why the module wasn't functioning properly in the first
place.

After looking this over, do any of you have any idea why this was
failing, and why this fix worked?

As you can see from the stack trace at the bottom of this message, which
both Wybo and I were getting, the "ExistOrNot" module was not found.
However, moving the following code fragment closer to the top of the
following file seems to fix the problem.

The file:

.../gems/rio-0.3.4/lib/rio/ops/either.rb

The code fragment:

module ExistOrNot
end
module Existing
include ExistOrNot
end
module NonExisting
include ExistOrNot
end

Here's my patch which fixes this:

*** either.rb.orig Sat Sep 10 09:13:51 2005
--- either.rb Sat Sep 10 09:15:11 2005
***************
*** 54,57 ****
--- 54,67 ----
module Ops
module FileOrDir
+
+ module ExistOrNot
+ end
+ module Existing
+ include ExistOrNot
+ end
+ module NonExisting
+ include ExistOrNot
+ end
+
module Existing
def chmod(mod) rtn_self { Impl::U.chmod(mod,fspath) } end
***************
*** 117,129 ****

end
-
- module ExistOrNot
- end
- module Existing
- include ExistOrNot
- end
- module NonExisting
- include ExistOrNot
- end
end
end
--- 127,130 ----


Wybo Dekker said:
My test program:

[ ... etc. ... ]

wybo>cat riotest
#!/usr/bin/env ruby

require 'rio'
$VERBOSE = true

rio('/etc/passwd') > rio('/tmp/passwd')
wybo>riotest
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/cp.rb:190: warning: useless use of < in void context
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/cp.rb:290: warning: useless use of > in void context
/usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/ops/file.rb:62: uninitialized constant RIO::Ops::FileOrDir::ExistOrNot (NameError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/file.rb:39
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:197:in `state2class'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:206:in `try_state_proc'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/factory.rb:204:in `[]'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:120:in `become'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/path.rb:80:in `efile'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/path.rb:65:in `when_missing'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:134:in `method_missing'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:136:in `__send__'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/state.rb:136:in `method_missing'
from /usr/local/lib/ruby/gems/1.8/gems/rio-0.3.4/lib/rio/if/grande.rb:402:in `>'
from ./riotest:6

[ ... ]
 
R

rio4ruby

Lloyd said:
I found a work-around for this problem, but I don't understand why it
fixes it, and why the module wasn't functioning properly in the first
place.
I still can't reproduce this. The Rio software is broken up over many
(perhaps too many) files, and somehow you got to code that was
including that module before it was evalutated by the interpreter. I
think your patch is right on target. That code really should be right
where you put it. I have made that change permanent -- it will be in
the next release. Thanks!

Cheers,
-Christopher
 
L

Lloyd Zusman

rio4ruby said:
I still can't reproduce this. The Rio software is broken up over many
(perhaps too many) files, and somehow you got to code that was
including that module before it was evalutated by the interpreter. I
think your patch is right on target. That code really should be right
where you put it. I have made that change permanent -- it will be in
the next release. Thanks!

Cheers,
-Christopher

I'm glad to help :)

I'm wondering if this behavior has something to do with the way that the
gem system evaluates files that it includes. This might have some
subtle idiosyncracies.

But anyway, it works now, and that's what's most important. All's well
that ends well!

Thanks.
 
J

Jim Morris

I also see a similar problem with 0.3.4 but I installed it the old
fashioned way not using gem... (0.3.3 works fine BTW)

ruby t.rb
/usr/local/lib/ruby/site_ruby/1.8/rio/ops/either.rb:110:in `require': No
such file toload -- Pathname (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rio/ops/either.rb:110
from /usr/local/lib/ruby/site_ruby/1.8/rio/ops/file.rb:61:in
`require'
from /usr/local/lib/ruby/site_ruby/1.8/rio/ops/file.rb:61
from /usr/local/lib/ruby/site_ruby/1.8/rio/file.rb:39:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rio/file.rb:39
from /usr/local/lib/ruby/site_ruby/1.8/rio/factory.rb:197:in
`require'
from /usr/local/lib/ruby/site_ruby/1.8/rio/factory.rb:197:in
`state2class'
from /usr/local/lib/ruby/site_ruby/1.8/rio/factory.rb:206:in
`try_state_proc'
... 7 levels...
from /usr/local/lib/ruby/site_ruby/1.8/rio/state.rb:136:in
`__send__'
from /usr/local/lib/ruby/site_ruby/1.8/rio/state.rb:136:in
`method_missing'
from /usr/local/lib/ruby/site_ruby/1.8/rio/if/grande.rb:402:in `>'
from t.rb:4

where t.rb is...

require 'rio'

str= ""
rio('t.asv') > str

puts "#{str}"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top