Module: CrossStub::Arguments::Proc

Defined in:
lib/cross-stub/arguments/proc.rb

Constant Summary collapse

RUBY_2_RUBY =
Ruby2Ruby.new

Class Method Summary collapse

Class Method Details

.parse(&block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/cross-stub/arguments/proc.rb', line 8

def parse(&block)
  methods = {}
  proc_to_sexp(block).each_of_type(:defn) do |_sexp|
    methods[_sexp.to_a[1]] = RUBY_2_RUBY.process(_sexp)
  end
  methods
end

.proc_to_sexp(block) ⇒ Object



16
17
18
19
20
# File 'lib/cross-stub/arguments/proc.rb', line 16

def proc_to_sexp(block)
  block.to_sexp(:stip_enclosure => true, :attached_to => :xstub) do |body|
    body =~ /^(.*\W|)def\W/
  end
end