docker-env 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/docker-env +33 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f33b10f7bf7f70865735af1a5c528de04a581ff
|
4
|
+
data.tar.gz: 024670f80640a4a0dd8a46fb2e259cc406f8f60f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f34ea507fef861db30f108dc7b9e6ad605db38334eb99e58a1ff92c3402034812a6c35cf27d09759578bee8145205973e9a0d1025f4fb57d04a020593e0eae48
|
7
|
+
data.tar.gz: b86aff6d07962278789af3eac68a2c7522dd18688884a7cf620391ca402924bed3e7faf71b7388dd8c18c9edb399543d0663cdd8fab641f0e95a77f51a1e9bcb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/bin/docker-env
CHANGED
@@ -18,24 +18,50 @@ arguments :strict
|
|
18
18
|
wrap_help_text :verbatim
|
19
19
|
|
20
20
|
switch [:v, :verbose], desc: 'be more verbose'
|
21
|
+
switch [:k, :kill], desc: 'quit docker if it is running'
|
22
|
+
switch [:r, :restart], desc: 'stop and start docker around command'
|
21
23
|
|
22
24
|
def current(options)
|
23
25
|
f = File.readlink(SYMLINK)
|
24
26
|
options[:verbose] ? f : f.split('.').last
|
25
27
|
end
|
26
28
|
|
27
|
-
def
|
28
|
-
|
29
|
+
def tell_docker(what, options)
|
30
|
+
cmd = %[osascript -e 'tell application "Docker" to #{what}']
|
31
|
+
$stderr.puts cmd if options[:verbose]
|
32
|
+
system(cmd)
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_running
|
36
|
+
`ps ax` =~ %r[/[D]ocker.app]
|
37
|
+
end
|
38
|
+
|
39
|
+
def running?(options)
|
40
|
+
active = check_running
|
41
|
+
tell_docker('quit', options) if active && (options[:kill] || options[:restart])
|
42
|
+
|
43
|
+
# wait for docker to quit
|
44
|
+
while check_running do
|
45
|
+
$stderr.putc '.' if options[:verbose]
|
46
|
+
sleep 1
|
47
|
+
end
|
48
|
+
$stderr.puts ''
|
49
|
+
|
50
|
+
return active unless check_running
|
29
51
|
|
30
52
|
$stderr.puts 'Please quit Docker.app before using this script!'
|
31
53
|
exit 1
|
32
54
|
end
|
33
55
|
|
56
|
+
post do |global_options, _command, _options, _args|
|
57
|
+
tell_docker('activate', global_options) if global_options[:restart]
|
58
|
+
end
|
59
|
+
|
34
60
|
desc 'setup by moving Docker.qcow2 to "image_name" and linking back'
|
35
61
|
arg 'image_name'
|
36
62
|
command :init do |c|
|
37
63
|
c.action do |global_options, _options, args|
|
38
|
-
running?
|
64
|
+
running?(global_options)
|
39
65
|
if File.symlink?(SYMLINK)
|
40
66
|
$stderr.puts "Already setup. Current is: #{current(global_options)}"
|
41
67
|
exit 1
|
@@ -73,8 +99,8 @@ Removes current link so that the next time docker starts, it will create a
|
|
73
99
|
create the symlink
|
74
100
|
EOF
|
75
101
|
command :new do |c|
|
76
|
-
c.action do |
|
77
|
-
running?
|
102
|
+
c.action do |global_options, _options, _args|
|
103
|
+
running?(global_options)
|
78
104
|
if File.exist?(SYMLINK) || !File.symlink?(SYMLINK)
|
79
105
|
$stderr.puts "Please use '--force' to force delete current image!"
|
80
106
|
exit 1
|
@@ -109,8 +135,8 @@ end
|
|
109
135
|
desc 'Link to "image"'
|
110
136
|
arg 'image'
|
111
137
|
command :use do |c|
|
112
|
-
c.action do |
|
113
|
-
running?
|
138
|
+
c.action do |global_options, _options, args|
|
139
|
+
running?(global_options)
|
114
140
|
file = "#{SYMLINK}.#{args[0]}"
|
115
141
|
File.exist?(file) or raise "Image #{file} does not exist"
|
116
142
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Frankel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|