sidedock 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sidedock/cli.rb +18 -2
- data/lib/sidedock/configuration.rb +25 -0
- data/lib/sidedock/container.rb +2 -2
- data/lib/sidedock/image.rb +0 -1
- data/lib/sidedock/machine.rb +11 -5
- data/lib/sidedock.rb +2 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1547b9506277f91d09403b7711efa3c74fcdf5df
|
4
|
+
data.tar.gz: 9336b1ac9f4dda4a8d9f33eadf2266123ae7ed4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ced41b69bc14f0f387ef69a63f308cd21f5805961eb8d5c277c5d2348dd8c7899952a58a2cb72d5e34539ca262664b23435741097bce3224deaeb05e7444b2e
|
7
|
+
data.tar.gz: 0fcf42814c428f75a2cde390e7f648011af4fd1bd4235c55c1108b640395b7668d12f19a9b1f56440d4d5502e55fb77fd579d2f95b1d0fd8f601fe8984972d8b
|
data/lib/sidedock/cli.rb
CHANGED
@@ -6,15 +6,31 @@ module Sidedock
|
|
6
6
|
|
7
7
|
def initialize(default_options = '')
|
8
8
|
@default_options = default_options
|
9
|
-
@cmd = TTY::Command.new
|
10
9
|
end
|
11
10
|
|
11
|
+
|
12
12
|
def execute(command)
|
13
13
|
full_command = "#{program} #{@default_options} #{command}"
|
14
|
-
stdout, stderr =
|
14
|
+
stdout, stderr = command_runner.run full_command
|
15
15
|
raise "`#{command}` failed" if stderr.present?
|
16
16
|
stdout.strip
|
17
17
|
end
|
18
|
+
|
19
|
+
def command_runner
|
20
|
+
if Sidedock.configuration.debug
|
21
|
+
debug_command_runner
|
22
|
+
else
|
23
|
+
quiet_command_runner
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def debug_command_runner
|
28
|
+
@debug_command_runner ||= TTY::Command.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def quiet_command_runner
|
32
|
+
@quiet_command_runner ||= TTY::Command.new printer: :null
|
33
|
+
end
|
18
34
|
end
|
19
35
|
end
|
20
36
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Allow gem users to do:
|
2
|
+
#
|
3
|
+
# Sidedock.configure do |config|
|
4
|
+
# config.debug = true
|
5
|
+
# end
|
6
|
+
|
7
|
+
module Sidedock
|
8
|
+
class << self
|
9
|
+
attr_accessor :configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.configure
|
13
|
+
self.configuration ||= Configuration.new
|
14
|
+
yield configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
class Configuration
|
18
|
+
attr_accessor :debug
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@debug = false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
data/lib/sidedock/container.rb
CHANGED
@@ -2,7 +2,7 @@ module Sidedock
|
|
2
2
|
class Container < Base
|
3
3
|
attr_accessor :ports, :id
|
4
4
|
|
5
|
-
def initialize(id, port_mapping: {})
|
5
|
+
def initialize(id, port_mapping: {}, **options)
|
6
6
|
@id = id
|
7
7
|
@port_mapping = port_mapping
|
8
8
|
end
|
@@ -28,7 +28,7 @@ module Sidedock
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def ports
|
31
|
-
Ports.new
|
31
|
+
@ports ||= Ports.new @id, @port_mapping
|
32
32
|
end
|
33
33
|
|
34
34
|
def running?
|
data/lib/sidedock/image.rb
CHANGED
data/lib/sidedock/machine.rb
CHANGED
@@ -15,10 +15,6 @@ module Sidedock
|
|
15
15
|
raise "Could not start docker machine #{@name}" unless running?
|
16
16
|
end
|
17
17
|
|
18
|
-
def running?
|
19
|
-
docker_machine("ls -q --filter state=Running").include? @name
|
20
|
-
end
|
21
|
-
|
22
18
|
def start
|
23
19
|
docker_machine "start #{@name}"
|
24
20
|
end
|
@@ -28,8 +24,18 @@ module Sidedock
|
|
28
24
|
docker_machine "create -d virtualbox #{@name}"
|
29
25
|
end
|
30
26
|
|
27
|
+
def running?
|
28
|
+
return true if @running
|
29
|
+
if docker_machine("ls -q --filter state=Running").include? @name
|
30
|
+
@running = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
31
34
|
def exists?
|
32
|
-
|
35
|
+
return true if @exists
|
36
|
+
if docker_machine("ls -q").include? @name
|
37
|
+
@exists = true
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
def ip
|
data/lib/sidedock.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
%w( cli machine base image container ports port_configuration
|
1
|
+
%w( configuration cli machine base image container ports port_configuration
|
2
2
|
).each { |file| require "sidedock/#{file}" }
|
3
3
|
|
4
4
|
module Sidedock
|
@@ -8,7 +8,7 @@ module Sidedock
|
|
8
8
|
container.start
|
9
9
|
yield container
|
10
10
|
container.stop
|
11
|
-
container.remove
|
11
|
+
container.remove unless options[:keep_image]
|
12
12
|
end
|
13
13
|
|
14
14
|
def with_dockerfile(name, options = {}, &block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidedock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Raasveld
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/sidedock/cli.rb
|
36
36
|
- lib/sidedock/cli/docker_cli.rb
|
37
37
|
- lib/sidedock/cli/machine_cli.rb
|
38
|
+
- lib/sidedock/configuration.rb
|
38
39
|
- lib/sidedock/container.rb
|
39
40
|
- lib/sidedock/image.rb
|
40
41
|
- lib/sidedock/machine.rb
|