voltos 0.3.0.rc11 → 0.3.0.rc12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/voltos +35 -15
  3. data/lib/voltos/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95927f2e70936a2a34eba426842f51affd050a7e
4
- data.tar.gz: b13eb1e0e9e464dcb1938e2f2a9de3eac6a10438
3
+ metadata.gz: 6108fdaecd4dee14499bcae26dd4f5a92c819cfe
4
+ data.tar.gz: 91d77ea706f913b4158982679621c685da45250d
5
5
  SHA512:
6
- metadata.gz: 154886e9b986bde9d457da7eb0f2929779796a98b9a11c1520c84c68806fedde3d84d5d3e7deb77880fca3dad8757398960bbe7813473b2445f96cc687152bcf
7
- data.tar.gz: acebddbec308e50d4f11b0b44a25d20a87133a1dacb396bee50a5ef905a5284c8a64950e9e65e5436db231bcb1c4992edd5928f488e74cce00ffa6e59d5bc37d
6
+ metadata.gz: fe7e57721b997651e8af022d97640a5a2fbd1fb33c0946aae5922f1362f8a8eef57b535cd0f80c91d4566326c032c164063f7e3c361a19a7e75072f522ee5c65
7
+ data.tar.gz: 9baf412dbb50c35f7f781a66b2a82b1cb294ef0484199ae57e5a6dceeb993e81ab1a973c9bc067c3d09285f1fd1c155021904771b9c5c32d1fd1887df5c98034
data/exe/voltos CHANGED
@@ -2,10 +2,10 @@
2
2
  require 'pty'
3
3
  require 'open3'
4
4
  require 'readline'
5
- STDOUT.sync = true
6
- bin = "#{Gem.bin_path('voltos', 'voltos')}-cli"
7
- if STDIN.tty?
8
- status = PTY.spawn(bin, *ARGV) do |stdout, stdin, pid|
5
+
6
+ def run_as_tty(bin, args)
7
+ STDOUT.sync = true
8
+ status = PTY.spawn(bin, *args) do |stdout, stdin, pid|
9
9
  stdout.sync = true
10
10
  Thread.new do
11
11
  loop do
@@ -25,34 +25,54 @@ if STDIN.tty?
25
25
  end
26
26
  begin
27
27
  Process::waitpid(pid) rescue nil
28
- while out = stdout.getc do
29
- STDOUT.print out
30
- end
31
28
  rescue SystemExit, Interrupt
32
29
  Process.kill('INT', pid)
33
30
  retry
34
31
  rescue EOFError
35
- puts "Ctrl-D"
36
- rescue IOError
32
+ rescue IOError, Errno::EIO
37
33
  end
38
34
  end
39
- else
35
+ status
36
+ end
37
+
38
+ def run_as_daemon(bin, args)
39
+ process = nil
40
40
  Open3.popen3(bin, *ARGV) do |stdin, stdout, stderr, thread|
41
+ Thread.new do
42
+ while !stdin.closed? do
43
+ input = Readline.readline("", true).strip
44
+ stdin.puts input
45
+ end
46
+ end
47
+
41
48
  errThread = Thread.new do
42
49
  while !stderr.eof? do
43
50
  putc stderr.readchar
44
51
  end
45
52
  end
53
+
46
54
  outThread = Thread.new do
47
55
  while !stdout.eof? do
48
56
  putc stdout.readchar
49
57
  end
50
58
  end
51
- Process::waitpid(thread.pid) rescue nil
52
- errThread.join
53
- outThread.join
54
- process = thread.value
55
- status = process.exitstatus.to_i if !process.nil?
59
+
60
+ begin
61
+ Process::waitpid(thread.pid) rescue nil
62
+ errThread.join
63
+ outThread.join
64
+ process = thread.value
65
+ rescue SystemExit, Interrupt
66
+ retry
67
+ end
56
68
  end
69
+ return process.exitstatus if process
70
+ end
71
+
72
+ bin = "#{Gem.bin_path('voltos', 'voltos')}-cli"
73
+ if STDIN.tty?
74
+ status = run_as_tty(bin, ARGV)
75
+ else
76
+ status = run_as_daemon(bin, ARGV)
57
77
  end
58
78
  exit(status.to_i)
@@ -1,3 +1,3 @@
1
1
  module Voltos
2
- VERSION = "0.3.0.rc11"
2
+ VERSION = "0.3.0.rc12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voltos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.rc11
4
+ version: 0.3.0.rc12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel May
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-16 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler