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 > Libs for high-level file processing?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Libs for high-level file processing?

Réponse
 
LinkBack Outils de la discussion
Vieux 20/11/2007, 11h14   #1
Casimir
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Libs for high-level file processing?

Is there anything you comp.lang.ruby readers would recommend that would
abstract away things like "if file load fails" or "if file not found" or
"index of all .xml -files in the subdirs"?

I can do the rescue patrol -mission, but time is running out! Lost on
the Apache mountain. I am not sure my squad will get us there on time...

Not looking for anything big, preferably small and simple (ie. practical).

Thanks
Csmr
  Réponse avec citation
Vieux 20/11/2007, 15h06   #2
Axel Etzold
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Libs for high-level file processing?


-------- Original-Nachricht --------
> Datum: Tue, 20 Nov 2007 20:15:04 +0900
> Von: Casimir <pikEISPAMMMseli@welho.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Libs for high-level file processing?


> Is there anything you comp.lang.ruby readers would recommend that would
> abstract away things like "if file load fails" or "if file not found" or
> "index of all .xml -files in the subdirs"?
>
> I can do the rescue patrol -mission, but time is running out! Lost on
> the Apache mountain. I am not sure my squad will get us there on time...
>
> Not looking for anything big, preferably small and simple (ie. practical).
>
> Thanks
> Csmr


Dear Casimir,

mmh - maybe rio can ?

http://rio.rubyforge.org/

Best regards,

Axel

--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

  Réponse avec citation
Vieux 20/11/2007, 16h49   #3
Robert Klemme
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Libs for high-level file processing?

2007/11/20, Casimir <pikEISPAMMMseli@welho.com>:
> Is there anything you comp.lang.ruby readers would recommend that would
> abstract away things like "if file load fails" or "if file not found" or
> "index of all .xml -files in the subdirs"?


I am not sure what you are missing. You can do

File.open("foo") do |io|
end resuce nil

if File.exists? "foo"

xml_files = Dir["bas/**/*.xml"]

Which is pretty small I'd say. What am I missing?

Kind regards

robert

--
use.inject do |as, often| as.you_can - without end

  Réponse avec citation
Vieux 20/11/2007, 22h16   #4
Casimir P
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Libs for high-level file processing?

> -------- Original-Nachricht --------
>> Datum: Tue, 20 Nov 2007 20:15:04 +0900 Von: Casimir
>> <pikEISPAMMMseli@welho.com> An: ruby-talk@ruby-lang.org
>> Betreff: Libs for high-level file processing?

>
>> Is there anything you comp.lang.ruby readers would recommend that would
>> abstract away things like "if file load fails" or "if file not found"
>> or "index of all .xml -files in the subdirs"?
>>

On Tue, 20 Nov 2007 10:06:36 -0500, Axel Etzold wrote:
> Dear Casimir,
> ...
> mmh - maybe rio can ? http://rio.rubyforge.org/
>


On Tue, 20 Nov 2007 11:49:30 -0500, Robert Klemme wrote:
>
> ...You can do
>
> File.open("foo") do |io|
> end resuce nil
>
> if File.exists? "foo"
>
> xml_files = Dir["bas/**/*.xml"]
>
> Which is pretty small I'd say. What am I missing?


I admint! I is dummy! IT's easy! 8)

Dir['/home/kasbah/*.jpg' && '/home/kasbah/*.png'].sort!.each { |f| puts
f.to_s }

But then its not that short:

if File.exists? $imgSourcePathStr
if File.exists? $imgDestPathStr
indexedDirs = indexImagesInDirs
($imgSourcePathStrs, $imgDestPathStr)
else
puts "no dest!"
exit
end
else
puts "no src!"
exit
end

indexedDirs.each { |one|
path=one[0]
num=0
one.flatten!.length < 8 ? num = (one.length.to_i-1) : num = 7
num.times { |m|
puts "converting (" + (m+1).to_s + "/" + num.to_s + ")"
imgname = one[(m+1)]
savesubpath = path.split("/").last
saveresized = savetargetstr.to_s + "/" + path.split("/").last + "/" +
(m+1).to_s + "fullsize" + imageFormat
#and then write and FAIL..
#Double slash kills..
#Or directory doesnt exist!
#Its all too complicated
#I is dum!
}
}

Csmr
--
Casimir Pohjanraito
Art Portfolio: http://csmr.dreamhosters.com
  Réponse avec citation
Vieux 21/11/2007, 09h01   #5
Jari Williamsson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Libs for high-level file processing?

Casimir P wrote:
> savesubpath = path.split("/").last
> saveresized = savetargetstr.to_s + "/" + path.split("/").last + "/" +
> (m+1).to_s + "fullsize" + imageFormat
> #and then write and FAIL..
> #Double slash kills..
> #Or directory doesnt exist!


I think the lines above are more easily handled if you use the methods
in the core File library, such as File.basename etc. Much to choose from
there.


Best regards,

Jari Williamsson

  Réponse avec citation
Vieux 21/11/2007, 09h34   #6
Casimir
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Mumbling about basic file operations (was Re: Libs for high-levelfile processing?)

> Casimir P wrote:
>> saveresized = savetargetstr.to_s + "/" + path.split("/").last + "/" +
>> (m+1).to_s + "fullsize" + imageFormat
>> #and then write and FAIL..
>> #Double slash kills..
>> #Or directory doesnt exist!


Jari Williamsson wrote:
>
> I think the lines above are more easily handled if you use the methods
> in the core File library, such as File.basename etc. Much to choose from
> there.


Yes. I was oblivious to File.basename which was exactly what I was
looking for. Thank you for pushing me in the right direction!

But I was not waste of time! I twas gathering cases for file ops. IT's
easy! 8)

Here's what I got, minimal case plan
- Open file
- Create file that doesn't exist, open
- Save file
- Overwrite file
- Dir doesnt exist, create
- get filename from path str (file.basename).
- get the sub dir file is ("deepest" dir)
- remove dbl slashes (etc crap).
- nonrelative dir (remove /dir1/../dir1/ etc.)

I was looking for guide covering these on google. Didn't find one. I
guess I will have to write a micro guide to these. 8)

Csmr
  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 19h20.


É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,13179 seconds with 14 queries