Module: Docker

Extended by:
Docker
Included in:
Docker
Defined in:
lib/docker.rb,
lib/docker/version.rb

Overview

The top-level module for this gem. It’s purpose is to hold global configuration variables that are used as defaults in other classes.

Defined Under Namespace

Modules: Error, Model, Multipart Classes: Connection, Container, Image

Constant Summary collapse

VERSION =
"0.0.5"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#credsObject (readonly)

Returns the value of attribute creds.



11
12
13
# File 'lib/docker.rb', line 11

def creds
  @creds
end

Instance Method Details

#authenticate!(options = {}) ⇒ Object

Login to the Docker registry.



50
51
52
53
54
# File 'lib/docker.rb', line 50

def authenticate!(options = {})
  connection.post(:path => '/auth', :body => options)
  @creds = options.to_json
  true
end

#connectionObject



31
32
33
# File 'lib/docker.rb', line 31

def connection
  @connection ||= Connection.new(url, options)
end

#infoObject

Get more information about the Docker server.



45
46
47
# File 'lib/docker.rb', line 45

def info
  connection.json_request(:get, '/info')
end

#optionsObject



17
18
19
# File 'lib/docker.rb', line 17

def options
  @options ||= { :port => 4243 }
end

#options=(new_options) ⇒ Object



26
27
28
29
# File 'lib/docker.rb', line 26

def options=(new_options)
  @options = { :port => 4243 }.merge(new_options)
  reset_connection!
end

#reset_connection!Object



35
36
37
# File 'lib/docker.rb', line 35

def reset_connection!
  @connection = nil
end

#urlObject



13
14
15
# File 'lib/docker.rb', line 13

def url
  @url ||= 'http://localhost'
end

#url=(new_url) ⇒ Object



21
22
23
24
# File 'lib/docker.rb', line 21

def url=(new_url)
  @url = new_url
  reset_connection!
end

#versionObject

Get the version of Go, Docker, and optionally the Git commit.



40
41
42
# File 'lib/docker.rb', line 40

def version
  connection.json_request(:get, '/version')
end