code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
class AddDomainStates < ActiveRecord::Migration
def self.up
add_column :domains, :state, :string
end
def self.down
remove_column :domains, :state
end
end | Ruby |
class AddDomainEvents < ActiveRecord::Migration
def self.up
create_table :domain_events, :force => true do |t|
t.integer :domain_id
t.string :description
# t.timestamps
t.datetime :started_at
t.datetime :finished_at
end
end
def self.down
drop_table :domain_events
... | Ruby |
class AddDomainsAndAssociateUrlsWithDomains < ActiveRecord::Migration
def self.up
create_table :domains, :force => true do |t|
t.string :domain
t.string :domain_hash
t.timestamps
end
add_column :urls, :domain_id, :integer
end
def self.down
remove_column :urls, :domain_id... | Ruby |
class AddUrlsTable < ActiveRecord::Migration
def self.up
create_table :urls, :force => true do |t|
t.string :url
t.string :url_hash
t.string :title
t.integer :total_posts
t.text :top_tags
t.timestamps
end
end
def self.down
drop_table :urls
end
end | Ruby |
class AddBookmarks < ActiveRecord::Migration
def self.up
create_table :bookmarks, :force => true do |t|
t.integer :url_id
t.string :username
t.string :title
t.text :notes
t.text :tags
t.datetime :bookmarked_at
t.timestamps
end
end
def ... | Ruby |
namespace :delicious do
desc 'Update URL history for every URL registered within every domain'
task :update_urlinfo => :environment do
Domain.all.each do |domain|
domain.update_urlinfo_from_delicious!(2)
end
end
desc 'Download all bookmarks for every URL registered within every domain'
task ... | Ruby |
namespace :deliciolytics do
namespace :domain do
desc 'Extract all the URLs from the domain sitemap'
task :update_urls => :environment do
Domain.all.each do |domain|
domain.retrieve_urls_from_sitemap!
end
end
desc 'Normalise all the domains'
task :normalise => :env... | Ruby |
module Delicious
class BookmarkAttributeConvertor
def self.convert(delicious_bookmark_attributes)
{
'username' => delicious_bookmark_attributes['a'],
'title' => delicious_bookmark_attributes['d'],
'notes' => delicious_bookmark_attributes['n'],
'tags' ... | Ruby |
require 'json'
require 'net/http'
module Delicious
class Url
def initialize(url_hash)
@url_hash = url_hash
end
def urlinfo
@urlinfo ||= (JSON.parse(urlinfo_json).first || {}) # return an empty hash if we received an empty json string from delicious
end
def bookmarks
@bookmarks |... | Ruby |
require 'net/http'
require 'hpricot'
class Sitemap
def initialize(domain)
@sitemap_url = "#{domain}sitemap.xml"
@urls = []
end
def urls
sitemap = get_sitemap_xml(@sitemap_url)
if (sitemap/:sitemapindex).length > 0
(sitemap/:sitemapindex/:sitemap/:loc).each do |sitemap_location_elemen... | Ruby |
require 'net/http'
class DomainUrlNormaliser
def self.normalise(domain)
new(domain.domain).url
end
attr_reader :url
def initialize(url)
@url = url
prepend_missing_http!
append_missing_slash!
canonicalise_url!
end
def canonical_url(url)
uri = URI.parse(url)
response = Net:... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the Fast... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the Fast... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test da... | Ruby |
require 'rubygems'
require 'builder'
require 'yaml'
require File.join(File.dirname(__FILE__), 'lib', 'install_manifest')
require File.join(File.dirname(__FILE__), 'lib', 'update_manifest')
module FirefoxExtension
EXTENSION_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
EXTENSIO... | Ruby |
require File.join(File.dirname(__FILE__), 'firefox-extension.rb')
desc "Build the extension, i.e. zip up the content of src/ as a .xpi and move it to the the build directory"
task :build do
config = YAML.load_file(File.join(FirefoxExtension::EXTENSION_CONFIG_DIRECTORY, 'extension.yml'))
`rm -rf #{FirefoxExtensi... | Ruby |
module FirefoxExtension
class UpdateManifest
def self.generate(configuration, output_directory)
buffer = StringIO.new
builder = Builder::XmlMarkup.new(:target=>buffer, :indent=>2)
builder.instruct!
builder.r(:RDF, 'xmlns:r' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', :xmlns => 'http... | Ruby |
module FirefoxExtension
class InstallManifest
def self.generate(configuration, output_directory, include_update_url = false)
install_rdf_buffer = StringIO.new
builder = Builder::XmlMarkup.new(:target=>install_rdf_buffer, :indent=>2)
builder.instruct!
builder.RDF(:xmlns => 'http://www.w3.o... | Ruby |
require 'yaml'
require 'cgi'
require 'rubygems'
require 'json'
module GoogleTasks
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
SETTINGS_FILE = File.join(PROJECT_ROOT, 'config', 'settings.yml')
COOKIE_JAR = File.join(PROJECT_ROOT, 'tmp', 'cookies.txt')
TASKS_HTML = File.... | Ruby |
require 'config/boot'
# Start with a blank slate by removing the cookie jar and tasks
`rm #{GoogleTasks::COOKIE_JAR}`
`rm #{GoogleTasks::TASKS_HTML}`
# Login to google
`curl "https://www.google.com/a/#{GoogleTasks::DOMAIN}/LoginAction2" -d"Email=#{GoogleTasks::USERNAME}" -d"Passwd=#{GoogleTasks::PASSWORD}" --cookie-j... | Ruby |
require 'config/boot'
tasks_html = File.read(GoogleTasks::TASKS_HTML)
tasks_json = tasks_html[/_setup\((.*)\)\}<\/script>/, 1]
File.open(GoogleTasks::TASKS_JSON, 'w') { |f| f.puts(tasks_json) } | Ruby |
require 'config/boot'
tasks = JSON.load(File.read(GoogleTasks::TASKS_JSON))
tasks['t']['tasks'].each do |task|
p task['name']
end | Ruby |
set :application, "egg2ofx-server"
set :repository, "http://chrisroos.googlecode.com/svn/trunk/scratch/#{application}"
role :app, "seagul.co.uk"
role :web, "seagul.co.uk"
role :db, "seagul.co.uk", :primary => true
after 'deploy:update_code', 'bundler:rebundle'
namespace :deploy do
task :start do; end
task :sto... | Ruby |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' | Ruby |
require File.join(File.dirname(__FILE__), 'vendor', 'gems', 'environment')
require 'sinatra'
require 'egg'
# TODO - host this app somewhere on the interwebs
get '/' do
"<h1>egg2ofx</h1>" # TODO - add a nice little introduction page thing
end
# TODO - add a manual upload page
post '/' do
content_type 'text/of... | Ruby |
require 'rake/testtask'
desc "Run the tests for egg2ofx."
Rake::TestTask.new(:default) do |t|
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
end | Ruby |
disable_rubygems
disable_system_gems
bin_path 'vendor/gems/bin'
source 'http://gemcutter.org'
gem 'sinatra'
gem 'egg2ofx'
| Ruby |
require 'egg2ofx'
set :environment, :production
run Sinatra::Application | Ruby |
require File.join(File.dirname(__FILE__), '..', 'egg2ofx')
require 'test/unit'
require 'rack/test' | Ruby |
#! /usr/bin/env ruby
#
# while line = gets
# # puts line[/href="(http:\/\/blog\.seagul\.co\.uk.*?)"/, 1]
# puts line[/span class="a">/m]
# end
google_serp = ARGV[0]
raise "Please supply the filename of the google SERP you wish to parse as the first argument" if google_serp.nil? or google_serp.empty?
require 'hpr... | Ruby |
#! /usr/bin/env ruby
while line = gets
url = line[/(http:\/\/.*?)\t/, 1]
puts url if url
end | Ruby |
#! /usr/bin/env ruby
while line = gets
url = line[/(http:\/\/.*?)\t/, 1]
puts url if url
end | Ruby |
#! /usr/bin/env ruby
rules = [
{
:description => "Mis-spelled URL should redirect to correct spelling (this is so that I can remove the permalink column from articles and dymanically generate)",
:pattern => /^\/articles\/2006\/12\/10\/crapy-ruby-script-to-download-photos-from-a-flickr-photoset$/,
:expect... | Ruby |
#! /usr/bin/env ruby
#
# while line = gets
# # puts line[/href="(http:\/\/blog\.seagul\.co\.uk.*?)"/, 1]
# puts line[/span class="a">/m]
# end
google_serp = ARGV[0]
raise "Please supply the filename of the google SERP you wish to parse as the first argument" if google_serp.nil? or google_serp.empty?
require 'hpr... | Ruby |
# TODO: Check whether I can actully upload ofx files that appear in lower case
require 'test/unit'
require 'hpricot'
require 'builder'
class LloydsTsb
def initialize(html)
doc = Hpricot(html)
@currency = 'GBP'
@sortcode = '30-96-93'
@account_number = '00614016'
@account_type = 'CHECKING'
@fi... | Ruby |
html = File.read('lloyds-tsb')
require 'hpricot'
doc = Hpricot(html)
# Get the following account details
# * Selected account
# * Account balance
# * Available balance
# * Sort code
# * Account number
account_details = {}
(doc/"#accountTable"/'td').each do |table_cell|
divs = (table_cell/'div')
if divs.length == ... | Ruby |
require 'hpricot'
html = File.read('smile')
doc = Hpricot(html)
module Smile
class Number
def initialize(number)
@number = number
remove_pound_sign
move_negative_sign_if_applicable
convert_to_float
end
private
def remove_pound_sign
@number.gsub!(/\243/, '')
en... | Ruby |
task :default do
test_files = Dir[File.join(File.dirname(__FILE__), 'test', '**', '*_test.html')]
first_file = test_files.shift
`open #{first_file}`
# Give the browser a chance to open before we open the rest of the files.
# If the browser isn't open then each subsequent file opens in its own window which i... | Ruby |
#! /usr/bin/env ruby
require 'rubygems'
require 'mongrel'
Server = {
:host => '127.0.0.1',
:port => '3001'
}
FilesPath = File.dirname(__FILE__) + '/files/'
Dir.mkdir(FilesPath) unless File.exists?(FilesPath)
class FileHandler < Mongrel::HttpHandler
def process(request, response)
method = request.params['R... | Ruby |
#! /usr/bin/env ruby
require 'rubygems'
require 'mongrel'
Server = {
:host => '127.0.0.1',
:port => '3001'
}
FilesPath = File.dirname(__FILE__) + '/files/'
Dir.mkdir(FilesPath) unless File.exists?(FilesPath)
class FileHandler < Mongrel::HttpHandler
def process(request, response)
method = request.params['R... | Ruby |
# curl http://localhost:3001/files -v -X"POST" -d"my_data" -H"Content-Type: text/plain"
require 'net/http'
puts "** Attempting to GET a resource"
response = Net::HTTP.start('127.0.0.1', '3001') { |http| http.get('/files/') }
puts "Code: " + response.code #=> 405
puts "Message: " + response.message #=> M... | Ruby |
#!/usr/bin/env ruby
require 'flickr'
photoset_id = ARGV.shift
raise "Must supply photoset_id" unless photoset_id
local_photo_dir = ARGV.shift
raise "Must supply local photo dir" unless local_photo_dir
photoset = Photoset.find(photoset_id)
local_photo_dir = File.join(local_photo_dir, photoset.filesystem_friendly_titl... | Ruby |
#!/usr/bin/env ruby
require 'flickr'
photoset_id = ARGV.shift
raise "Must supply photoset_id" unless photoset_id
local_photo_dir = ARGV.shift
raise "Must supply local photo dir" unless local_photo_dir
photoset = Photoset.find(photoset_id)
local_photo_dir = File.join(local_photo_dir, photoset.filesystem_friendly_titl... | Ruby |
require 'rubygems'
require 'digest/md5'
require 'json'
require 'net/http'
require 'uri'
class Flickr; end
auth_token_filename = File.join(File.dirname(__FILE__), '/AUTH_TOKEN')
Flickr::AUTH_TOKEN = if File.exist?(auth_token_filename) then
File.open(auth_token_filename) { |file| file.read }
else
nil
end
class Fli... | Ruby |
require 'mongrel'
require 'nat-rail-enq'
port = ENV['NAT_RAIL_ENQ_SERVER_PORT'] || 4000
class SimpleHandler < Mongrel::HttpHandler
def process(request, response)
raw_query = request.params['QUERY_STRING']
query = raw_query.split('&').inject({}) { |hash, key_value_pair| key, value = key_value_pair.split('=')... | Ruby |
require 'json'
class StationsParser
def self.from_file(stations_as_json_path)
stations_as_json = File.open(stations_as_json_path) { |file| file.read }
JSON.parse(stations_as_json)
end
end
class Stations
def initialize(station_codes_and_stations)
@stations = station_codes_and_stations.inject({}) do |... | Ruby |
require 'rubygems'
require 'hpricot'
CURL_CMD = '/usr/bin/curl'
class NationalRailEnquiries
COOKIE_JAR = File.expand_path(File.dirname(__FILE__) + '/national-rail-enquiries.cookie')
class Parameters
attr_reader :depart_station, :arrive_station
attr_reader :depart_day, :depart_month, :depart_hour, :d... | Ruby |
load File.join(File.dirname(__FILE__), 'vendor', 'firefox-extension', 'Rakefile') | Ruby |
load File.join(File.dirname(__FILE__), 'vendor', 'firefox-extension', 'Rakefile') | Ruby |
require 'action_view_helper_url_helper'
require 'test_unit_assertions' | Ruby |
class AnchorTagHelper
Regex = /href="(.*?)"/
attr_reader :anchor_tag, :url, :url_without_parameters
def initialize(anchor_tag)
@anchor_tag = anchor_tag
anchor_tag = @anchor_tag.gsub("'", "\"")
@url = anchor_tag.match(Regex)[1] rescue ''
@url_without_parameters = @url.sub(/\?.*/, '')
end... | Ruby |
class MockRequest
attr_reader :path
attr_accessor :path_parameters
def initialize(path)
@path = path
end
end | Ruby |
require 'anchor_tag_helper'
require 'mock_request'
module ActionView
module Helpers
module UrlHelper
alias :link_to_before_link_validity_check :link_to
def link_to(name, options = {}, html_options = nil, *parameters_for_method_reference)
anchor_tag = link_to_before_link_validity... | Ruby |
module Test
module Unit
module Assertions
def assert_no_broken_links
assert_no_tag :tag => 'a', :attributes => { :class => 'invalid_href_target' }
end
end
end
end | Ruby |
require 'test_unit_active_record_errors' if RAILS_ENV == 'test' | Ruby |
require 'test_help'
class Test::Unit::ActiveRecordError < Test::Unit::Error
attr_reader :active_record_model
def initialize(test_name, exception)
super
@active_record_model = exception.record
end
def long_display
msg = super
msg << "\nActiveRecord Errors: #{active_record_model.errors.full_messa... | Ruby |
require 'routing_redirection' | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the routing_redirection plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end | Ruby |
module ActionController
module Routing
class RouteSet
def recognize(request)
if request.path =~ /.+\/$/
request.path_parameters = {:action => 'permanently_redirect_urls_with_trailing_slash'}
RedirectionController
else
params = recognize_path(request.path, ext... | Ruby |
require 'uri_sanitizer'
class RedirectionController < ApplicationController
def permanently_redirect_urls_with_trailing_slash
uri_sanitizer = UriSanitizer.new(request.request_uri)
headers['Status'] = '301 Moved Permanently'
redirect_to uri_sanitizer.location
end
def permanently_redirect
if ... | Ruby |
require 'uri'
class UriSanitizer
def initialize(uri)
@uri = URI.parse(uri)
end
def path
@uri.path.sub(/\/$/, '')
end
def querystring
@uri.query ? ('?' + @uri.query) : ''
end
def location
path + querystring
end
end | Ruby |
require 'test/unit'
require 'rubygems'
require 'action_controller'
require 'action_controller/test_process'
$:.unshift(File.dirname(__FILE__) + '/../lib/') | Ruby |
require 'private_associations' | Ruby |
class ActiveRecord::Base
class << self
def has_many_private(*args, &blk)
original_methods = public_instance_methods
has_many(*args, &blk)
new_methods = public_instance_methods - original_methods
private(*new_methods)
end
def has_one_private(*args, &blk)
original_met... | Ruby |
subject = 'National Rail Enquiries'
sender = '"Ross, Alastair" <Alastair.Ross@atoc.org>'
received = '29th Feb 2008, 11:18'
recipient = 'chris@seagul.co.uk'
body = DATA.read
require 'erb'
include ERB::Util
template = File.open('template.html.erb') { |f| f.read }
erb = ERB.new(template)
File.open('email.html', 'w') { |... | Ruby |
postcode = 'SW1A 2AJ'
html = `curl "http://streetmap.co.uk/streetmap.dll" -d"MfcISAPICommand=GridConvert" -d"name=#{postcode}" -d"type=PostCode"`
require 'rubygems'
require 'hpricot'
doc = Hpricot(html)
latitude, longitude = 0, 0
(doc/"div"/"center"/"table"/"tr").each do |row|
attribute = (row/"td").first.inner_... | Ruby |
# *******
# USE TO PRODUCE A FILE OF BOOKMARKS THAT CAN EASILY BE COMPARED TO AN SIMILARLY PRODUCED FILE USING DIFF
Filename = 'FILE_OF_DELICIOUS_BOOKMARKS'
xml = File.open(Filename) { |f| f.read }
require 'hpricot'
require 'yaml'
doc = Hpricot(xml)
output = File.open("#{Filename}.yml", 'w')
(doc/'posts'/'post').eac... | Ruby |
# CREDENTIALS
USERNAME = 'YOUR_USERNAME'
PASSWORD = 'YOUR_PASSWORD'
POSTS_CACHE = 'FILE_TO_STORE_YOUR_EXISTING_DELICIOUS_POSTS_IN'
# GET ALL POSTS
unless File.exists?(POSTS_CACHE)
puts "Downloading all posts..."
curl_cmd = <<-EndCurl
curl "https://api.del.icio.us/v1/posts/all" \
-u"#{USERNAME}:#{PASSWORD}" \
... | Ruby |
class Object
def attribute(arg, &block)
if arg.class == Hash
attribute = arg.keys[0]
value = arg.values[0]
else
attribute = arg
value = block ? block : nil
end
class_eval do
attr_writer attribute
define_method(attribute) do
unless instance... | Ruby |
#
# metakoans.rb is an arduous set of exercises designed to stretch
# meta-programming muscle. the focus is on a single method 'attribute' which
# behaves much like the built-in 'attr', but whose properties require delving
# deep into the depths of meta-ruby. usage of the 'attribute' method follows
# the general form... | Ruby |
# DOWNLOAD RUBY 1.8.5 ONE CLICK INSTALLER
# DONWLOAD 7ZIP COMMAND LINE ONLY
require 'net/ftp'
require 'date'
today = Date.today.strftime
yesterday = (Date.today - 1).strftime
ZIP_PROG = 'c:/bin/7za.exe'
APC_DIR = 'c:/documents and settings/chris/desktop/'
DATA_DIR = APC_DIR + 'data'
BACKUP_DIR = APC_DIR + 'backup'
B... | Ruby |
invoices_file = ARGV.shift
unless invoices_file && File.exists?(invoices_file)
puts ""
puts "Split Invoices"
puts "--------------"
puts "Usage: split-invoices.rb all-invoices-file [output-directory]"
puts ""
puts " * all-invoices-file (required): Path to the file containing all invoices exported from APC D... | Ruby |
set :application, "thisiskent.seagul.co.uk"
set :repository, "http://chrisroos.googlecode.com/svn/trunk/www/thisiskent.seagul.co.uk"
set :deploy_to, "/home/chrisroos/www/#{application}"
set :deploy_via, :copy
role :app, "jail0093.vps.exonetric.net"
role :web, "jail0093.vps.exonetric.net"
role :db, "jail0093.vps.exo... | Ruby |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' | Ruby |
class ArticlesView
def initialize(articles, number_to_display)
@articles, @number_to_display = articles, number_to_display
end
def each_article
number_displayed = 0
@articles.each do |article|
break if number_displayed == @number_to_display
yield article
number_displayed += 1
... | Ruby |
require 'yaml'
class YamlDeserializer
def deserialize(serialized_articles)
deserialized_articles = YAML.load(serialized_articles)
deserialized_articles ? deserialized_articles : []
end
end | Ruby |
require 'yaml'
class YamlSerializer
def serialize(articles)
articles.to_yaml
end
end | Ruby |
require 'hpricot'
require 'net/http'
class DocumentParser
class << self
def from_file(filename)
html = File.open(filename) { |f| f.read }
doc = Hpricot(html)
new(doc)
end
def from_url(url)
user_agent = "User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:... | Ruby |
require 'erb'
include ERB::Util
class ErbRenderer
def initialize(template_file, binding)
@template_file, @binding = template_file, binding
end
def render(output_buffer)
template = File.open(@template_file) { |f| f.read }
erb = ERB.new(template)
output_buffer << erb.result(@binding)
end
end | Ruby |
require File.join(File.dirname(__FILE__), 'yaml_serializer')
require File.join(File.dirname(__FILE__), 'yaml_deserializer')
class Articles
class << self
def retrieve(io, deserializer)
new deserializer.deserialize(io.read)
end
def retrieve_from_yaml_file(filename)
File.open(filename) { |file|... | Ruby |
require 'rake/testtask'
desc "Produce the atom feed"
task :produce_atom_feed do
ruby 'bin/create_atom_feed.rb'
end
desc "Run all the tests."
Rake::TestTask.new(:default) do |t|
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.