Module: Tid

Defined in:
lib/tid.rb,
lib/tid/docker.rb,
lib/tid/console.rb,
lib/tid/version.rb,
lib/tid/boot2docker.rb

Defined Under Namespace

Modules: Boot2docker, Console, Docker

Constant Summary collapse

VERSION =
'0.0.2'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.base_pathObject



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

def base_path
  ENV['TID_BASE_PATH'] ||= './spec/tid'
end

.bundle(options = []) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/tid.rb', line 25

def bundle(options = [])
  default_options = [
    '--gemfile',
    "#{base_path}/Gemfile"
  ]

  Bundler.with_clean_env do
    Console.cmd "bundle install #{default_options.concat(options).join(' ')}"
  end
end

.clearObject



19
20
21
22
23
# File 'lib/tid.rb', line 19

def clear
  Docker.stop
  Docker.rm
  Docker.rmi
end

.envObject



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

def env
  @env
end

.env!Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/tid.rb', line 44

def env!
  ENV['TID_HOSTNAME'] = h = Docker.hostname
  ENV['TID_PORT'] = p = Docker.container_ssh_port

  @env = {
    'TID_HOSTNAME' => h,
    'TID_PORT' => p,
    'TID_BASE_PATH' => base_path
  }
end

.prepareObject



12
13
14
15
16
17
# File 'lib/tid.rb', line 12

def prepare
  Boot2docker.prepare if Boot2docker.have?
  Docker.build
  Docker.run
  self.env!
end

Instance Method Details

#cmd(str, env = {}) ⇒ Object



7
8
9
# File 'lib/tid.rb', line 7

def cmd(str, env = {})
  Console.cmd(str, env)
end