hotdog 0.11.0 → 0.12.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: 52dcd14a86fb66237bcb18755f02fde4109a2c22
4
- data.tar.gz: dcca4b54617bfb3dac88bff53db1605f26535984
3
+ metadata.gz: 81c8f88ce41f3d20b7099237e335f0baa453ad3a
4
+ data.tar.gz: 3aa663a263433092de26f1d5ec33cffb871e1b2e
5
5
  SHA512:
6
- metadata.gz: 2b5a34f103669cdca02a4233d1af3cff3c57b827a8b6b97b87bd9c54bb8fd71e411800540655597825cc3ba23e5753c49e0f0bc465f1354ddf047fa7b1e86c23
7
- data.tar.gz: 4b1d29a2ce4ddc458dc3a6d6a63d7ceff460bb24139e7083a282edaef3a7d3f08cf36fcd989fb4cc93c8723f9d381a588d60267f0861ed5f1d551689cef7cce3
6
+ metadata.gz: 04dfbc1dc88f135b680ee989ac02b708d2adf86a7cab3e315f3c0875eb5071b618ed97064ebefdc48d0b1bf991ee4f6c5bd9d623c7af13f0e5b555e40ecdea2e
7
+ data.tar.gz: 74a9fc5f60194286c07926a199f5e6a51064b62cce8057159d84195352686fbaa3dacdc42ed5e7a6f5d09508dbd4cb824ee741df34ed02be6afd2486dfa7a26a
@@ -95,8 +95,13 @@ module Hotdog
95
95
  end
96
96
 
97
97
  command.run(args, @options)
98
+ rescue Interrupt
99
+ STDERR.puts("Interrupt")
98
100
  rescue Errno::EPIPE => error
99
101
  STDERR.puts(error)
102
+ rescue => error
103
+ STDERR.puts(error)
104
+ exit(1)
100
105
  end
101
106
  end
102
107
 
@@ -352,14 +352,6 @@ module Hotdog
352
352
  def dump(options={})
353
353
  {}
354
354
  end
355
-
356
- def intermediates()
357
- []
358
- end
359
-
360
- def leafs()
361
- [self]
362
- end
363
355
  end
364
356
 
365
357
  class UnaryExpressionNode < ExpressionNode
@@ -428,14 +420,6 @@ module Hotdog
428
420
  {unary_op: @op.to_s, expression: @expression.dump(options)}
429
421
  end
430
422
 
431
- def intermediates()
432
- [self] + @expression.intermediates
433
- end
434
-
435
- def leafs()
436
- @expression.leafs
437
- end
438
-
439
423
  private
440
424
  def optimize1(options={})
441
425
  case op
@@ -600,7 +584,7 @@ module Hotdog
600
584
  when EverythingNode
601
585
  left
602
586
  when NothingNode
603
- left
587
+ right
604
588
  else
605
589
  if left == right
606
590
  left
@@ -643,14 +627,6 @@ module Hotdog
643
627
  {left: @left.dump(options), binary_op: @op.to_s, right: @right.dump(options)}
644
628
  end
645
629
 
646
- def intermediates()
647
- [self] + @left.intermediates + @right.intermediates
648
- end
649
-
650
- def leafs()
651
- @left.leafs + @right.leafs
652
- end
653
-
654
630
  private
655
631
  def optimize1(options)
656
632
  if TagExpressionNode === left and TagExpressionNode === right
@@ -744,14 +720,6 @@ module Hotdog
744
720
  def dump(options={})
745
721
  {multinary_op: @op.to_s, expressions: expressions.map { |expression| expression.dump(options) }}
746
722
  end
747
-
748
- def intermediates()
749
- [self] + @expression.flat_map { |expression| expression.intermediates }
750
- end
751
-
752
- def leafs()
753
- @expressions.flat_map { |expression| expression.leafs }
754
- end
755
723
  end
756
724
 
757
725
  class QueryExpressionNode < ExpressionNode
@@ -60,10 +60,10 @@ module Hotdog
60
60
  end
61
61
 
62
62
  result0 = evaluate(node, self)
63
- result, _fields = get_hosts_with_search_tags(result0, node)
64
- hosts = filter_hosts(result.flatten)
65
- validate_hosts!(hosts)
66
- run_main(hosts, options)
63
+ tuples, fields = get_hosts_with_search_tags(result0, node)
64
+ tuples = filter_hosts(tuples)
65
+ validate_hosts!(tuples, fields)
66
+ run_main(tuples.map {|tuple| tuple.first }, options)
67
67
  end
68
68
 
69
69
  private
@@ -71,29 +71,29 @@ module Hotdog
71
71
  options[:max_parallelism] || hosts.size
72
72
  end
73
73
 
74
- def filter_hosts(hosts)
74
+ def filter_hosts(tuples)
75
75
  if options[:filter_command]
76
- filtered_hosts = Parallel.map(hosts, in_threads: parallelism(hosts)) { |host|
77
- cmdline = build_command_string(host, options[:filter_command], options)
78
- [host, exec_command(host, cmdline, output: false)]
76
+ filtered_tuples = Parallel.map(tuples, in_threads: parallelism(tuples)) { |tuple|
77
+ cmdline = build_command_string(tuple.first, options[:filter_command], options)
78
+ [tuple, exec_command(tuple.first, cmdline, output: false)]
79
79
  }.select { |_host, stat|
80
80
  stat
81
- }.map { |host, _stat|
82
- host
81
+ }.map { |tuple, _stat|
82
+ tuple
83
83
  }
84
- if hosts == filtered_hosts
85
- hosts
84
+ if tuples == filtered_tuples
85
+ tuples
86
86
  else
87
- logger.info("filtered host(s): #{(hosts - filtered_hosts).inspect}")
88
- filtered_hosts
87
+ logger.info("filtered host(s): #{(tuples - filtered_tuples).map {|tuple| tuple.first }.inspect}")
88
+ filtered_tuples
89
89
  end
90
90
  else
91
- hosts
91
+ tuples
92
92
  end
93
93
  end
94
94
 
95
- def validate_hosts!(hosts)
96
- if hosts.length < 1
95
+ def validate_hosts!(tuples, fields)
96
+ if tuples.length < 1
97
97
  STDERR.puts("no match found")
98
98
  exit(1)
99
99
  end
@@ -196,21 +196,21 @@ module Hotdog
196
196
  end
197
197
 
198
198
  private
199
- def filter_hosts(hosts)
200
- hosts = super
201
- if options[:index] and options[:index] < hosts.length
202
- [hosts[options[:index]]]
199
+ def filter_hosts(tuples)
200
+ tuples = super
201
+ if options[:index] and options[:index] < tuples.length
202
+ [tuples[options[:index]]]
203
203
  else
204
- hosts
204
+ tuples
205
205
  end
206
206
  end
207
207
 
208
- def validate_hosts!(hosts)
208
+ def validate_hosts!(tuples, fields)
209
209
  super
210
- if hosts.length != 1
211
- result = hosts.each_with_index.map { |host, i| [i, host] }
212
- STDERR.print(format(result, fields: ["index", "host"]))
213
- logger.error("found %d candidates." % result.length)
210
+ if tuples.length != 1
211
+ result = tuples.each_with_index.map { |tuple, i| [i] + tuple }
212
+ STDERR.print(format(result, fields: ["index"] + fields))
213
+ logger.error("found %d candidates. use '-n INDEX' option to select one." % result.length)
214
214
  exit(1)
215
215
  end
216
216
  end
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.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.11.0
4
+ version: 0.12.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-07-29 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler