koma 0.10.1 → 0.11.0

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: 5587b2e28c83b821c268b46ee8fb55e0703b59d2
4
- data.tar.gz: e8e20af923807a34b761d67783502f178517a56e
3
+ metadata.gz: 81a82ab20cf42d0d1961a641f0694c9e1e5ae68f
4
+ data.tar.gz: 44d1c6c6180fe5adeac4ceaf7da558fef6d9aff6
5
5
  SHA512:
6
- metadata.gz: 6a1792a8a5b07b706ff5af04b9ecebba986e70e7989414bff39c9e0c450113438a43867ffebdbffffc4841a66290511e353c3069464725c29295ac064ce3a156
7
- data.tar.gz: 54251c646ee8ff76ba963079bb7cd66e1a616f049a84ce62ae7d7f7d79c6818c867931657ba7b3b7005322a7aa2567dd48ab10eefc49307c2c959437076dcd7c
6
+ metadata.gz: add6325fa9970357a34053e2c90fac65ed276cfed461d69576d08237cef832cdc41a6e012ffb2e1c7e90ca0b32278f5df3dccd37938c602d7db89aac711baa95
7
+ data.tar.gz: 55faa2f2c085b3f4db78743bb6dc9acaabc5b87ea7b50832645f366b90ef87707492803ab3428aeb02f821b276d98df3b13f58b2f9ceb164c024f49f7fa18d1a
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
4
- - 2.2.4
5
- - 2.1.8
3
+ - 2.3.1
4
+ - 2.2.5
5
+ - 2.1.10
@@ -20,16 +20,16 @@ module Koma
20
20
  result
21
21
  end
22
22
 
23
- def run_command(command)
23
+ def run_commands(commands)
24
24
  if host.include?(',')
25
25
  list = host.split(',').uniq
26
26
  results = Parallel.map(list) do |h|
27
- run_command_via_ssh(h, options, command)
27
+ run_commands_via_ssh(h, options, commands)
28
28
  end
29
29
  arr = [list, results].transpose
30
30
  result = Hash[*arr.flatten]
31
31
  else
32
- result = run_command_via_ssh(host, options, command)
32
+ result = run_commands_via_ssh(host, options, commands)
33
33
  end
34
34
  result
35
35
  end
@@ -39,17 +39,19 @@ module Koma
39
39
  out(options[:key])
40
40
  end
41
41
 
42
- def run_command_via_ssh(host, options, command)
42
+ def run_commands_via_ssh(host, options, commands)
43
43
  set :ssh_options, build_ssh_options(host, options)
44
- result = Specinfra.backend.run_command(command)
45
- { command =>
46
- {
44
+ results = {}
45
+ commands.each do |command|
46
+ result = Specinfra.backend.run_command(command)
47
+ results[command] = {
47
48
  exit_signal: result.exit_signal,
48
49
  exit_status: result.exit_status,
49
50
  stderr: result.stderr,
50
51
  stdout: result.stdout
51
52
  }
52
- }
53
+ end
54
+ results
53
55
  end
54
56
 
55
57
  private
@@ -34,25 +34,25 @@ module Koma
34
34
  end
35
35
  end
36
36
 
37
- desc 'run-command <host1,host2,..> <command>', 'run command on a remote machine'
37
+ desc 'run-command <host1,host2,..> <command1> <command2> ...', 'run command on a remote machine'
38
38
  option :yaml, type: :boolean, desc: 'stdout YAML', aliases: :Y
39
39
  option :identity_file, type: :string, banner: '<identity_file>', desc: 'identity file', aliases: :i
40
40
  option :port, type: :numeric, banner: '<port>', desc: 'port', aliases: :p
41
- def run_command(host = nil, command = nil)
41
+ def run_command(host = nil, *commands)
42
42
  if host.nil?
43
43
  STDERR.puts 'ERROR: "koma run-command" was called with no arguments'
44
44
  STDERR.puts 'Usage: "koma run-command <host1,host2,..> <command>"'
45
45
  return
46
46
  end
47
- if command.nil?
48
- command = host
47
+ if commands.empty?
48
+ commands = [host]
49
49
  begin
50
50
  stdin = timeout(1) { $stdin.read }
51
51
  rescue Timeout::Error
52
52
  end
53
53
  if stdin.nil?
54
- STDERR.puts 'ERROR: "koma run-command" was called with no arguments'
55
- STDERR.puts 'Usage: "koma run-command <host1,host2,..> <command>"'
54
+ STDERR.puts 'ERROR: "koma run-commands" was called with no arguments'
55
+ STDERR.puts 'Usage: "koma run-commands <host1,host2,..> <commands>"'
56
56
  return
57
57
  end
58
58
  ret = stdin.split("\n").select { |line| line =~ /^Host ([^\s\*]+)/ }.map do |line|
@@ -63,7 +63,7 @@ module Koma
63
63
  end
64
64
  backend = Koma::Backend::Ssh.new(host, options)
65
65
  backend.stdin = stdin if stdin
66
- gathered = backend.run_command(command)
66
+ gathered = backend.run_commands(commands)
67
67
  if options[:yaml]
68
68
  puts YAML.dump(gathered)
69
69
  else
@@ -1,3 +1,3 @@
1
1
  module Koma
2
- VERSION = '0.10.1'
2
+ VERSION = '0.11.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor