Module: Tid::Boot2docker

Defined in:
lib/tid/boot2docker.rb

Class Method Summary collapse

Class Method Details

.envObject



12
13
14
# File 'lib/tid/boot2docker.rb', line 12

def env
  @env ||= env!
end

.env!Object



16
17
18
19
20
21
22
# File 'lib/tid/boot2docker.rb', line 16

def env!
  out = `boot2docker shellinit 2>/dev/null`
  env_keys.each.with_object({}) do |key, memo|
    out.match(/#{key}=(.*)/)
    memo[key] = $1.chomp
  end
end

.env_keysObject



4
5
6
7
8
9
10
# File 'lib/tid/boot2docker.rb', line 4

def env_keys
  %w(
    DOCKER_HOST
    DOCKER_CERT_PATH
    DOCKER_TLS_VERIFY
  )
end

.have?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/tid/boot2docker.rb', line 32

def have?
  !`which boot2docker`.empty?
end

.ipObject



40
41
42
43
# File 'lib/tid/boot2docker.rb', line 40

def ip
  out, _, _ = Console.cmd 'boot2docker ip'
  out.to_s.chomp
end

.prepareObject



24
25
26
# File 'lib/tid/boot2docker.rb', line 24

def prepare
  up unless running?
end

.running?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/tid/boot2docker.rb', line 36

def running?
  status == 'running'
end

.statusObject



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

def status
  Console.cmd 'boot2docker status'
end

.upObject



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

def up
  Console.cmd 'boot2docker up'
end