kommando 0.1.0 → 0.1.1

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: 06f39743982905083dccf326b8edd83f882cefa4
4
- data.tar.gz: f7eb8a290c764606b716c2b15a451179502eb716
3
+ metadata.gz: 5a2293ea68b1d7c3e6fd7e3045a87aad8aee5ca3
4
+ data.tar.gz: ac8e7fcad1629c33147e8cbd637e30843758ba02
5
5
  SHA512:
6
- metadata.gz: c913d9b57655dfd1768c682cba99f0f0109c8cad22d2eff6a024c68c1b85e75672fab5449295f4ce9cfee0917994507f76bf338ecfdcbc21e79cd3aa3b523814
7
- data.tar.gz: 2fead68560757c6bad67aa22d663fa59cce61587bab9b52ed7e01f7ea6b71d379c468e230f0549bbe5e7c2963ab5eeac1cf1668aa492c6648e74b2811ccd859f
6
+ metadata.gz: 1f6e2bd07f08f2cc30977bb704ecf475e4e47b8b6552f24ffc13ed7a134973c81e01dff32bd52f49d5acb23e59365e05da0c50861925a5c8a26a176edb0ca67d
7
+ data.tar.gz: b3683acec3ee38045cb8348bb58ccc011dc7f6fc6a7eef0357376405ae91a20b7ef5164c682c3ed95d174b732e71b4d36481b542f99cc97912ea760f8b7a7be2
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.1
4
+ - FIX: Use `sh` with `Kommando.run "$ ls"` if `bash` was not found.
5
+
3
6
  ## 0.1.0
4
7
  - DOCS: `demos/ping_monitor.rb`
