Top Level Namespace

Defined Under Namespace

Modules: Truth

Constant Summary collapse

Timeout =

stolen from klarlack – github.com/schoefmax/klarlack to get an reliable timeout that wont fail on other platforms or if sytem_timer is missing

begin
  # Try to use the SystemTimer gem instead of Ruby's timeout library
  # when running on something that looks like Ruby 1.8.x. See:
  # http://ph7spot.com/articles/system_timer
  # We don't want to bother trying to load SystemTimer on jruby and
  # ruby 1.9+.
  if RUBY_VERSION =~ /^1\.8\./ and RUBY_PLATFORM !~ /java/
    require 'system_timer'
    SystemTimer
  else
    require 'timeout'
    Timeout
  end
rescue LoadError => e
  $stderr.puts "Could not load SystemTimer gem, falling back to Ruby's slower/unsafe timeout library: #{e.message}"
  require 'timeout'
  Timeout
end