Sha256: e4d3021a618a07a82b2130cdcff27c2f40d249c2f17718b58bbb1d54d0320e96

Contents?: true

Size: 1.05 KB

Versions: 22

Compression:

Stored size: 1.05 KB

Contents

require 'toq'

# @note Needs `ENV['WEB_SERVER_DISPATCHER']` in the format of `host:port`.
#
# {WebServerManager}-API-compatible client for the {WebServerAgent}.
#
# Delegates test webserver creation to the machine running {WebServerAgent},
# for hosts that lack support for fast servers (like Windows, which can't run
# Thin, Puma etc.).
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
class WebServerClient < Toq::Proxy
    include Singleton

    def initialize( options = {} )
        @host, port = ENV['WEB_SERVER_DISPATCHER'].split( ':' )

        Raktr.global.run_in_thread if !Raktr.global.running?

        client = Toq::Client.new( host: @host, port: port )
        super client, 'server'
    end

    def protocol_for( name )
        name.to_s.include?( 'https' ) ? 'https' : 'http'
    end

    def address_for( name )
        @host
    end

    def up?( name )
        Typhoeus.get(
            url_for( name, false ),
            ssl_verifypeer: false,
            ssl_verifyhost: 0,
            forbid_reuse:   true
        ).code != 0
    end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cuboid-0.2.11 spec/support/lib/web_server_client.rb
cuboid-0.2.10 spec/support/lib/web_server_client.rb
cuboid-0.2.9 spec/support/lib/web_server_client.rb
cuboid-0.2.8 spec/support/lib/web_server_client.rb
cuboid-0.2.7 spec/support/lib/web_server_client.rb
cuboid-0.2.6 spec/support/lib/web_server_client.rb
cuboid-0.2.5 spec/support/lib/web_server_client.rb
cuboid-0.2.4.2 spec/support/lib/web_server_client.rb
cuboid-0.2.4.1 spec/support/lib/web_server_client.rb
cuboid-0.2.4 spec/support/lib/web_server_client.rb
cuboid-0.2.3 spec/support/lib/web_server_client.rb
cuboid-0.2.2 spec/support/lib/web_server_client.rb
cuboid-0.2.1 spec/support/lib/web_server_client.rb
cuboid-0.2 spec/support/lib/web_server_client.rb
cuboid-0.1.9.1 spec/support/lib/web_server_client.rb
cuboid-0.1.9 spec/support/lib/web_server_client.rb
cuboid-0.1.8 spec/support/lib/web_server_client.rb
cuboid-0.1.7 spec/support/lib/web_server_client.rb
cuboid-0.1.6.1 spec/support/lib/web_server_client.rb
cuboid-0.1.6 spec/support/lib/web_server_client.rb