Skip to content

Instantly share code, notes, and snippets.

irb(main):001:0> def me(foo)
irb(main):002:1> if foo
irb(main):003:2> $1
irb(main):004:2> else
irb(main):005:2* nil
irb(main):006:2> end
irb(main):007:1> end
=> #<Rubinius::CompiledMethod me file=(irb)>
irb(main):008:0> exit
An exception occurred running IRB
require 'rubygems'
require 'nokogiri'
html = %q{blah http://google.com blah blah}
new_html = %q{blah <a href="http://google.com">http://google.com</a> blah blah}
frag = Nokogiri::HTML.fragment(html)
text = frag.children.first
p frag.to_html
class DebArchive < Archive
def content_subdir
"."
end
def extract_command
""
end
end
Archive.CLASSES.merge! :deb => DebArchive
class SomeModel < ActiveRecord::Base
def some_method
raise NotImplementedError
end
end
module Api::V1::SomeModelMethods
def some_method
return {:blah => 1}
end
Building openssl
=== OpenSSL for Ruby configurator ===
=== Checking for system dependent stuff... ===
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
checking for sys/time.h... yes
checking for unistd.h... yes
checking for assert.h... yes
=== Checking for required stuff... ===
openssl [master*] $ ../../../bin/rbx -Xint extconf.rb
=== OpenSSL for Ruby configurator ===
=== Checking for system dependent stuff... ===
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
checking for sys/time.h... yes
checking for unistd.h... yes
checking for assert.h... yes
=== Checking for required stuff... ===
describe "Symbol#[]" do
describe "with a Fixnum index" do
it "returns the character code of the element at the index"
describe "an index that is out of bounds" do
it "returns nil if the index is before the start"
it "return nil if the index is past the end"
end
end
@ileitch
ileitch / gist:1340123
Created November 4, 2011 18:41
RSpec matcher for Rails 3 controller filters.
RSpec::Matchers.define :have_before_filter do |filter|
match do |actual|
actual._process_action_callbacks.select { |c| c.kind == :before }.map(&:filter).include?(filter)
end
end
MyController.should have_before_filter(:filter_name)
@ileitch
ileitch / gist:1459987
Created December 11, 2011 11:08
Interruptible sleep in Ruby
module InterruptibleSleep
def interruptible_sleep(seconds)
@_sleep_check, @_sleep_interrupt = IO.pipe
IO.select([@_sleep_check], nil, nil, seconds)
end
def interrupt_sleep
@_sleep_interrupt.close if @_sleep_interrupt
end
end
diff --git a/kernel/common/module.rb b/kernel/common/module.rb
index dffe98a..5bb7501 100644
--- a/kernel/common/module.rb
+++ b/kernel/common/module.rb
@@ -168,25 +168,41 @@ class Module
end
def public_method_defined?(sym)
- sym = Rubinius::Type.coerce_to_symbol(sym)
+ sym = sym.to_str if sym.respond_to?(:to_str)