mediakit 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c160825c9e2f9c658e27deba0c1b85901d1a26b3
4
- data.tar.gz: 9fda675bcda6a2640361e713c0fe8a3ed2caf40e
3
+ metadata.gz: 107e031c77eff9e854d35d6f1645b3e934ca9136
4
+ data.tar.gz: e4f10d51c9f694e06576dc17ce55ae8a39b00d9e
5
5
  SHA512:
6
- metadata.gz: a2898c825709b0544492c17bc1e82ac8a10c93c3dfea9abd4105ac158071449da26032125195c1d0467052d5604dacf043f14e388d2f4ba6d322be1411f4c409
7
- data.tar.gz: e02a33b4ff394e976fcd1aee61de63cebbb1a21df6833395c9371d824f9576939c37461ceca395790cdae72e48706b9958ddb84517da2a5f808c4107c9baae87
6
+ metadata.gz: 9380bfc22cb3c72d33af11864bd2e67ec4be24865dd1360695a981f0eac683bd150071806234ca61eb97b2d08c787e12eacbdcde9355f5be7617a9defb2bf848
7
+ data.tar.gz: 8510cf29d66fa761e936beea7456e0d8b2e7e247bdf86a2e7cd5f2b7f266b53070715e88a5391ae9fe31b260f76472c17596e277a3ebbbefd57479387fe99fed
@@ -46,20 +46,21 @@ module Mediakit
46
46
 
47
47
  def wait(stdout, stderr, wait_thread)
48
48
  begin
49
- setup_watchers(stderr)
49
+ setup_watchers(stdout, stderr)
50
50
  loop_thread = Thread.new { run_loop }
51
51
  wait_thread.join
52
52
  exit_status = (wait_thread.value.exitstatus == 0)
53
- output = stdout.read
54
53
  rescue Timeout::Error => error
55
54
  force_kill_process(wait_thread.pid)
56
55
  raise(error)
57
56
  ensure
58
57
  teardown_watchers
59
58
  loop_thread.join if loop_thread
59
+ @out_watcher.read
60
+ @err_watcher.read
60
61
  end
61
62
 
62
- [exit_status, output, @out_watcher.data]
63
+ [exit_status, @out_watcher.data, @err_watcher.data]
63
64
  end
64
65
 
65
66
  def build_command(bin, *args)
@@ -76,11 +77,13 @@ module Mediakit
76
77
  "#{bin} #{escaped_args}"
77
78
  end
78
79
 
79
- def setup_watchers(stderr)
80
+ def setup_watchers(stdout, stderr)
80
81
  @timer = @timeout ? TimeoutTimer.new(@timeout, Thread.current) : nil
81
- @out_watcher = IOWatcher.new(stderr) { |data| @timer.update if @timer; logger.info(data); }
82
+ @out_watcher = IOWatcher.new(stdout) { |data| @timer.update if @timer; logger.info(data); }
83
+ @err_watcher = IOWatcher.new(stderr) { |data| @timer.update if @timer; logger.info(data); }
82
84
  @loop = Coolio::Loop.new
83
85
  @out_watcher.attach(@loop)
86
+ @err_watcher.attach(@loop)
84
87
  @timer.attach(@loop) if @timer
85
88
  end
86
89
 
@@ -94,7 +97,6 @@ module Mediakit
94
97
 
95
98
  def teardown_watchers
96
99
  @loop.watchers.each { |w| w.detach if w.attached? }
97
- @out_watcher.close if @out_watcher && !@out_watcher.closed?
98
100
  @loop.stop if @loop.has_active_watchers?
99
101
  rescue RuntimeError => e
100
102
  logger.warn(e.message)
@@ -108,9 +110,10 @@ module Mediakit
108
110
  end
109
111
 
110
112
  class IOWatcher < Coolio::IO
111
- attr_reader(:data)
113
+ attr_reader(:io, :data)
112
114
 
113
115
  def initialize(io, &block)
116
+ @io = io
114
117
  @block = block
115
118
  @data = ''
116
119
  super
@@ -124,6 +127,11 @@ module Mediakit
124
127
  def on_close
125
128
  @block = nil
126
129
  end
130
+
131
+ def read
132
+ @data << @io.read unless @io.closed?
133
+ @io.close unless @io.closed?
134
+ end
127
135
  end
128
136
 
129
137
  class TimeoutTimer < Coolio::TimerWatcher
@@ -1,3 +1,3 @@
1
1
  module Mediakit
2
- VERSION = '0.1.5'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediakit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ainame
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport