hotdog 0.6.4 → 0.6.5

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: f1b8937e6ed17779e09622476dae786c9f7e04a4
4
- data.tar.gz: 59d5cf9204f2b3cf7a272734ca62253f09b01347
3
+ metadata.gz: e5b7de644e20c6baece23e0cfb092c648f450e86
4
+ data.tar.gz: 5e12b97c01d76aa8b9a7d5ede0cf5fe3371dda3a
5
5
  SHA512:
6
- metadata.gz: c763c88d2083cb10007195b7962edd980a47f0145a613081b1a5c9713da91ffed3350daa7bdd1317f7e9d00b928141f69a5005e6fa2026deb127a6e6a1b71173
7
- data.tar.gz: 796c96d4b2c954690fc9bbf97339d8ebe4213fc7c3c92fafc5c5a67b90914c208ad4eea7c3a2b21f5c871dc4562c002ff561b443321d949c24038b3491743caf
6
+ metadata.gz: 390fcdb204d802c1ed9a49e7657233d6d2581d7b910c22d5370ffa722d934ba9dc4aacc1b199a525694962bc435c2ded7d9bf7d9056c3e51ed6ad959cb58366c
7
+ data.tar.gz: 42fe7102b0c6cb9564fbdc1acb3f7dd739bacc1d59d7b7e82c7ad8391d71bb46007ea4386d76a228adc163b5fdc40ac0ef58e8422e3ac541d4e6b5fb30163cc2
@@ -11,10 +11,9 @@ module Hotdog
11
11
  class Pssh < SshAlike
12
12
  private
13
13
  def run_main(hosts, options={})
14
- use_color_p = use_color?
15
- stats = Parallel.map(hosts, in_threads: parallelism(hosts)) { |host|
14
+ stats = Parallel.map(hosts.each_with_index.to_a, in_threads: parallelism(hosts)) { |host, i|
16
15
  cmdline = build_command_string(host, @remote_command, options)
17
- exec_command(host, cmdline, true, use_color_p)
16
+ exec_command(host, cmdline, index: i, output: true)
18
17
  }
19
18
  if stats.all?
20
19
  exit(0)
@@ -74,10 +74,9 @@ module Hotdog
74
74
 
75
75
  def filter_hosts(hosts)
76
76
  if options[:filter_command]
77
- use_color_p = use_color?
78
77
  filtered_hosts = Parallel.map(hosts, in_threads: parallelism(hosts)) { |host|
79
78
  cmdline = build_command_string(host, options[:filter_command], options)
80
- [host, exec_command(host, cmdline, false, use_color_p)]
79
+ [host, exec_command(host, cmdline, output: false)]
81
80
  }.select { |host, stat|
82
81
  stat
83
82
  }.map { |host, stat|
@@ -148,15 +147,32 @@ module Hotdog
148
147
  end
149
148
  end
150
149
 
151
- def exec_command(identifier, cmdline, output=true, colorize=false)
150
+ def exec_command(identifier, cmdline, options={})
151
+ output = options.fetch(:output, true)
152
152
  logger.debug("execute: #{cmdline}")
153
+ if use_color?
154
+ if options.key?(:index)
155
+ color = 31 + (options[:index] % 6)
156
+ else
157
+ color = 36
158
+ end
159
+ else
160
+ color = nil
161
+ end
153
162
  IO.popen(cmdline, in: :close, err: [:child, :out]) do |io|
154
163
  io.each_with_index do |s, i|
155
164
  if output
156
- STDOUT.write("\e[0;36m") if colorize
157
- STDOUT.write("#{identifier}:#{i}:")
158
- STDOUT.write("\e[0m") if colorize
159
- STDOUT.write(s)
165
+ if color
166
+ STDOUT.write("\e[0;#{color}m")
167
+ end
168
+ STDOUT.write(identifier)
169
+ STDOUT.write(":")
170
+ STDOUT.write(i.to_s)
171
+ STDOUT.write(":")
172
+ if color
173
+ STDOUT.write("\e[0m")
174
+ end
175
+ STDOUT.puts(s)
160
176
  end
161
177
  end
162
178
  end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rbconfig"
4
+
5
+ module Hotdog
6
+ module Commands
7
+ class Version < BaseCommand
8
+ def run(args=[], options={})
9
+ ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"])
10
+ exit(system(ruby, $0, "--version") ? 0 : 1)
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ # vim:set ft=ruby :
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-27 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - lib/hotdog/commands/ssh.rb
164
164
  - lib/hotdog/commands/tags.rb
165
165
  - lib/hotdog/commands/up.rb
166
+ - lib/hotdog/commands/version.rb
166
167
  - lib/hotdog/formatters.rb
167
168
  - lib/hotdog/formatters/csv.rb
168
169
  - lib/hotdog/formatters/json.rb
@@ -213,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
214
  version: '0'
214
215
  requirements: []
215
216
  rubyforge_project:
216
- rubygems_version: 2.4.5
217
+ rubygems_version: 2.4.5.1
217
218
  signing_key:
218
219
  specification_version: 4
219
220
  summary: Yet another command-line tool for Datadog
@@ -239,4 +240,3 @@ test_files:
239
240
  - spec/parser/regexp_expression_spec.rb
240
241
  - spec/parser/string_expression_spec.rb
241
242
  - spec/spec_helper.rb
242
- has_rdoc: