kommando 0.0.6 → 0.0.7

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: a4b7759e3a3f6c9980f7dc19353cdece83fafdca
4
- data.tar.gz: 5c4ac9619d762838a4146a03fee7c5b314b7c920
3
+ metadata.gz: acfba23f49067f3a5685780644f56fb5369e4836
4
+ data.tar.gz: 4773b9387220563a69f13fb3f7c3e37a6c3c4639
5
5
  SHA512:
6
- metadata.gz: 378367b00a5cf6febd212d611eb35622fe37a1b530d233757e25b54d11af818778145a1f0cab1c5722049dc26cd3e8f765d72a0a1d19e52013247edf9081b8dd
7
- data.tar.gz: 1e2c26f31ade6e75cc68dd7a965566769f54cf46346c915d2863614d9185d52ff8c36f6cdfa944344e6ba7a33bc7dd5c3f31b007d38d190972179363adf6e193
6
+ metadata.gz: 40d0a3852ff6711cc36dbb422356f8c616f48348ce764a9ecc9d8cb781a528e456715545e089cd39f6ccde3b7b6823f9d36398398652fbeba02abae9db9ecfb5
7
+ data.tar.gz: a9bae7941b46c95b7d167f8a6c94078927b7a5d51c1fca5c40a450c93d641e97533eca7270e4eab0adf45d395b9c4af43caf61f9b67392f4a036b356cfe00301
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.7
4
+ Async running, killing the run.
5
+
6
+ - FEAT: Support async running with `k.run_async`
7
+ - FEAT: Support for killing the process.
8
+ - EXAMPLES: `async` and `kill` added.
9
+
3
10
  ## 0.0.6
4
11
  Fix Linux harder.
5
12
 
@@ -0,0 +1,13 @@
1
+ require "./lib/kommando"
2
+
3
+ k = Kommando.new "sleep 0.5"
4
+ k.run_async
5
+
6
+ puts "started in background"
7
+
8
+ while (k.code == nil) do
9
+ print "."
10
+ sleep 0.1
11
+ end
12
+
13
+ puts "exited"
@@ -0,0 +1,13 @@
1
+ require "./lib/kommando"
2
+
3
+ k = Kommando.new "sleep 10"
4
+
5
+ Thread.new do
6
+ puts "killer is waiting.."
7
+ sleep 1
8
+ k.kill
9
+ puts "..killed."
10
+ end
11
+ k.run
12
+
13
+ puts "Killed while sleeping."
@@ -27,6 +27,19 @@ class Kommando
27
27
  @executed = false
28
28
 
29
29
  @retry = opts[:retry] == true
30
+
31
+ @thread = nil
32
+ @pid = nil
33
+ end
34
+
35
+ def run_async
36
+ @thread = Thread.new do
37
+ run
38
+ end
39
+ end
40
+
41
+ def kill
42
+ Process.kill('KILL', @pid)
30
43
  end
31
44
 
32
45
  def run
@@ -41,6 +54,8 @@ class Kommando
41
54
  return run
42
55
  end
43
56
 
57
+ @pid = pid
58
+
44
59
  if @output_file
45
60
  stdout_file = File.open @output_file, 'w'
46
61
  stdout_file.sync = true
@@ -1,3 +1,3 @@
1
1
  class Kommando
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
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.6
4
+ version: 0.0.7
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-05-21 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,7 +104,9 @@ files:
104
104
  - bin/setup
105
105
  - bin/stress
106
106
  - bin/version
107
+ - examples/async.rb
107
108
  - examples/exit.rb
109
+ - examples/kill.rb
108
110
  - examples/live_output.rb
109
111
  - examples/ping.rb
110
112
  - examples/stdout_to_file.rb