|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello Ruby Forum,
I'm picking through a script that will archive sent messages in my Dialog newsreader, written by another. He included msgfile.rb, which looks to be a class definition. Am I correct that ruby should throw an error if it can't find iconv? As it is, the script seems to execute without output, warnings or errors. #!/usr/bin/env ruby # extr_sent.rb # extract all Sent messgages from all msg*.dat in Dialog's data direectory into single messages # Usage: place into data dir and run - will extract into single messages # with parameter -m: extracts to mbox # with parameter -r: extracts raw, mostly for debugging purposes # Backup your files first, no guarantees. require 'iconv' require 'msgfile' Is iconv something that comes already with ruby 1.8.6? Thanks, -- -- Posted via http://www.ruby-forum.com/. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sunday 08 June 2008 23:34:09 Gerry Ford wrote:
> Is iconv something that comes already with ruby 1.8.6? Seems to. For what it's worth, isn't 1.8.7 out now? |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
David Masover wrote:
> On Sunday 08 June 2008 23:34:09 Gerry Ford wrote: > >> Is iconv something that comes already with ruby 1.8.6? > > Seems to. For what it's worth, isn't 1.8.7 out now? I've had this install for a while. Ruby was something I wanted to get to, but real life has been interfering. I might be behind one version. Since you said you got it to work, I went ahead and looked for anything in ruby that had iconv in it. There was an iconv.dll and an iconv.exe. I'd guess ruby.exe used iconv.dll. Here's some more of the script: RAW = ARGV.delete("-r") MBX = ARGV.delete("-m") def output(art, counter) if RAW File.open(filename(counter), "wb") {|out| out.puts art} else if MBX File.open("sent.mbx", "ab") do |out| out.print fromline(counter), LINEBREAK out.print reformat(art), LINEBREAK, LINEBREAK end else File.open(filename(counter), "wb") {|out| out.print reformat(art), LINEBREAK} end end end It looks like ARG.delete is a way to get command line args. How would this behave if no command-line args are given? -- -- Posted via http://www.ruby-forum.com/. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Monday 09 June 2008 04:24:25 Gerry Ford wrote:
> It looks like ARG.delete is a way to get command line args. How would > this behave if no command-line args are given? Well, ARGV is an array of commandline arguments -- it behaves exactly like any other array. A little testing shows that calling delete from an array will either return the item asked for, or nil. So in this case, RAW will be either '-r' or nil, depending on whether there's a -r in the commandline. Same for MBX and '-m' -- so with no commandline arguments, RAW and MBX will both be nil. |
|
![]() |
| Outils de la discussion | |
|
|