This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under NamespaceClasses: AnimationDisabler, Checker, Middleware
Instance Attribute Summary collapseA new instance of Server.
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Server.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
# File 'lib/capybara/server.rb', line 21 def initialize(app, *deprecated_options, port: Capybara.server_port, host: Capybara.server_host, reportable_errors: Capybara.server_errors, extra_middleware: []) unless deprecated_options.empty? warn 'Positional arguments, other than the application, to Server#new are deprecated, please use keyword arguments' end @app = app @extra_middleware = @server_thread = nil @host = deprecated_options[1] || host @reportable_errors = deprecated_options[2] || reportable_errors @port = deprecated_options[0] || port @port ||= Capybara::Server.ports[port_key] @port ||= find_available_port(host) @checker = Checker.new(@host, @port) endInstance Attribute Details #app ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21
# File 'lib/capybara/server.rb', line 19 def app @app end#host ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21
# File 'lib/capybara/server.rb', line 19 def host @host end#port ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21
# File 'lib/capybara/server.rb', line 19 def port @port endClass Method Details .ports ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16
# File 'lib/capybara/server.rb', line 14 def ports @ports ||= {} endInstance Method Details #base_url ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93
# File 'lib/capybara/server.rb', line 91 def base_url "http#{'s' if using_ssl?}://#{host}:#{port}" end#boot ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
# File 'lib/capybara/server.rb', line 72 def boot unless responsive? Capybara::Server.ports[port_key] = port @server_thread = Thread.new do Capybara.server.call(middleware, port, host) end timer = Capybara::Helpers.timer(expire_in: 60) until responsive? raise 'Rack application timed out during boot' if timer.expired? @server_thread.join(0.1) end end self end#error ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47
# File 'lib/capybara/server.rb', line 45 def error middleware.error end#reset_error! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43
# File 'lib/capybara/server.rb', line 41 def reset_error! middleware.clear_error end#responsive? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 56 57 58 59 60 61
# File 'lib/capybara/server.rb', line 53 def responsive? return false if @server_thread&.join(0) res = @checker.request { |http| http.get('/__identify__') } res.body == app.object_id.to_s if res.is_a?(Net::HTTPSuccess) || res.is_a?(Net::HTTPRedirection) rescue SystemCallError, Net::ReadTimeout, OpenSSL::SSL::SSLError false end#using_ssl? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51
# File 'lib/capybara/server.rb', line 49 def using_ssl? @checker.ssl? end#wait_for_pending_requests ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 68 69 70
# File 'lib/capybara/server.rb', line 63 def wait_for_pending_requests timer = Capybara::Helpers.timer(expire_in: 60) while pending_requests? raise "Requests did not finish in 60 seconds: #{middleware.pending_requests}" if timer.expired? sleep 0.01 end end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4