module MonkeyLib

Public Class Methods

backend() click to toggle source
# File lib/monkey.rb, line 7
def self.backend
  Backend.backend
end
backend=(backend) click to toggle source
# File lib/monkey.rb, line 2
def self.backend=(backend)
  Backend.setup! backend
  backend
end
delete_from_backtrace(error) { |position| ... } click to toggle source
# File lib/monkey.rb, line 40
def self.delete_from_backtrace(error, &block)
  if error.respond_to? :awesome_backtrace
    # HACK: we rely on the internal data structure, btw
    locations = error.instance_variable_get :@locations
    return unless locations
    locations.reject! { |l| yield l.position }
    error.instance_variable_set :@backtrace, nil
  else
    error.backtrace.reject!(&block)
  end
end
hide_invisibles!(&block) click to toggle source
# File lib/monkey.rb, line 36
def self.hide_invisibles!(&block)
  show_invisibles!(false, &block)
end
invisible(*from) { || ... } click to toggle source
# File lib/monkey.rb, line 11
def self.invisible(*from)
  yield
rescue Exception => error
  unless show_invisibles?
    from << caller.first[/^[^:]*/] if from.empty?
    from << __FILE__
    delete_from_backtrace(error) { |l| from.any? { |f| l.include? f } }
  end
  raise error
end
show_invisibles!(show = true) { || ... } click to toggle source
# File lib/monkey.rb, line 26
def self.show_invisibles!(show = true)
  return @show_invisibles = show unless block_given?
  # actually, that is not thread-safe. but that's no issue, as
  # it is quite unlikely and does not cause any harm.
  show_invisibles_was, @show_invisibles = @show_invisibles, show
  result = yield
  @show_invisibles = show_invisibles_was
  result
end
show_invisibles?() click to toggle source
# File lib/monkey.rb, line 22
def self.show_invisibles?
  !!@show_invisibles
end