Archive for the ‘Ruby’ Category
iPhone Development with Ruby
I’m a Java and Ruby developer and I’m interested in starting development on an idea I have which would work great as an iPhone application. Naturally, instead of learning Objective-C I started doing some research on finding out if it’s possible to use another language for iPhone development. Here are some things I found along the way to answering my question:
Read the rest of this entry »
Ruby One-Liner: Download from FTP server through a proxy
If you need to download a file or view an http page source through a proxy, something like the following one-liner will help:
require 'open-uri'
open("somefile.zip","wb").write(open("ftp://username:password@host:port/remotefile.zip", :proxy=>"http://proxyhost:proxyport").read)
gem install rjb on mac os x leopard
If you’ve tried installing the rjb 1.1.x gem on Mac OS X Leopard, you will probably end up with an error like:
lipo: can't open input file: /var/tmp//ccpyNy8b.out (No such file or directory)
make: *** [load.o] Error 1
In order to get around this you have to run the following commands:
sudo su -
export JAVA_HOME='/System/Library/Frameworks/JavaVM.framework/Home'
gem install rjb
Ruby Technorati API Client
So as part of a pet project I decided to write a Ruby client for the Technorati API. There are several available requests that can be made and each has it’s own options to pass for things like the response format. I should mention there is also a Technorati-Ruby gem available that looks like it was written back in 2004 and weighs in at around 500 lines. Mine weighs in at 130 lines or so but doesn’t provide a response parser.
ActiveRecord Gem Gotchya
There is a gotchya related to how you require ActiveRecord. Apparently, in older versions of Ruby (eg. the version packaged with Leopard) something like the following will NOT work:
require 'activerecord'
with something like the following error:
-
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- activerecord (LoadError)
-
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
-
from main.rb:5
However if you use this form:
require 'active_record'
it WILL magically work.
Look here for a related patch.