PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > picking through a script
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
picking through a script

Réponse
 
LinkBack Outils de la discussion
Vieux 09/06/2008, 05h34   #1
Gerry Ford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut picking through a script

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

  Réponse avec citation
Vieux 09/06/2008, 05h58   #2
David Masover
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: picking through a script

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?

  Réponse avec citation
Vieux 09/06/2008, 10h24   #3
Gerry Ford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: picking through a script

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

  Réponse avec citation
Vieux 10/06/2008, 04h50   #4
David Masover
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: picking through a script

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.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h03.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12617 seconds with 12 queries