Ask a Question related to Ruby, Design and Development.
-
Xavier #1
Article on oreilly.net on how to build Unix tools with Ruby
Thought you'd like to know about this article
This links to the printable version, much easier to read.
[url]http://linux.oreillynet.com/lpt/a/4159[/url]
Enjoy.
Xavier Guest
-
Article : Security Tools Part -- 2 (.Net FrameWork Tools Series)
Hey Group, Yesterday we created our own certificate installed the certificate in the certificate store and even created a key container for the... -
Article: What is Isolated Storage ? (.Net FrameWork Tools Series)
Hey Group, After a long week end I am back again. Its nice and refreshing after a short vacation so lets get started with .NET once again. ... -
Article : Code Access Security Part - 2 (.Net FrameWork Tools Series)
Hey Guys, Before we start with our sample app we need to view the security configuration files on the machine. You will find them under ... -
Article : Code Access Security Part - 1 (.Net FrameWork Tools Series)
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its... -
An article on using Ruby to drive a Java hourly build...
...is on the O'Reilly web site here: http://www.onjava.com/pub/a/onjava/2003/09/10/dashboard.html The more the merrier... Yours, Tom -- -
Paul Brannan #2
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Sat, Sep 20, 2003 at 06:00:21AM +0900, Xavier wrote:
A pretty good article, though:> Thought you'd like to know about this article
> This links to the printable version, much easier to read.
> [url]http://linux.oreillynet.com/lpt/a/4159[/url]
>
> Enjoy.
1. It would be nice if it mentioned optparse, which is a little
cleaner than getoptlong for what the author is doing.
2. Using "while line = gets do" is just as clean as "while gets", but
doesn't require the use of $_. I suspect the author came from a
perl background.
3. I wish he'd mentioned the option of using #!/usr/bin/env ruby
instead of #!/usr/local/bin/ruby.
Paul
Paul Brannan Guest
-
Geoffrey S. Knauth #3
Re: Article on oreilly.net on how to build Unix tools with Ruby
Xavier <NOSPAM@keepyourspam.com> wrote:
Nice script for handling CSVs. But it doesn't handle commas embedded in> Thought you'd like to know about this article
> This links to the printable version, much easier to read.
> [url]http://linux.oreillynet.com/lpt/a/4159[/url]
double quotes (yet).
--
Geoffrey S. Knauth | [url]http://knauth.org/gsk[/url]
Geoffrey S. Knauth Guest
-
Jim Menard #4
Re: Article on oreilly.net on how to build Unix tools with Ruby
[email]geoff@knauth.org[/email] (Geoffrey S. Knauth) writes:
If anyone wants one, I've got a DelimParser class that handles different> Xavier <NOSPAM@keepyourspam.com> wrote:>> > Thought you'd like to know about this article
> > This links to the printable version, much easier to read.
> > [url]http://linux.oreillynet.com/lpt/a/4159[/url]
> Nice script for handling CSVs. But it doesn't handle commas embedded in
> double quotes (yet).
delimiters and quote marks as well as delimiters, escaped characters, and
doubled quotes that appear in the data.
It doesn't use regexps. It's a simple state machine that walks through each
character in the input.
Ask and thou shall receive.
Jim
--
Jim Menard, [email]jimm@io.com[/email], [url]http://www.io.com/~jimm/[/url]
"$665.95: The Retail Price of the Beast" -- Unknown
Jim Menard Guest
-
Michael Campbell #5
Re: Article on oreilly.net on how to build Unix tools with Ruby
> If anyone wants one, I've got a DelimParser class that handles
differentcharacters, and> delimiters and quote marks as well as delimiters, escapedI'd like to get a copy of that please.> doubled quotes that appear in the data.
>
> It doesn't use regexps. It's a simple state machine that walks
> through each character in the input.
>
> Ask and thou shall receive.
I've used [url]http://raa.ruby-lang.org/list.rhtml?name=csv[/url] in the past,
and while it works for my feeble CSV needs, I find the interface
somewhat [overly] complex.
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
[url]http://sitebuilder.yahoo.com[/url]
Michael Campbell Guest
-
gabriele renzi #6
Re: Article on oreilly.net on how to build Unix tools with Ruby
il 23 Sep 2003 15:06:01 -0500, Jim Menard <jimm@io.com> ha scritto::
>It doesn't use regexps. It's a simple state machine that walks through each
>character in the input.
>
>Ask and thou shall receive.
would you please send me a copy or publish it on RAA ?
gabriele renzi Guest
-
Jim Menard #7
Re: Article on oreilly.net on how to build Unix tools with Ruby
gabriele renzi <surrender_it@remove.yahoo.it> writes:
Gabriele,> il 23 Sep 2003 15:06:01 -0500, Jim Menard <jimm@io.com> ha scritto::
>>> >It doesn't use regexps. It's a simple state machine that walks through each
> >character in the input.
> >
> >Ask and thou shall receive.
>
> would you please send me a copy or publish it on RAA ?
>
I emailed it to you and Michael and posted it to
<http://www.io.com/~jimm/downloads/index.html>.
Jim
--
Jim Menard, [email]jimm@io.com[/email], [url]http://www.io.com/~jimm/[/url]
"Unix is extremely user-friendly. It also happens to be extremely
selective when picking its friends." -- Daniel E. Macks
Jim Menard Guest
-
Jim Freeze #8
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Wednesday, 24 September 2003 at 5:15:41 +0900, Jim Menard wrote:
I have found that the csv parser by NaHi to be very good and> [email]geoff@knauth.org[/email] (Geoffrey S. Knauth) writes:
>>> > Xavier <NOSPAM@keepyourspam.com> wrote:> >> > > Thought you'd like to know about this article
> > > This links to the printable version, much easier to read.
> > > [url]http://linux.oreillynet.com/lpt/a/4159[/url]
> > Nice script for handling CSVs. But it doesn't handle commas embedded in
> > double quotes (yet).
full featured.
[url]http://raa.ruby-lang.org/list.rhtml?name=csv[/url]
--
Jim Freeze
----------
God made the world in six days, and was arrested on the seventh.
Jim Freeze Guest
-
Gavin Sinclair #9
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Wednesday, September 24, 2003, 2:33:01 AM, Paul wrote:
> 3. I wish he'd mentioned the option of using #!/usr/bin/env ruby
> instead of #!/usr/local/bin/ruby.
Can someone please explain to me what /usr/bin/env/ruby does?
Thanks,
Gavin
Gavin Sinclair Guest
-
Michael W Thelen #10
Re: Article on oreilly.net on how to build Unix tools with Ruby
* Gavin Sinclair <gsinclair@soyabean.com.au> [2003-09-23 17:16]:
Note that there's no slash between "env" and "ruby"... env is a program that> On Wednesday, September 24, 2003, 2:33:01 AM, Paul wrote:>> > 3. I wish he'd mentioned the option of using #!/usr/bin/env ruby
> > instead of #!/usr/local/bin/ruby.
> Can someone please explain to me what /usr/bin/env/ruby does?
lets you run a program in a modified environment, and it's also useful on the
shebang line if you don't know the exact location of the interpreter you want
to run. It will find the executable in the path before executing it.
-- Mike
--
Michael W. Thelen
Experience is what you get when you don't get what you want.
-- Dan Stanford
Michael W Thelen Guest
-
Jim Freeze #11
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Wednesday, 24 September 2003 at 8:24:36 +0900, Michael W Thelen wrote:
Speaking of env, does this work on linux when options are passed> * Gavin Sinclair <gsinclair@soyabean.com.au> [2003-09-23 17:16]:> > On Wednesday, September 24, 2003, 2:33:01 AM, Paul wrote:> >> > > 3. I wish he'd mentioned the option of using #!/usr/bin/env ruby
> > > instead of #!/usr/local/bin/ruby.
> > Can someone please explain to me what /usr/bin/env/ruby does?
to ruby?
I'm not at a linux terminal right now, but when the shebang is:
/usr/bin/env ruby -w
I get the error that ruby -w is not found.
The gnu manual says that it should work, but it certainly
doesn't work as it does on FreeBSD or Sun.
The distro is RH 7.3.
--
Jim Freeze
----------
Adore, v.:
To venerate expectantly.
-- Ambrose Bierce, "The Devil's Dictionary"
Jim Freeze Guest
-
Paul Brannan #12
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Wed, Sep 24, 2003 at 09:04:55AM +0900, Jim Freeze wrote:
No, it doesn't. I've seen a detailed explanation somewhere on a perl> Speaking of env, does this work on linux when options are passed
> to ruby?
mailing list or newsgroup, but I can't remember the specifics.
Paul
Paul Brannan Guest
-
NAKAMURA, Hiroshi #13
Re: Article on oreilly.net on how to build Unix tools with Ruby
Hi,
> From: "Jim Freeze" <jim@freeze.org>
> Sent: Wednesday, September 24, 2003 7:05 AM> > > Xavier <NOSPAM@keepyourspam.com> wrote:
> > > > Thought you'd like to know about this article
> > > > This links to the printable version, much easier to read.
> > > > [url]http://linux.oreillynet.com/lpt/a/4159[/url]
> > >
> > > Nice script for handling CSVs. But it doesn't handle commas embedded in
> > > double quotes (yet).And is bundled in ruby from 1.8...> I have found that the csv parser by NaHi to be very good and
> full featured.
>
> [url]http://raa.ruby-lang.org/list.rhtml?name=csv[/url]
It can parse <<__EOS__.chomp
a,b,",","""","\r\n","\r","\n"
__EOS__
Of cource it must have easy interface!
Any suggestion are welcome. How do you want to write
parsing code?
Regards,
// NaHi
PS. Current interface;
SYNOPSIS
1. reader = CSV.open( filename, "r" )
2. CSV.open( filename, "r" ) do | row |
...
end
3. writer = CSV.open( filename, "w" )
4. CSV.open( filename, "w" ) do | writer |
...
end
ARGS
filename: filename to open.
mode: "r" for read (parse)
"w" for write (generate)
row: an Array of cells which is a parsed line.
writer: Created writer instance. See CSV::Writer#<< and
CSV::Writer#addRow to know how to generate CSV string.
RETURNS
reader: Create reader instance. To get parse result, see
CSV::Reader#each.
writer: Created writer instance. See CSV::Writer#<< and
CSV::Writer#addRow to know how to generate CSV string.
DESCRIPTION
Open a CSV formatted file to read or write.
EXAMPLE 1
reader = CSV.open( "csvfile.csv", "r" )
row1 = reader.shift
row2 = reader.shift
if row2.empty?
p "row2 not find."
end
reader.close
EXAMPLE 2
CSV.open( "csvfile.csv", "r" ) do | row |
p row
end
EXAMPLE 3
writer = CSV.open( "csvfile.csv", "w" )
writer << [ "r1c1", "r1c2" ] << [ "r2c1", "r2c2" ] << [ nil, nil ]
writer.close
EXAMPLE 4
CSV.open( "csvfile.csv", "w" ) do | writer |
writer << [ "r1c1", "r1c2" ]
writer << [ "r2c1", "r2c2" ]
writer << [ nil, nil ]
end
NAKAMURA, Hiroshi Guest
-
NAKAMURA, Hiroshi #14
Re: Article on oreilly.net on how to build Unix tools with Ruby
Hi,
> From: "NAKAMURA, Hiroshi" <nakahiro@sarion.co.jp>
> Sent: Wednesday, September 24, 2003 11:54 AMI didn't mean "it must be easy already without any modification".> Of cource it must have easy interface!
> Any suggestion are welcome. How do you want to write
> parsing code?
I mean "it should have easy interface if the current interface
is not easy".
Where's my teacher of English composition?
Regards,
// NaHi
NAKAMURA, Hiroshi Guest
-
Bermejo, Rodrigo #15
Re: Article on oreilly.net on how to build Unix tools with Ruby
Paul Brannan wrote:
advantages ?>
>
> 3. I wish he'd mentioned the option of using #!/usr/bin/env ruby
> instead of #!/usr/local/bin/ruby.
>
>Paul
>
>
>
-r.
Bermejo, Rodrigo Guest
-
Jim Freeze #16
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Wednesday, 24 September 2003 at 12:30:24 +0900, Bermejo, Rodrigo wrote:
I thought someone had already mentioned the advantages.>
> Paul Brannan wrote:
>> advantages ?> >
> >
> > 3. I wish he'd mentioned the option of using #!/usr/bin/env ruby
> > instead of #!/usr/local/bin/ruby.
> >
>
Basically, you don't need to know the path of ruby.
So, if you are distributing an application, your app
will run no matter where ruby is installed.
There are also options that you can pass to env to
control environment variables.
The main disadvantage is that using env increases
the security risk over a hard coded path.
--
Jim Freeze
----------
It is now 10 p.m. Do you know where Henry Kissinger is?
-- Elizabeth Carpenter
Jim Freeze Guest
-
David Garamond #17
Re: Article on oreilly.net on how to build Unix tools with Ruby
> On Sat, Sep 20, 2003 at 06:00:21AM +0900, Xavier wrote:
Speaking of Unix tools, do any of the Perlians in this list remember Tom>>>Thought you'd like to know about this article
>>This links to the printable version, much easier to read.
>>[url]http://linux.oreillynet.com/lpt/a/4159[/url]
>>
>>Enjoy.
Christiansen's pet project Perl Power Tools?
[url]http://www.perl.com/language/ppt/[/url]
The project aims to rewrite many Unix commands in Perl, from simple
commands like 'echo', 'clear', and 'cat' to moderately complex ones like
'cp', 'find', and 'ls' to complex ones like 'awk', 'make', and 'm4'.
Take a look at the URL above, they seem to have implemented a good chunk
of them.
Perhaps someone with extra free time on his hands would like to take a
stab on a Ruby Power Tools project? ;-)
--
dave
David Garamond Guest
-
Mike Stok #18
Re: Article on oreilly.net on how to build Unix tools with Ruby
In article <20030923200517.A36392@freeze.org>,
Jim Freeze <jim@freeze.org> wrote:One way of getting arounf env's ignoring ARGS iff you are just doing -w>On Wednesday, 24 September 2003 at 8:24:36 +0900, Michael W Thelen wrote:>>> * Gavin Sinclair <gsinclair@soyabean.com.au> [2003-09-23 17:16]:>> > On Wednesday, September 24, 2003, 2:33:01 AM, Paul wrote:
>> > > 3. I wish he'd mentioned the option of using #!/usr/bin/env ruby
>> > > instead of #!/usr/local/bin/ruby.
>> >
>> > Can someone please explain to me what /usr/bin/env/ruby does?
>Speaking of env, does this work on linux when options are passed
>to ruby?
>
>I'm not at a linux terminal right now, but when the shebang is:
>
> /usr/bin/env ruby -w
>
> I get the error that ruby -w is not found.
> The gnu manual says that it should work, but it certainly
> doesn't work as it does on FreeBSD or Sun.
is to put
$VERBOSE = true
after the shebang line. See
[url]http://mail.gnu.org/archive/html/bug-sh-utils/2002-04/msg00020.html[/url]
for an explanation.
Hope this helps,
Mike
--
[email]mike@stok.co.uk[/email] | The "`Stok' disclaimers" apply.
[url]http://www.stok.co.uk/~mike/[/url] | GPG PGP Key 1024D/059913DA
[email]mike@exegenix.com[/email] | Fingerprint 0570 71CD 6790 7C28 3D60
[url]http://www.exegenix.com/[/url] | 75D2 9EC4 C1C0 0599 13DA
Mike Stok Guest
-
Jim Freeze #19
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Wednesday, 24 September 2003 at 20:18:42 +0900, Mike Stok wrote:
Yes, that is our current work around. It's probably the better> In article <20030923200517.A36392@freeze.org>,>> >
> > I get the error that ruby -w is not found.
> > The gnu manual says that it should work, but it certainly
> > doesn't work as it does on FreeBSD or Sun.
> One way of getting arounf env's ignoring ARGS iff you are just doing -w
> is to put
>
> $VERBOSE = true
>
> after the shebang line. See
convention because it is reliable for all platforms.
--
Jim Freeze
----------
All things are possible, except skiing thru a revolving door.
Jim Freeze Guest
-
Tom Copeland #20
Re: Article on oreilly.net on how to build Unix tools with Ruby
On Wed, 2003-09-24 at 02:23, David Garamond wrote:
rpt.rubyforge.org is still available...> Speaking of Unix tools, do any of the Perlians in this list remember Tom
> Christiansen's pet project Perl Power Tools?
>
> [url]http://www.perl.com/language/ppt/[/url]
>
> The project aims to rewrite many Unix commands in Perl, from simple
> commands like 'echo', 'clear', and 'cat' to moderately complex ones like
> 'cp', 'find', and 'ls' to complex ones like 'awk', 'make', and 'm4'.
> Take a look at the URL above, they seem to have implemented a good chunk
> of them.
>
> Perhaps someone with extra free time on his hands would like to take a
> stab on a Ruby Power Tools project? ;-)
Yours,
Tom
--
Tom Copeland <tom@infoether.com>
InfoEther
Tom Copeland Guest



Reply With Quote