5
8
  - FEAT: `k.out.once` can chain `k.out.every` (`k.out.once(/smth/).every(/aftersmth/)`
data/bin/matrix CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  require "./lib/kommando"
4
4
  require "yaml"
5
+ loops=if ARGV[0]
6
+ ARGV[0].to_i
7
+ else
8
+ -1
9
+ end
5
10
 
6
11
  docker_compose=YAML.load(File.read("docker-compose.yml"))
7
12
  services = docker_compose["services"].keys
@@ -19,17 +24,31 @@ for service in services
19
24
  ks << k
20
25
  end
21
26
 
27
+ def cleanup(ks)
28
+ ks.map(&:kill)
29
+ Kommando.run "docker-compose down"
30
+ end
31
+
22
32
  loop do
33
+ puts "loops: #{loops}"
34
+ loops = loops - 1
35
+
23
36
  for k in ks do
24
37
  cmd=k.instance_variable_get(:@cmd)
25
38
  puts "#{cmd} (#{(k.code ? "STOP" : "RUNNING")})"
26
39
 
27
40
  if k.code
28
41
  puts k.out
42
+ cleanup(ks)
29
43
  exit 1
30
44
  end
31
45
  end
32
46
 
33
47
  print "-"*20; puts " #{DateTime.now.to_s}"
34
48
  sleep 2
49
+
50
+ if loops == 0
51
+ cleanup(ks)
52
+ exit 0
53
+ end
35
54
  end
@@ -9,8 +9,8 @@ set -e
9
9
 
10
10
  rake; rake; rake
11
11
  bin/e2e
12
- #bin/matrix
13
- bin/stress 2 10
12
+ bin/matrix 3
13
+ bin/stress 2 2
14
14
 
15
15
  echo
16
16
  head CHANGELOG.md
@@ -1,3 +1,14 @@
1
+ # $ ruby demos/ping_monitor.rb
2
+ # 0.077 xxxxxxxxxxxxxxxxxxxxxxx
3
+ # 0.021 xxxxxx
4
+ # 0.027 xxxxxxxx
5
+ # 0.021 xxxxxx
6
+ # 0.021 xxxxxx
7
+ # 0.041 xxxxxxxxxxxx
8
+ # 0.021 xxxxxx
9
+ # 0.023 xxxxxx
10
+ # ^C
11
+
1
12
  require "./lib/kommando"
2
13
 
3
14
  k = Kommando.new "ping -i 0.2 127.0.0.1"
@@ -24,4 +24,4 @@ services:
24
24
  alpine-2.3:
25
25
  build:
26
26
  context: .
27
- dockerfile: docker/Dockerfile.alpine-2.3
27
+ dockerfile: docker/Dockerfile.alpine-2.3
@@ -2,7 +2,7 @@ FROM ruby:2.4.1-alpine
2
2
 
3
3
  RUN apk add --no-cache \
4
4
  git build-base \
5
- nano bash
5
+ nano
6
6
 
7
7
  WORKDIR /app
8
8
 
@@ -2,7 +2,7 @@ FROM ruby:2.1-alpine
2
2
 
3
3
  RUN apk add --no-cache \
4
4
  git build-base \
5
- nano bash
5
+ nano
6
6
 
7
7
  WORKDIR /app
8
8
 
@@ -2,7 +2,7 @@ FROM ruby:2.2-alpine
2
2
 
3
3
  RUN apk add --no-cache \
4
4
  git build-base \
5
- nano bash
5
+ nano
6
6
 
7
7
  WORKDIR /app
8
8
 
@@ -2,7 +2,7 @@ FROM ruby:2.3-alpine
2
2
 
3
3
  RUN apk add --no-cache \
4
4
  git build-base \
5
- nano bash
5
+ nano
6
6
 
7
7
  WORKDIR /app
8
8
 
@@ -10,4 +10,4 @@ COPY lib/kommando/version.rb ./lib/kommando/
10
10
  RUN bundle install
11
11
 
12
12
  COPY . .
13
- ENTRYPOINT docker/entrypoint.sh
13
+ ENTRYPOINT docker/entrypoint.sh
@@ -0,0 +1,30 @@
1
+ require "./lib/kommando"
2
+
3
+ k = Kommando.new "redis-cli --raw", {
4
+ output: true
5
+ }
6
+
7
+ # redis sends cursor position queries (!) even with --raw
8
+ k.out.every /\e\[6n/ do |m|
9
+ k.in.write '\e0;0R'
10
+ end
11
+
12
+ got_pong = false
13
+ k.out.once "127.0.0.1:6379>" do
14
+ k.in.writeln "ping"
15
+ end.once "PONG" do
16
+ got_pong = true
17
+ end
18
+
19
+ k.run_async
20
+
21
+ # mitigate kommando bug with thread deadlock when writing to in from .every and .once
22
+ loop do
23
+ break if got_pong
24
+ sleep 0.1
25
+ end
26
+ sleep 0.1
27
+ k.in.writeln "exit"
28
+ k.wait
29
+
30
+ #Outputs some ANSI trash to terminal when exits (;1R;1R)
@@ -141,7 +141,12 @@ class Kommando
141
141
  command, *args = if @shell
142
142
  trash, line = @cmd.split "$", 2
143
143
  line.lstrip!
144
- ["bash", "-c", line]
144
+
145
+ if `command -v bash`
146
+ ["bash", "-c", line]
147
+ else
148
+ ["sh", "-c", line]
149
+ end
145
150
  else
146
151
  @cmd.split " "
147
152
  end
@@ -1,3 +1,3 @@
1
1
  class Kommando
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matti Paksula
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-23 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -187,6 +187,7 @@ files:
187
187
  - examples/out_once_chaining.rb
188
188
  - examples/passwd.rb
189
189
  - examples/ping.rb
190
+ - examples/redis_workaround.rb
190
191
  - examples/shell.rb
191
192
  - examples/shorthands.rb
192
193
  - examples/stackprof.rb
@@ -232,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
233
  version: '0'
233
234
  requirements: []
234
235
  rubyforge_project:
235
- rubygems_version: 2.6.11
236
+ rubygems_version: 2.6.12
236
237
  signing_key:
237
238
  specification_version: 4
238
239
  summary: Command runner with expect-like features