This file contains hidden or 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 'yaml' | |
# yaml-able proc | |
# write the proc as a string or a block that returns a string | |
# no bindings! | |
class Sproc | |
def initialize *args, &block | |
@proc_string = block_given? ? block.call.to_s : args.first.to_s | |
end |
This file contains hidden or 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 LazEvalProxy | |
alias_method :proxy_respond_to?, :respond_to? | |
alias_method :proxy_extend, :extend | |
instance_methods.each { |m| undef_method m unless m =~ /(^__|^proxy_)/ } | |
attr_accessor :proxy_block, :proxy_object | |
def initialize(object, block) | |
@proxy_object, @proxy_block = object, block | |
end |
This file contains hidden or 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 Stream | |
include Enumerable | |
attr_reader :succ, :value | |
def initialize(value, &block) | |
@value, @succ = value, block | |
end |
This file contains hidden or 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 ProcMatcher | |
attr_accessor :proc, :calls, :args | |
def initialize(proc) | |
@proc = proc | |
@calls = [] | |
@args = [] | |
end | |
def parse | |
@calls = [] |
NewerOlder