class Object
Constants
- DIR
- QNAME
- RNAME
Public Instance Methods
check_running()
click to toggle source
# File bin/docker-env, line 55 def check_running `ps ax` =~ %r[/[D]ocker.app] end
current(options)
click to toggle source
# File bin/docker-env, line 44 def current(options) name(readlink, options) end
name(f, options)
click to toggle source
# File bin/docker-env, line 31 def name(f, options) options[:verbose] ? f : f.sub(/^.+Docker\.(qcow2|raw)\./, '') end
readlink()
click to toggle source
# File bin/docker-env, line 35 def readlink if !File.symlink?(symlink) $stderr.puts "Image not symlink, try init!" exit 1 end File.readlink(symlink) end
running?(options)
click to toggle source
# File bin/docker-env, line 59 def running?(options) active = check_running tell_docker('quit', options) if active && (options[:kill] || options[:restart]) # wait for docker to quit while check_running $stderr.putc '.' if options[:verbose] sleep 1 end $stderr.puts '' return active unless check_running $stderr.puts 'Please quit Docker.app before using this script!' exit 1 end
symlink()
click to toggle source
# File bin/docker-env, line 24 def symlink n = File.join(DIR, QNAME); return n if File.exist?(n) return File.join(DIR, RNAME); end
tell_docker(what, options)
click to toggle source
# File bin/docker-env, line 48 def tell_docker(what, options) # wrap in try because "open" generated an error which we can ignore cmd = %[osascript -e 'try\ntell application "Docker" to #{what}\nend try'] $stderr.puts cmd if options[:verbose] system(cmd) end