Sha256: 0e5c0b89e7b5017bd720c8264bed4a09498c34b6ff006a26e68e093098af3417

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8
require "belzebuth/wait_condition/base"
require "belzebuth/wait_condition/api"
require "belzebuth/wait_condition/regular_expression"
require "belzebuth/wait_condition/closure"
require "belzebuth/wait_condition/blocking"
require "belzebuth/wait_condition/timed"
require "uri"

module Belzebuth
  def self.WaitCondition(wait_condition)
    case wait_condition
    when WaitCondition::Base
      wait_condition
    when Numeric
      WaitCondition::Timed.new(wait_condition)
    when Proc
      WaitCondition::Closure.new(wait_condition)
    when Regexp
      WaitCondition::RegularExpression.new(wait_condition)
    when String
      begin
        uri = URI(wait_condition)
        if uri.scheme == "http" || uri.scheme == "https"
          WaitCondition::Api.new(uri)
        else
          WaitCondition::RegularExpression.new(/^#{wait_condition}$/)
        end
      rescue => e
        WaitCondition::RegularExpression.new(/^#{wait_condition}/)
      end
    else
      raise "Unknown WaitCondition for: #{wait_condition}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belzebuth-0.1.0 lib/belzebuth/wait_condition.rb