hotdog 0.8.2 → 0.9.0

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: b0cc99f3c55686cdd50dcb7ed8cdcc71fbc21b5d
4
- data.tar.gz: 4878f147992a472e6774a9c93d2003c39ac390fc
3
+ metadata.gz: 2ccee00108b31b9154a5f11b031a06955d1b4dd0
4
+ data.tar.gz: 23bda8a7a49eddb81abfd3c5e96580715cc9a6ca
5
5
  SHA512:
6
- metadata.gz: 04e673d3d53675091e32b51f738971b57ad6e6b9d28f81e31094674b8f99c604af1ceaae9584520c8cd7d8191d29c9a92bbdd364ff55c4d595c702e8ebec3cb1
7
- data.tar.gz: 8d3e3345477f7e752b123547c6069e1420e43a88828efa304c33b3aea364e1bf681528c8f3168ff87932852e6efd20f804a7499db240ae9dbef1928b40ac3b1d
6
+ metadata.gz: 322a60fa2690142f3b30d934136e06462c473a4a8be83c6d761783f3a219badc79ae9215b5f4246cb30bc26ac08a365457aca1310d58e8bc64c1faf78f350257
7
+ data.tar.gz: 6958e8bc715bda65ff2ad7b86e0068288c76c201661e5d84f97b653564484d2f1e065cddec8e1f367cb4f71a24ed89cfe1c7456287434f0047112266c1bf993a
@@ -4,6 +4,7 @@ require "json"
4
4
  require "parallel"
5
5
  require "parslet"
6
6
  require "shellwords"
7
+ require "tempfile"
7
8
  require "hotdog/commands/ssh"
8
9
 
9
10
  module Hotdog
@@ -22,11 +23,21 @@ module Hotdog
22
23
 
23
24
  private
24
25
  def run_main(hosts, options={})
26
+ if STDIN.tty?
27
+ infile = nil
28
+ else
29
+ infile = Tempfile.new()
30
+ while cs = STDIN.read(4096)
31
+ infile.write(cs)
32
+ end
33
+ infile.flush
34
+ infile.seek(0)
35
+ end
25
36
  begin
26
37
  stats = Parallel.map(hosts.each_with_index.to_a, in_threads: parallelism(hosts)) { |host, i|
27
38
  cmdline = build_command_string(host, @remote_command, options)
28
39
  identifier = options[:show_identifier] ? host : nil
29
- success = exec_command(identifier, cmdline, index: i, output: true)
40
+ success = exec_command(identifier, cmdline, index: i, output: true, infile: infile.path)
30
41
  if !success && options[:stop_on_error]
31
42
  raise StopException.new
32
43
  end
@@ -367,7 +367,7 @@ module Hotdog
367
367
 
368
368
  def initialize(op, expression)
369
369
  case (op || "not").to_s
370
- when "!", "~", /\Anot\z/i
370
+ when "!", "~", "NOT", "not"
371
371
  @op = :NOT
372
372
  else
373
373
  raise(SyntaxError.new("unknown unary operator: #{@op.inspect}"))
@@ -158,7 +158,12 @@ module Hotdog
158
158
  else
159
159
  color = nil
160
160
  end
161
- IO.popen(cmdline, in: :close, err: [:child, :out]) do |io|
161
+ if options[:infile]
162
+ stdin = IO.popen("cat #{Shellwords.shellescape(options[:infile])}")
163
+ else
164
+ stdin = :close
165
+ end
166
+ IO.popen(cmdline, in: stdin, err: [:child, :out]) do |io|
162
167
  io.each_with_index do |s, i|
163
168
  if output
164
169
  if identifier
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.8.2"
2
+ VERSION = "0.9.0"
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.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -256,4 +256,3 @@ test_files:
256
256
  - spec/parser/regexp_expression_spec.rb
257
257
  - spec/parser/string_expression_spec.rb
258
258
  - spec/spec_helper.rb
259
- has_rdoc: