Module: Billy

Defined in:
lib/billy.rb,
lib/billy/cache.rb,
lib/billy/proxy.rb,
lib/billy/config.rb,
lib/billy/railtie.rb,
lib/billy/version.rb,
lib/billy/init/rspec.rb,
lib/billy/json_utils.rb,
lib/billy/init/cucumber.rb,
lib/billy/ssl/authority.rb,
lib/billy/browsers/watir.rb,
lib/billy/ssl/certificate.rb,
lib/billy/handlers/handler.rb,
lib/billy/proxy_connection.rb,
lib/billy/browsers/capybara.rb,
lib/billy/proxy_request_stub.rb,
lib/billy/handlers/request_log.rb,
lib/billy/handlers/stub_handler.rb,
lib/billy/ssl/certificate_chain.rb,
lib/billy/handlers/cache_handler.rb,
lib/billy/handlers/proxy_handler.rb,
lib/billy/ssl/certificate_helpers.rb,
lib/billy/handlers/request_handler.rb

Defined Under Namespace

Modules: Browsers, CertificateHelpers, CucumberHelper, Handler, JSONUtils, RspecHelper Classes: Authority, Cache, CacheHandler, Certificate, CertificateChain, Config, Proxy, ProxyConnection, ProxyHandler, ProxyRequestStub, Railtie, RequestHandler, RequestLog, StubHandler

Constant Summary collapse

VERSION =
'2.1.1'

Class Method Summary collapse

Class Method Details

.certificate_authorityObject



28
29
30
# File 'lib/billy.rb', line 28

def self.certificate_authority
  @certificate_authority ||= Billy::Authority.new
end

.configure {|config| ... } ⇒ Object

Yields:

  • (config)


56
57
58
59
# File 'lib/billy/config.rb', line 56

def self.configure
  yield config if block_given?
  config
end

.log(*args) ⇒ Object



61
62
63
64
65
# File 'lib/billy/config.rb', line 61

def self.log(*args)
  unless config.logger.nil?
    config.logger.send(*args)
  end
end

.pass_request(params, headers, body, url, method) ⇒ Object

This global shortcut can be used inside of request stubs. You can modify the request beforehand and/or modify the actual response which is passed back by this method. But you can also implement a custom proxy passing method if you like to. This is just a shortcut.



36
37
38
39
40
41
42
43
44
# File 'lib/billy.rb', line 36

def self.pass_request(params, headers, body, url, method)
    handler = proxy.request_handler.handlers[:proxy]
    response = handler.handle_request(method, url, headers, body)
    {
      code: response[:status],
      body: response[:content],
      headers: response[:headers]
    }
end

.proxyObject



20
21
22
23
24
25
26
# File 'lib/billy.rb', line 20

def self.proxy
  @billy_proxy ||= (
    proxy = Billy::Proxy.new
    proxy.start
    proxy
  )
end