It uses Wirble, for syntax highlighting and fun, and also loads lots of common libraries, and a bunch of nice helper functions
# load libraries
require 'rubygems'
require 'wirble'
require 'ostruct'
require 'open-uri'
require 'color'
require 'etc'
#require 'extensions'
require 'hpricot'
require 'rbosa'
Itunes = OSA.app('iTunes')
# add the mocker!
class Object;
def mock_methods(mock_methods);
original = self;
klass = Class.new(self) do;
instance_eval do;
mock_methods.each do |method, proc|;
define_method("mocked_#{method}", &proc);
alias_method method, "mocked_#{method}";
end;
end;
end;
begin;
Object.send(:remove_const, self.name.to_s);
Object.const_set(self.name.intern, klass);
yield;
ensure;
Object.send(:remove_const, self.name.to_s);
Object.const_set(self.name.intern, original);
end;
end;
end
# load some tricks
class Module
def awesome_attr_accessor(*args)
args.each do |arg|
class_eval {
define_method arg, Proc.new { instance_variable_get "@#{arg}" }
define_method "#{arg}=", Proc.new {|obj| instance_variable_set "@#{arg}", "awesome #{obj.to_s}" }
}
end
end
end
class Struct
def to_hash
self.members.inject({}) { |hash, key| hash[key.to_sym] = self[key]; hash }
end
end
class Hash
def /(key)
self[key]
end
end
module Etc
def self.gwtinfohash(name)
Etc.getpwnam(name).to_hash
end
end
module UrlVerifier
def self.verify(url,title)
doc = Hpricot(open(url))
urititle = (doc/:title).text
title == urititle ? true : false
end
end
# start wirble (with color)
Wirble.init
Wirble.colorize