kommando 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1eb976e3f92e3f6f40a3ec40c23e066fc1caaca5
4
- data.tar.gz: 8d8db58bca29f0f3c05f85f7f7c239130a02a810
3
+ metadata.gz: 0d3521e56231b4dc2100fce519d440157005c3f7
4
+ data.tar.gz: 382b63f80f81059847e56cb51a0fcc62366ee2f0
5
5
  SHA512:
6
- metadata.gz: 0b1db26c6871afc3450b3a7d7744569a42f2eb4762de02edf21c1a75f9d42cbd1862d0a909dee2cdf76f228123356981448af5240d680fb2aa5ce181fba51aa8
7
- data.tar.gz: 176e6c683af1f6d3418584279b520ace53e4482e6527e21f014a1e0ccffde507357f426c84d3d6817e2a788258abf07d8717b700ac87c03ee6e69403f805ad03
6
+ metadata.gz: 1c5673c728d2a97ac292e4a03918bf8d2a65eb0a4f6f47d1c53fdbf658775de5d5f41063d8cb595483961ed001d4c59bb769c0c6943f7c26196c6cd1fbc4e229
7
+ data.tar.gz: 33b3dbbce80ba81ce23c1a4777b4233540582c06958347f1605ee1064a4585cfd76afcbcf97f09b8c94aad0276b8c515428658a26e21e52370589ab9b098fe5a
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.9
4
+ Support for shell (bash) commands.
5
+
6
+ - FEAT: Support for running shell commands with `Kommando.new "$ echo hello | rev"`
7
+ - EXAMPLES: `shell` added.
8
+
3
9
  ## 0.0.8
4
10
  Improves killing, tries to fix Linux specific issues.
5
11
 
@@ -0,0 +1,7 @@
1
+ require "./lib/kommando"
2
+
3
+ k = Kommando.new "$ echo 'hello\nworld' | rev | rev"
4
+ k.run
5
+
6
+ raise "err" unless k.out == "hello\r\nworld"
7
+ puts "shell says: #{k.out}"
@@ -31,6 +31,8 @@ class Kommando
31
31
 
32
32
  @thread = nil
33
33
  @pid = nil
34
+
35
+ @shell = false
34
36
  end
35
37
 
36
38
  def run_async
@@ -48,7 +50,16 @@ class Kommando
48
50
  return false if @executed
49
51
  @executed = true
50
52
 
51
- command, *args = @cmd.split " "
53
+ command, *args = if @cmd.start_with? "$"
54
+ @shell = true
55
+ trash, line = @cmd.split "$"
56
+ line.lstrip!
57
+ ["bash", "-c", line]
58
+ else
59
+ #command, *args = @cmd.split " "
60
+ @cmd.split " "
61
+ end
62
+
52
63
  begin
53
64
  PTY.spawn(command, *args) do |stdout, stdin, pid|
54
65
  if @retry && stdout.eof?
@@ -132,7 +143,11 @@ class Kommando
132
143
  end
133
144
 
134
145
  def out
135
- @stdout.to_s
146
+ if @shell
147
+ @stdout.to_s.strip
148
+ else
149
+ @stdout.to_s
150
+ end
136
151
  end
137
152
 
138
153
  def code
@@ -1,3 +1,3 @@
1
1
  class Kommando
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
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.8
4
+ version: 0.0.9
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-09 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,6 +109,7 @@ files:
109
109
  - examples/kill.rb
110
110
  - examples/live_output.rb
111
111
  - examples/ping.rb
112
+ - examples/shell.rb
112
113
  - examples/stdout_to_file.rb
113
114
  - examples/timeout.rb
114
115
  - examples/uptime.rb