Skip to content

Instantly share code, notes, and snippets.

View halorgium's full-sized avatar

Tim Carey-Smith halorgium

View GitHub Profile
We couldn’t find that file to show.
@halorgium
halorgium / gist:4722
Created August 10, 2008 04:28 — forked from wycats/gist:4721
def requirable?(filename)
result = fork do
begin
require filename
exit!(0)
rescue
exit!(1)
end
end
result == 0 ? true : false
if v:progname =~? "evim"
finish
endif
"core vim options {{{1
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
require 'rubygems'
require 'dm-core'
require 'pp'
DataMapper.setup(:default, "sqlite3::memory:")
class City
include DataMapper::Resource
property :id, Serial
class DateTime
def httpdate
t = dup.utc
sprintf('%s, %02d %s %d %02d:%02d:%02d GMT',
Time::RFC2822_DAY_NAME[t.wday],
t.day, Time::RFC2822_MONTH_NAME[t.mon-1], t.year,
t.hour, t.min, t.sec)
end
def utc
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 458a845..13994d4 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -121,6 +121,8 @@ module Gem
# Gem::Requirement and Gem::Version documentation.
def self.activate(gem, *version_requirements)
+ options = version_requirements.last.is_a?(Hash) ? version_requirements.pop : {}
+ sources = options[:sources] || []
describe "Without logging in" do
describe "a request to /foo/bar" do
before(:each) do
get("/foo/bar")
end
it "redirects" do
rack.status.should == 302
end
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 458a845..bc0078f 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -121,6 +123,8 @@ module Gem
# Gem::Requirement and Gem::Version documentation.
def self.activate(gem, *version_requirements)
+ options = version_requirements.last.is_a?(Hash) ? version_requirements.pop : {}
+ sources = options[:sources] || []
main = "jf*2r112r2"
f1 = "22r"
f2 = "ff*"
f1.gsub!(/2/, f2)
f2.gsub!(/1/, f1)
main.gsub!(/1/, f1)
main.gsub!(/2/, f2)
>> a = "foo"
=> "foo"
>> b = "bar"
=> "bar"
>> c = {}
=> {}
>> c[a] ||= :foo
=> :foo
>> c[b] ||= :bar
=> :bar