code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin' | Ruby |
# =============================================================================
# A set of rake tasks for invoking the Capistrano automation utility.
# =============================================================================
# Invoke the given actions via Capistrano
def cap(*parameters)
begin
require 'rubyg... | Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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 FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# an... | Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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 FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# an... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::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 datab... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
class RubyLibraryExample
def get_server_language
'ruby'
end
# Basic communication
def passing
end
def failing(message)
raise message
end
def logging(message, level='INFO')
puts "*#{level}* #{message}"
end
def returning
'returned string'
end
# Logging
def one_message_w... | Ruby |
# Copyright 2008-2009 Nokia Siemens Networks Oyj
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | Ruby |
#!/usr/bin/env ruby
class ExampleRemoteLibrary
def count_items_in_directory(path)
Dir.entries(path).find_all{|i| not i.match('^\.')}.length
end
def strings_should_be_equal(str1, str2)
puts "Comparing '#{str1}' to '#{str2}'"
if str1 != str2
raise RuntimeError, "Given strings are not equal"
... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'data_mapper', '~> 1.2'
gem 'dm-postgres-adapter'
gem 'google-api-client', '>= 0.4.3'
group :development do
gem 'dm-sqlite-adapter', '~> 1.2'
gem 'do_sqlite3', '~> 0.10'
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
#!/usr/bin/ruby
require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb')
include CppUTestToUnityUtils
test_lines = Array.new
expected_lines = Array.new
#---------------------------------------------------
test_lines =
["\n",
"TEST_GROUP(mygroup)\n",
"{\n",
"}\n",
"\n"
]
group = get_test_group(... | Ruby |
module CppUTestToUnityUtils
def convert_test_filename_to_unity_filename(testpath)
testpath.sub(/^tests\/(.*)\.cpp/, "unity/\\1.c")
end
def convert_test_filename_to_unity_testrunner_filename(testpath)
testpath.sub(/^tests\/(.*)\.cpp/, "unity/\\1_runner.c")
end
def convert_one_liners(line, grou... | Ruby |
#!/usr/bin/ruby
require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb')
include CppUTestToUnityUtils
in_file = ARGV[0]
unity_filename = convert_test_filename_to_unity_filename(in_file)
unity_runner_filename = convert_test_filename_to_unity_testrunner_filename(in_file)
puts "Converting :" + in_file +... | Ruby |
#!/usr/bin/ruby
require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb')
include CppUTestToUnityUtils
in_file = ARGV[0]
create_group_runner_file(in_file)
unity_runner_filename = convert_test_filename_to_unity_testrunner_filename(in_file)
puts "Creating test runner for :" + in_file + "\n"
puts " ... | Ruby |
#!/bin/ruby
require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb')
include CppUTestToUnityUtils
in_file = ARGV[0]
test_lines = File.open(in_file).collect
out_file = File.open(File.basename(in_file, ".c") + "_runner.c", 'w')
group_runner = generate_group_runner_plainUnity("unity", test_lines)
wri... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
require 'thread'
class Metasp... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
require 'thread'
class Metasp... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit4 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit4 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary... | Ruby |
##
# $Id:$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
require 'rex'
require 'rex/z... | Ruby |
##
# $Id:$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit4 < Msf::A... | Ruby |
##
# $Id:$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliar... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
require 'resolv'
class Metasploit3 < Msf::Explo... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit4 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit4 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'rex/proto/http'
require 'msf/core'
clas... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
require 'racket'
class Metasp... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit4 < Msf::Auxi... | Ruby |
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit4 < Msf::Expl... | Ruby |
# # require 'net/https'
# # require 'uri'
# #
# #
# # url = URI.parse('https://api.del.icio.us')
# # http = Net::HTTP.new(url.host, url.port)
# # http.use_ssl = true
# # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
# #
HTTP_USERNAME = 'USERNAME'
HTTP_PASSWORD = 'PASSWORD'
# # request = Net::HTTP::Get.new('/v1/posts... | Ruby |
#!/usr/bin/env ruby
class Test
def initialize
@added, @removed = [], []
end
def add_responsibility(responsibility)
@added << responsibility
end
def remove_responsibility(responsibility)
@removed << responsibility
end
def added_responsibilities
(@added - @removed).sort
end
def removed_... | Ruby |
require 'rubygems'
require 'hpricot'
class ContactParser
def self.from_html(html)
doc = Hpricot(html)
new(doc)
end
def initialize(hpricot_doc)
@hpricot_doc = hpricot_doc
end
def service_identifiers
(@hpricot_doc/'.contactDetails .identifier').inject({}) do |hash, e|
service = (e.classe... | Ruby |
ACCESS_IDENTIFIER = '<your-access-identifier-here>'
SECRET_IDENTIFIER = '<your-secret-identifier-here>' | Ruby |
require 'rubygems'
require 'cgi'
require 'time'
require 'hmac'
require 'hmac-sha2'
require 'base64'
require File.join(File.dirname(__FILE__), 'amazon-sdb-credentials')
AMAZON_ENDPOINT = 'https://sdb.amazonaws.com/'
params = {
'Action' => 'ListDomains',
'AWSAccessKeyId' => ACCESS_IDENTIFIER,
'SignatureMethod' =... | Ruby |
require 'fileutils'
class MoinMoinWikiPageCreator
First = '00000001'
def initialize(source_wiki_page, moinmoin_wiki_pages_directory, convertor)
@source_wiki_page, @moinmoin_wiki_pages_directory, @convertor = source_wiki_page, moinmoin_wiki_pages_directory, convertor
@page_name = File.basename(source_wiki_p... | Ruby |
#! /usr/bin/env ruby
require File.join(File.dirname(__FILE__), 'moin_moin_wiki_page_creator')
require File.join(File.dirname(__FILE__), 'google-wiki-convertor')
google_doctype_wiki_directory = ARGV.shift
raise "Please specify the location of the google-doctype wiki directory" unless google_doctype_wiki_directory
moi... | Ruby |
#! /usr/bin/env ruby
require File.join(File.dirname(__FILE__), 'moin_moin_wiki_page_creator')
require File.join(File.dirname(__FILE__), 'google-wiki-convertor')
google_doctype_wiki_directory = ARGV.shift
raise "Please specify the location of the google-doctype wiki directory" unless google_doctype_wiki_directory
moi... | Ruby |
class GoogleWikiConvertor
def convert(google_wiki_file)
wiki = File.read(google_wiki_file)
labels = wiki[/^#labels (.*)/, 1]
# p labels
wiki = wiki.gsub(/^#labels (.*)/, '') # Delete the labels comment
wiki = wiki.sub(/#summary (.*)/, 'Summary: \'\'\1\'\'') # Make the summary visible and make it i... | Ruby |
require 'rubygems'
require 'hpricot'
amazon_html = open('/users/chrisroos/desktop/retailer_searching/amazon.html').read
doc = Hpricot(amazon_html)
doc.search("//td[@class='dataColumn']") do |td|
name = td.search("//span[@class='srTitle']")
price = td.search("//span[@class='sr_price']").text
price = td.search("//... | Ruby |
require 'fileutils'
stop_at_revision = ARGV[0]
raise "Please specify the revision that you wish to go back to as the only argument to this script." unless stop_at_revision
stop_at_revision = Integer(stop_at_revision)
class Time
def friendly_format
strftime("%Y-%m-%d %H:%M:%S")
end
end
def msg(message)
puts... | Ruby |
#!/usr/bin/env ruby
class Test
def initialize
@added, @removed = [], []
end
def add_responsibility(responsibility)
@added << responsibility
end
def remove_responsibility(responsibility)
@removed << responsibility
end
def added_responsibilities
(@added - @removed).sort
end
def removed_... | Ruby |
require File.join(File.dirname(__FILE__), '..', 'lib', 'message_parser')
require File.join(File.dirname(__FILE__), '..', 'lib', 'searcher')
require File.join(File.dirname(__FILE__), '..', 'lib', 'parser')
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
MESSAGE_STORE = File.expand_path(File.join(File.... | Ruby |
# Parse the example departures file for departure information
require 'rubygems'
require 'hpricot'
require 'htmlentities'
html = File.open('example-departures.html') { |f| f.read }
doc = Hpricot(html)
html_entities_decoder = HTMLEntities.new
Departures = []
(doc/'table.arrivaltable'/'tbody'/'tr').each do |table_ro... | Ruby |
module NatRailEnq
class MessageParser
def initialize(message)
@message = message
end
def parse
@message.split('to').collect { |component| component.strip }
end
end
end | Ruby |
require 'rubygems'
require 'hpricot'
module NatRailEnq
class Parser
def initialize(html)
@html = html
end
def parse_timetable
doc = Hpricot(@html)
departs, arrives = [], []
(doc/'input#DepartsBTN').first.parent.parent.children_of_type('td').each { |e| departs << e.inner_text }
... | Ruby |
require 'json'
DATA_STORE = File.join(File.dirname(__FILE__), '..', 'data')
module NatRailEnq
StationsVsCodes, CodesVsStations = {}, {}
Stations = []
StationData = File.open(File.join(DATA_STORE, 'stations.json')) { |f| JSON.parse(f.read) }
StationData.each do |code_and_station|
code, station = code_and... | Ruby |
require 'net/http'
require 'cgi'
module NatRailEnq
class Searcher
def initialize(from, to)
@from, @to = CGI.escape(from), CGI.escape(to)
end
def search_timetable
uri = URI.parse(search_url)
cookie, location = Net::HTTP.start(uri.host, uri.port) do |http|
response = http.get(uri.... | Ruby |
require 'net/http'
require 'json'
class Twitter
Host = 'http://twitter.com'
def initialize(credentials)
@credentials = credentials
end
def get_direct_messages(since_message_id = nil)
path = 'direct_messages.json'
query_string = "since_id=#{since_message_id}" if since_message_id
uri = URI.parse... | Ruby |
require 'rubygems'
require 'mongrel'
require 'erb'
require 'delicious'
class DeliciousHandler < Mongrel::HttpHandler
def process(request, response)
hash_of_url = request.params['PATH_INFO'].sub(/^\//, '')
if hash_of_url
site_bookmark = Delicious.bookmark_from_hash(hash_of_url)
if site_bookmark
... | Ruby |
require 'delicious'
# Want to test the intersection of tags
current_site_json = %%[{"u":"http://uk.techcrunch.com/2007/11/01/crowdstorm-comes-back-but-can-it-cut-it/","n":"A comprehensive overview of the new Crowdstorm site by Mike Butcher at TCUK. Mike mentions Reevoo, "... is closer to a CRM app for retailers... | Ruby |
require 'md5'
require 'json'
require 'open-uri'
require 'cgi'
class Delicious
class << self
def bookmark_from_url(url)
bookmark_from_hash(MD5.md5(url))
end
def bookmark_from_hash(hash_of_url)
bookmarks("url/#{hash_of_url}").first
end
def bookmarks(tag, count = nil)
json_url = "h... | Ruby |
#! /usr/bin/env ruby
require 'lib/wiki_syntax.rb'
module GoogleWiki
class WikiFolder
def initialize(directory)
@directory = directory
end
def each
Dir[File.join(@directory, '*.wiki')].each do |wiki_file|
yield WikiDocument.new(wiki_file)
end
end
end
class WikiDocument
... | Ruby |
require 'rake/testtask'
desc "Run the tests for the google wiki to html convertor."
Rake::TestTask.new(:default) do |t|
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end
| Ruby |
#! /usr/bin/env ruby
require 'lib/wiki_syntax.rb'
module GoogleWiki
class WikiFolder
def initialize(directory)
@directory = directory
end
def each
Dir[File.join(@directory, '*.wiki')].each do |wiki_file|
yield WikiDocument.new(wiki_file)
end
end
end
class WikiDocument
... | Ruby |
require File.join(File.dirname(__FILE__), 'list_block')
require 'cgi'
class WikiSyntax
module Regex
ListBlock = /(#{ListBlock::LineRegex}\n?)+/m
AtStartOfStringOrBeginsWithSpaces = /(?:^| +)/
AtEndOfStringOrEndsWithSpaces = /(?: +|$)/
CamelCaseWord = /... | Ruby |
class ListBlock
LineRegex = /^( +)(\*|#)(.*)$/ # Any number of spaces then a list token, a space and the list content
Tokens = {
'*' => 'ul',
'#' => 'ol'
}
def initialize(wiki_content)
@wiki_content = wiki_content
@html, @open_tags = '', []
@previous_indentation_to_token = @indentation_to_to... | Ruby |
require 'rake/testtask'
desc "Run the tests."
Rake::TestTask.new(:default) do |t|
t.test_files = FileList['*_test.rb']
t.verbose = true
end | Ruby |
class Redirector
def initialize(request, redirection_rules = {})
@path = request.params['REQUEST_PATH']
@host = request.params['HTTP_X_FORWARDED_HOST']
@uri = request.params['REQUEST_URI']
@redirection_rules = redirection_rules
end
def redirect_to
redirect_to = @redirection_rules[@host][... | Ruby |
require 'mongrel'
require 'redirector'
require 'configuration_loader'
port = ENV['REDIRECTION_PORT'] || '4000'
class SimpleHandler < Mongrel::HttpHandler
def process(request, response)
configuration_loader = ConfigurationLoader.new(request)
rules = configuration_loader.load_rules
redirector = Redirector... | Ruby |
require 'yaml'
class ConfigurationLoader
RULES_PATH = File.join(File.dirname(__FILE__), 'rules')
def initialize(request)
host = request.params['HTTP_X_FORWARDED_HOST']
@config_file_path = File.join(RULES_PATH, host) if host
end
def load_rules
@config_file_path && File.exists?(@config_file_path) ? Y... | Ruby |
require 'json'
HOST, PORT = 'localhost', '4001'
# Creating a new redirection
path, redirect_to = '/wem', 'http://foo.com/wem'
request = Net::HTTP::Put.new(path)
request.body = {'url' => redirect_to}.to_json
response = Net::HTTP.start(HOST, PORT) do |http|
http.request(request)
end
p response
# Listing all redirec... | Ruby |
require 'mongrel'
require 'erb'
require 'yaml'
port = ENV['REDIRECTION_WEB_INTERFACE_PORT'] || '4001'
RULES_PATH = File.join(File.dirname(__FILE__), 'rules.conf')
class RedirectionsHandler < Mongrel::HttpHandler
def process(request, response)
r = {
:http_method => request.params['REQUEST_METHOD'],
... | Ruby |
require 'mongrel'
require 'json'
port = ENV['REDIRECTION_WEB_INTERFACE_PORT'] || '4001'
RULES_PATH = File.join(File.dirname(__FILE__), 'rules.conf')
class RedirectionsHandler < Mongrel::HttpHandler
def process(request, response)
r = {
:http_method => request.params['REQUEST_METHOD'],
:path => reque... | Ruby |
task :build do
`cd src && zip -r delicious-trackbacks.xpi *`
`mv src/delicious-trackbacks.xpi .`
hash = `md5 delicious-trackbacks.xpi`[/= (.+)/, 1]
installation_html_file = File.join(File.dirname(__FILE__), 'installation.html')
installation_html = File.open(installation_html_file) { |f| f.read }
installatio... | Ruby |
require 'rake/testtask'
task :default => :tests
desc 'Run all tests'
Rake::TestTask.new(:tests) do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end
desc 'Start webserver hosting micro_id sample page and check against it'
task :webserver_example do
require "#{File.dirname(__... | Ruby |
require 'yaml'
require 'rubygems'
require 'active_record'
database_params = YAML.load(File.open("#{File.dirname(__FILE__)}/../config/database.yml"))
connection_params = database_params['database']
ActiveRecord::Base.establish_connection(connection_params) | Ruby |
$:.unshift(File.dirname(__FILE__))
$:.unshift("#{File.dirname(__FILE__)}/config")
$:.unshift("#{File.dirname(__FILE__)}/micro_id")
require 'config/database'
require 'micro_id/link' | Ruby |
require 'net/http'
class HttpClient
def http_headers
{
'User-Agent' => 'MicroID verifier',
'From' => 'you@yoursite.com'
}
end
def get_html(url, net_http_class = Net::HTTP)
host, port, path = host_port_and_path(url)
http = net_http_class.new(host, port)
http.get(path, http_h... | Ruby |
require 'rubygems'
require 'rubyful_soup'
class MicroIdVerifier
def verify(html, expected_micro_id)
soup = BeautifulSoup.new(html)
micro_id_tag = soup.html.head.find('meta', :attrs => {'name' => 'microid'}) rescue nil
return false unless micro_id_tag
micro_id_tag['content'] == expected_micro_id
... | Ruby |
require 'http_client'
require 'micro_id_verifier'
class LinkStatus
Unprocessed = 1
VerificationSuccess = 2
VerificationFailure = 3
VerificationError = 4
end
class Link < ActiveRecord::Base
class << self
def all_links
Link.find(:all)
end
def find_all_unverified(links = all_link... | Ruby |
require 'digest/sha1'
class MicroIdGenerator
attr_reader :email, :url
def initialize(email, url)
@email, @url = email, url
end
def micro_id
email_digest = Digest::SHA1.new(email).to_s
url_digest = Digest::SHA1.new(url).to_s
Digest::SHA1.new(email_digest + url_digest).to_s
end
end | Ruby |
require 'webrick'
require 'stringio'
class MicroIdServer
include WEBrick
attr_reader :micro_id_server
def initialize
server_options = { :Port => 7000, :DocumentRoot => "#{File.dirname(__FILE__)}/example_micro_id.htm", :AccessLog => StringIO.new }
@micro_id_server = HTTPServer.new(server_options)
... | Ruby |
$: << File.dirname(__FILE__)
# Start webserver
require 'micro_id_server'
micro_id_server = MicroIdServer.new
micro_id_server.start
# Validate micro_ids
require "#{File.dirname(__FILE__)}/../lib/micro_id"
puts "Good page with micro_id"
link = Link.new(:url => 'http://localhost:7000/', :expected_micro_id => 'ff511e16... | Ruby |
class Object
def metaclass
class << self; self; end
end
def define_instance_method(sym, &block)
metaclass.__send__(:define_method, sym, &block)
end
def stub_instance_method(sym, &block)
raise "#{self} does not respond to <#{sym}> and therefore cannot be stubbed" unless self.respond_to?(sy... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.