Method: Docker::Connection#initialize
- Defined in:
- lib/docker/connection.rb
#initialize(url, opts) ⇒ Connection
Create a new Connection. This method takes a url (String) and options (Hash). These are passed to Excon, so any options valid for Excon.new can be passed here.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/docker/connection.rb', line 11 def initialize(url, opts) case when !url.is_a?(String) raise ArgumentError, "Expected a String, got: '#{url}'" when !opts.is_a?(Hash) raise ArgumentError, "Expected a Hash, got: '#{opts}'" else uri = URI.parse(url) if uri.scheme == "unix" @url, = 'unix:///', {:socket => uri.path}.merge(opts) elsif uri.scheme =~ /^(https?|tcp)$/ @url, = url, opts else @url, = "http://#{uri}", opts end end end |