I am giving myself little projects during the winter break, and am trying to write little geektool scripts I can use for my desktop. I wrote this for ruby and it works in terminal, but when I run it in textmate I get a host is down error, and when I place it in geektool it will not run.
#!/usr/bin/ruby
require 'open-uri'
require 'nokogiri'
def fetch_xml()
open("http://weather.yahooapis.com/forecastrss?w=2424766&u=f")
end
def parse_xml()
source = Nokogiri::XML(fetch_xml)
location = source.xpath("//yweather:location")
condition = source.xpath("//item//yweather:condition")
forecast = source.xpath("//item//yweather:forecast")
[location[0]['city'], location[0]['region'], condition[0]['temp'].to_i, condition[0]['text'], forecast[0]['high'], forecast[0]['low']]
end
def display_weather()
result = parse_xml()
print "#{result}\n"
end
display_weather
It runs in terminal and gives me the correct output: ["Houston", "TX", 64, "Cloudy", "69", "63"]
But like I mentioned earlier, it will not run within textmate, and nothing shows up in geektool. Thanks in advance for any help.