kommando 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/examples/in.rb +9 -0
- data/examples/nano.rb +24 -0
- data/lib/kommando.rb +18 -0
- data/lib/kommando/buffer.rb +7 -0
- data/lib/kommando/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 087165e6259c0a09ac7fb5eaf432338dd92fe9b6
|
4
|
+
data.tar.gz: 06ff447d8ee0ebadce51fae705628cef8877d08d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 378bdaa26cda65cd3cd154501578cddc3a6e34c19e573ac3a3bf92bb270d2cecdec64a91eb1ded589cd641b2520cac7d9f8e6d4521d52bd20f13b2eef2ad08c6
|
7
|
+
data.tar.gz: 961ed2f546c6edf6b81091a0988128331dbc485cdb25d71d7f7fefd83ba22ecdc4352d9ce73f4dcb810343a45d2683e984b1831fde3a70499d02efff9138ca18
|
data/CHANGELOG.md
CHANGED
data/examples/in.rb
ADDED
data/examples/nano.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "./lib/kommando"
|
2
|
+
require "tempfile"
|
3
|
+
|
4
|
+
scratch = Tempfile.new
|
5
|
+
|
6
|
+
k = Kommando.new "nano #{scratch.path}", {
|
7
|
+
output: true
|
8
|
+
}
|
9
|
+
|
10
|
+
Thread.new do
|
11
|
+
words = [
|
12
|
+
"hello\r",
|
13
|
+
"world\r",
|
14
|
+
"\x1B\x1Bx",
|
15
|
+
"y",
|
16
|
+
"\r"
|
17
|
+
]
|
18
|
+
words.each do |word|
|
19
|
+
k.in << word
|
20
|
+
sleep 0.25
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
k.run
|
data/lib/kommando.rb
CHANGED
@@ -10,6 +10,7 @@ class Kommando
|
|
10
10
|
def initialize(cmd, opts={})
|
11
11
|
@cmd = cmd
|
12
12
|
@stdout = Buffer.new
|
13
|
+
@stdin = Buffer.new
|
13
14
|
|
14
15
|
@output_stdout = opts[:output] == true
|
15
16
|
@output_file = if opts[:output].class == String
|
@@ -46,6 +47,8 @@ class Kommando
|
|
46
47
|
def kill
|
47
48
|
Process.kill('KILL', @pid)
|
48
49
|
@kill_happened = true
|
50
|
+
|
51
|
+
sleep 0.001 until @code # let finalize
|
49
52
|
end
|
50
53
|
|
51
54
|
def run
|
@@ -130,6 +133,17 @@ class Kommando
|
|
130
133
|
end
|
131
134
|
end
|
132
135
|
|
136
|
+
thread_stdin = Thread.new do
|
137
|
+
while true do
|
138
|
+
c = @stdin.getc
|
139
|
+
unless c
|
140
|
+
sleep 0.01
|
141
|
+
next
|
142
|
+
end
|
143
|
+
stdin.write c
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
133
147
|
if @timeout
|
134
148
|
begin
|
135
149
|
Timeout.timeout(@timeout) do
|
@@ -184,4 +198,8 @@ class Kommando
|
|
184
198
|
def code
|
185
199
|
@code
|
186
200
|
end
|
201
|
+
|
202
|
+
def in
|
203
|
+
@stdin
|
204
|
+
end
|
187
205
|
end
|
data/lib/kommando/buffer.rb
CHANGED
data/lib/kommando/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kommando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,8 +107,10 @@ files:
|
|
107
107
|
- examples/async.rb
|
108
108
|
- examples/env.rb
|
109
109
|
- examples/exit.rb
|
110
|
+
- examples/in.rb
|
110
111
|
- examples/kill.rb
|
111
112
|
- examples/live_output.rb
|
113
|
+
- examples/nano.rb
|
112
114
|
- examples/ping.rb
|
113
115
|
- examples/shell.rb
|
114
116
|
- examples/stdout_to_file.rb
|