module MiniProxy
ruby-doc.org/stdlib-2.0.0/libdoc/webrick/rdoc/WEBrick.html#module-WEBrick-label-HTTPS
Constants
- DRB_SERVICE_TIMEOUT
- VERSION
Public Class Methods
allow_request(method:, url:)
click to toggle source
# File lib/miniproxy.rb, line 40 def self.allow_request(method:, url:) remote.allow_request(method: method, url: url) end
host()
click to toggle source
# File lib/miniproxy.rb, line 20 def self.host @host || "127.0.0.1" end
host=(host)
click to toggle source
# File lib/miniproxy.rb, line 24 def self.host=(host) @host = host end
ignore_all_requests()
click to toggle source
# File lib/miniproxy.rb, line 28 def self.ignore_all_requests reset %w(GET POST PUT PATCH DELETE).each do |method| stub_request(method: method, url: /.*/) end end
port()
click to toggle source
# File lib/miniproxy.rb, line 16 def self.port remote.port end
reset()
click to toggle source
# File lib/miniproxy.rb, line 8 def self.reset remote.clear end
stop()
click to toggle source
# File lib/miniproxy.rb, line 12 def self.stop remote.stop if Remote.drb_process_alive? end
stub_request(method:, url:, response: {})
click to toggle source
# File lib/miniproxy.rb, line 36 def self.stub_request(method:, url:, response: {}) remote.stub_request(method: method, url: url, response: response) end
Private Class Methods
remote()
click to toggle source
# File lib/miniproxy.rb, line 44 def self.remote Timeout.timeout(DRB_SERVICE_TIMEOUT) do begin remote = DRbObject.new(nil, Remote.server(self.host)) until remote.started? sleep 0.01 end remote.drain_messages.each(&method(:puts)) remote rescue retry end end end