[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: getdate(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead
Tynsoe Projects • View topic - Problem w/ ruby scripts & gem requires

Problem w/ ruby scripts & gem requires

Problem w/ ruby scripts & gem requires

Postby carinishead » Fri Jan 06, 2012 5:23 am

I've written some scripts for GeekTool in ruby, but unfortunately when run as shell commands, they do not work when I require gems that aren't a part of core.

Example, if I require 'rubygems' or 'json', everything is fine. However, if I try to require any gems I installed explicitly like 'mechanize' or 'libxml-ruby' the scripts break. They run fine when executed through terminal, but will not run through GT no matter what. I've tried everything I can think of, including writing a shell script that executes the ruby script (saw this on SO), but that won't work either.

It appears that GT doesn't respect the profile or something along those lines. I even tried to do full paths to the gems, but this still doesn't work. If I take my shell script and output 'gem which mechanize', it gives me the right gem and everything. What's the deal? I'll attach one of the scripts below as an example:

Code: Select all
require 'rubygems'
require 'json'
# this is fine
puts "working so far"
require 'mechanize'
# the script breaks here
puts "still working"

r = [*1..14].sample
uri = "http://www.brainyquote.com/quotes/keywords/scientific#{r > 1 ? '_' + r : ''}.html"
a = Mechanize.new

page = a.get(uri)
parser = page.parser

quotes = parser.xpath("//div[@class='quotecontent']/span[@class='body']")
authors = parser.xpath("//div[@class='quotecontent']/span[@class='bodybold']/a")

r = [*1..quotes.count].sample

quote = quotes[r].text
author = authors[r].text

puts "\"#{quote}\n#{author}\""
carinishead
 
Posts: 3
Joined: Fri Jan 06, 2012 4:38 am

Re: Problem w/ ruby scripts & gem requires

Postby carinishead » Mon Feb 27, 2012 11:56 pm

Anybody have any clues here? I abandoned it for a while, but would really like to get this working.

Thanks!
carinishead
 
Posts: 3
Joined: Fri Jan 06, 2012 4:38 am


Return to GeekTool

Who is online

Users browsing this forum: No registered users and 1 guest

cron