This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'delegate' | |
class Foo | |
def select | |
'Foo#select' | |
end | |
end | |
class Bar < SimpleDelegator | |
def a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Printer | |
def initialize(options) | |
@out = options.fetch(:out) | |
@translator = options.fetch(:translator) | |
end | |
def say_hello | |
@translator.translate("Hello!", self) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class X | |
def connect(action, to, with_success_status_code) | |
:result_a | |
end | |
def connect(different_thing_entirely) | |
:result_b | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def my_method(options = {}) | |
observer = options.delete(:observer) | |
x = SomeObservable.new | |
x.add_observer(*observer) | |
end | |
# works with | |
my_method(:observer => some_object) | |
# and also with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def winner_is(winner) | |
puts "*Time passes...*" | |
if winner == :computer | |
puts "I win!" | |
else | |
puts "OK, you win this one." | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyGivenDriver < Kookaburra::GivenDriver | |
def a_bar(name) | |
bar_data = test_data.default(:bar) | |
record = api.create_bar(bar_data) | |
test_data.set_bars(name, record) | |
end | |
def a_foo(name, bar_name) | |
foo_data = test_data.default(:foo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'rails', '3.1.1' | |
gem 'pg' | |
gem 'json' | |
gem 'therubyracer', :require => 'v8' | |
# Gems used only for assets and not required | |
# in production environments by default. | |
group :assets do | |
gem 'sass-rails', '~> 3.1.4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let(:some_thing) { mock_model(SomeThing) } | |
let(:exception) do | |
ActiveRecord::RecordInvalid.allocate.tap do |e| | |
e.stub!(record: some_thing) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl get.pow.cx/install.sh | sh | |
# We don't actually want the firewall rule that pow installs | |
echo "Get rid of those silly firewall rules for port 80." | |
ports=($(ruby -e'puts $<.read.scan(/fwd .*?,([\d]+).*?dst-port ([\d]+)/)' "/Library/LaunchDaemons/cx.pow.firewall.plist")) | |
HTTP_PORT=${ports[0]} | |
DST_PORT=${ports[1]} | |
RULE=$(sudo ipfw show | (grep ",$HTTP_PORT .* dst-port $DST_PORT in" || true) | cut -f 1 -d " ") | |
[[ -n "$RULE" ]] && sudo ipfw del "$RULE" | |
# Unload the firewall plist and remove it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ree-1.8.7-2010.02 > s.each do |x| | |
ree-1.8.7-2010.02 > begin | |
ree-1.8.7-2010.02 > puts '%02d' % x | |
ree-1.8.7-2010.02 ?> rescue ArgumentError => e | |
ree-1.8.7-2010.02 ?> puts e | |
ree-1.8.7-2010.02 ?> end | |
ree-1.8.7-2010.02 ?> end | |
01 | |
02 | |
03 |