joumae 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/joumae/command.rb +38 -11
- data/lib/joumae/version.rb +1 -1
- 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: 0ef042d05aeab5b8c0b04b20bc7d941cb12662f2
|
4
|
+
data.tar.gz: 9db5f0ee408e17c7f6a25d1e1131f908af75ad9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee52c72f005d0debe8829fe4ddbf659fdbc11f4850c4ac08811c84b8c52fdb6684ea73fb09ead5283ca90d1a29d7b031006a9c160815a0904ae42f2948ce0ba7
|
7
|
+
data.tar.gz: e636aec70a610a459cce4c397e5a6d5c73240aef3cd6d05877d47b9e2785a4b8802d9acd1380538c44a513c14ac7a3f9d187c79ae2fb0c274c10e308799af94f
|
data/Gemfile.lock
CHANGED
data/lib/joumae/command.rb
CHANGED
@@ -5,6 +5,8 @@ require 'open3'
|
|
5
5
|
|
6
6
|
module Joumae
|
7
7
|
class Command
|
8
|
+
EXIT_STATUS_INTERRUPT = 130
|
9
|
+
|
8
10
|
attr_reader :cmd
|
9
11
|
|
10
12
|
def initialize(cmd, resource_name:, client:)
|
@@ -26,19 +28,13 @@ module Joumae
|
|
26
28
|
|
27
29
|
def run!
|
28
30
|
status = Joumae::Transaction.run!(resource_name: @resource_name, client: @client) do
|
29
|
-
Open3.popen3(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
o.each do |line|
|
34
|
-
STDOUT.puts line
|
35
|
-
STDOUT.flush
|
31
|
+
Open3.popen3(cmd) do |i, o, e, w|
|
32
|
+
unless STDIN.tty?
|
33
|
+
redirect(STDIN => i)
|
36
34
|
end
|
35
|
+
i.close
|
37
36
|
|
38
|
-
e
|
39
|
-
STDERR.puts line
|
40
|
-
STDERR.flush
|
41
|
-
end
|
37
|
+
redirect(o => STDOUT, e => STDERR)
|
42
38
|
|
43
39
|
debug w.value
|
44
40
|
|
@@ -50,6 +46,37 @@ module Joumae
|
|
50
46
|
|
51
47
|
private
|
52
48
|
|
49
|
+
def redirect(mapping)
|
50
|
+
files = mapping.keys
|
51
|
+
|
52
|
+
until files.all?(&:eof) do
|
53
|
+
ready = IO.select(files)
|
54
|
+
|
55
|
+
continue unless ready
|
56
|
+
|
57
|
+
readable = ready[0]
|
58
|
+
|
59
|
+
readable.each do |f|
|
60
|
+
begin
|
61
|
+
data = f.read_nonblock(1024)
|
62
|
+
|
63
|
+
mapping[f].write(data)
|
64
|
+
rescue EOFError => e
|
65
|
+
debug e.to_s;
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def all_eof?(files)
|
72
|
+
begin
|
73
|
+
files.all?(&:eof)
|
74
|
+
rescue Interrupt => e
|
75
|
+
warn "You've interrupted while joumae is running a command."
|
76
|
+
EXIT_STATUS_INTERRUPT
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
53
80
|
def info(msg)
|
54
81
|
logger.info msg
|
55
82
|
end
|
data/lib/joumae/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joumae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke KUOKA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|