dg 0.5.19 → 0.6.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dg/docker.rb +20 -18
  3. data/lib/dg/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a3f4b067937b5536ae9cfa52690850c436b61d1
4
- data.tar.gz: 119852a348e991a32ffd868304ca80782e1c7215
3
+ metadata.gz: 8b00be5ea28289ada6575a196c4c06d72054e47e
4
+ data.tar.gz: 77decf3d5e7776cbab171e1b90e627fba28c5821
5
5
  SHA512:
6
- metadata.gz: 2f814cb699707ee2aecb95d19f491d85460c28fe432efeb40b8e6a05b2e31660d0fc4c09b97b1b3146f9bce13f3375e520cafab69818cc708c7428ab370c5108
7
- data.tar.gz: cd590c47ffdcaf5b2a0607237ac527cbb883655baaa8cd1bdedd1245e23da60f387d2bd063a86f946f0c638bb153ef94f2833e03754b8ff5d9136cf62a036868
6
+ metadata.gz: 510fdf4503a1e0bc81f9102fecde5d9a87fe3b3afd0a7c0b176fbe7b9454bb2551950724a1cb39c093e5d507442b2fe3c9aae179eac5e6e2853e15644a77012e
7
+ data.tar.gz: 5bc7e6f6eab06c13a6122e5281c2d9eefbe8b25d50e3edcec65621c2b091e256d650b190d955ca9e793ce35ede493b6cde3655504d67833590480da9c53e5ab2
data/lib/dg/docker.rb CHANGED
@@ -5,7 +5,7 @@ require 'dg/version'
5
5
 
6
6
  module DG
7
7
  class Docker
8
- SUDO = !!ENV['GO_PIPELINE_NAME']
8
+ SUDO = !!ENV['USE_SUDO']
9
9
  BASEPATH = Dir.pwd
10
10
 
11
11
  FIG_YML_PATH = "#{BASEPATH}/fig.yml"
@@ -27,7 +27,7 @@ module DG
27
27
  end
28
28
 
29
29
  def push
30
- run_with_output("docker push #{git_image_name.tr(':',' ')}")
30
+ run_with_output("docker push #{git_image_name}")
31
31
  end
32
32
 
33
33
  def deploy
@@ -84,24 +84,26 @@ module DG
84
84
  def run_with_output(command, capture = false)
85
85
  sudo_command = SUDO ? "sudo -E bash -c '#{command}'" : command
86
86
  puts "Running `#{sudo_command}` in #{Dir.pwd}"
87
- if capture
88
- # TODO: Replace this with a combined function below, so
89
- # that non-zero exit codes are handled correctly
90
- return `#{sudo_command}`
91
- else
92
- begin
93
- PTY.spawn(sudo_command) do |stdin, stdout, pid|
94
- stdin.each { |line| print line } rescue Errno::EIO
95
- Process.wait(pid)
96
- end
97
- status_code = $?.exitstatus
98
-
99
- error!(RuntimeError.new("exit code was #{status_code}"), "executing #{command}") if status_code != 0
100
87
 
101
- return status_code
102
- rescue PTY::ChildExited
103
- puts "The child process exited!"
88
+ begin
89
+ PTY.spawn(sudo_command) do |stdin, stdout, pid|
90
+ buffer = ''
91
+ callback = capture ?
92
+ ->(line) {
93
+ print line
94
+ buffer << line
95
+ } :
96
+ ->(line) { print line }
97
+ stdin.each(&callback) rescue Errno::EIO
98
+ Process.wait(pid)
104
99
  end
100
+ status_code = $?.exitstatus
101
+
102
+ error!(RuntimeError.new("exit code was #{status_code}"), "executing #{command}") if status_code != 0
103
+
104
+ return capture ? buffer : status_code
105
+ rescue PTY::ChildExited
106
+ puts "The child process exited!"
105
107
  end
106
108
  end
107
109
 
data/lib/dg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DG
2
- VERSION = '0.5.19'
2
+ VERSION = '0.6.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.19
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Malet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  DockerGo (DG)