Afficher un message
Vieux 15/09/2007, 15h07   #1
Nathan Thickett-menghini
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut errors, trying to edit and write some text files

Hi, I'm a total ruby noob but i've obtained this script from another
forum over at Tracks. I'm trying to extract some info from a plain text
feed of my upcoming calendar events and write specific info to three
different text files (today, tomorrow, and next 7 days). I'm on a Mac.

The script is here: I've already made edits specific to my computer (the
address of my text feed for example):

#!/usr/bin/ruby
#ÂGenerateÂ3ÂseperateÂtextÂfilesÂfromÂTrack sÂTXTÂfeeds
#ÂlistingÂactionsÂdueÂtodayÂ(orÂoverdue),Ât omorrowÂor
#ÂinÂtheÂnextÂ7Âdays.
#ÂYouÂcanÂthenÂpullÂtheseÂtextÂfilesÂinto GeekToolÂandÂcolour
#ÂthemÂseparately.

#Â========ÂConstantsÂtoÂsetÂwithÂyourÂvalue sÂ===============
#
#ÂURLÂforÂtheÂbaseÂfeed:Âhttp://yourdomain.tld/feed/text/[token]
URLÂ=Â"http://0.0.0.0:3000/feed/text/Nathan/b0b2a7c81680d1a1920b199ecb6db0ad86e2e984"
#ÂPathÂtoÂtemporaryÂdirectory
TEMP_DIRÂ=Â"/Users/"
#
#Â=============================================
#ÂGrabÂeachÂfeed,ÂsplitÂintoÂlines,ÂthenÂg etÂridÂofÂanyÂnon-actionÂlines
todayÂ=Â`curlÂ-sÂ"#{URL}"?due=0`.split("\n").select{|line|Âline Â=~Â/\s+\[Due:/ÂorÂlineÂ=~Â/^\w/}
tomorrowÂ=Â`curlÂ-sÂ"#{URL}"?due=1`.split("\n").select{|line|Âline Â=~Â/\s+\[Due:/ÂorÂlineÂ=~Â/^\w/}
this_weekÂ=Â`curlÂ-sÂ"#{URL}"?due=6`.split("\n").select{|line|Âline Â=~Â/\s+\[Due:/ÂorÂlineÂ=~Â/^\w/}

#ÂGetÂridÂofÂrepeatedÂactionsÂinÂtomorrow andÂthis_week
tomorrowÂ=ÂtomorrowÂ-Âtoday
today_or_tomorrowÂ=ÂtodayÂ+Âtomorrow
this_weekÂ=Âthis_weekÂ-Âtoday_or_tomorrow

#ÂPrintÂtheÂinfoÂtoÂthreeÂfiles,ÂstoredÂin ÂTEMP_DIR
fileÂ=ÂFile.new("#{TEMP_DIR}/today.txt",Â"w")
ÂÂfile.printÂ"\nToday:\n"Â+Âtoday.join("\n")
file.close

fileÂ=ÂFile.new("#{TEMP_DIR}/tomorrow.txt",Â"w")
ÂÂfile.printÂ"\nTomorrow:\n"Â+Âtomorrow.join( "\n")
file.close

fileÂ=ÂFile.new("#{TEMP_DIR}/later.txt",Â"w")
ÂÂfile.printÂ"\nLater:\n"Â+Âthis_week.join("\ n")
file.close

When I run this from BBEdit I get about 50 lines of this:

untitled text:11: Invalid char `\302' in expression
untitled text:11: Invalid char `\240' in expression
untitled text:11: Invalid char `\302' in expression
untitled text:11: Invalid char `\240' in expression
untitled text:13: Invalid char `\302' in expression
untitled text:13: Invalid char `\240' in expression
untitled text:13: Invalid char `\302' in expression
untitled text:13: Invalid char `\240' in expression
untitled text:17: Invalid char `\302' in expression
untitled text:17: Invalid char `\240' in expression
untitled text:17: Invalid char `\302' in expression
untitled text:17: Invalid char `\240' in expression


Any ideas? Sorry if this appears obvious. Many thanks.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
 
Page generated in 0,06623 seconds with 9 queries