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 +4 -4
- data/lib/hotdog/application.rb +5 -0
- data/lib/hotdog/commands/search.rb +1 -33
- data/lib/hotdog/commands/ssh.rb +27 -27
- data/lib/hotdog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81c8f88ce41f3d20b7099237e335f0baa453ad3a
|
4
|
+
data.tar.gz: 3aa663a263433092de26f1d5ec33cffb871e1b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04dfbc1dc88f135b680ee989ac02b708d2adf86a7cab3e315f3c0875eb5071b618ed97064ebefdc48d0b1bf991ee4f6c5bd9d623c7af13f0e5b555e40ecdea2e
|
7
|
+
data.tar.gz: 74a9fc5f60194286c07926a199f5e6a51064b62cce8057159d84195352686fbaa3dacdc42ed5e7a6f5d09508dbd4cb824ee741df34ed02be6afd2486dfa7a26a
|
data/lib/hotdog/application.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/hotdog/commands/ssh.rb
CHANGED
@@ -60,10 +60,10 @@ module Hotdog
|
|
60
60
|
end
|
61
61
|
|
62
62
|
result0 = evaluate(node, self)
|
63
|
-
|
64
|
-
|
65
|
-
validate_hosts!(
|
66
|
-
run_main(
|
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(
|
74
|
+
def filter_hosts(tuples)
|
75
75
|
if options[:filter_command]
|
76
|
-
|
77
|
-
cmdline = build_command_string(
|
78
|
-
[
|
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 { |
|
82
|
-
|
81
|
+
}.map { |tuple, _stat|
|
82
|
+
tuple
|
83
83
|
}
|
84
|
-
if
|
85
|
-
|
84
|
+
if tuples == filtered_tuples
|
85
|
+
tuples
|
86
86
|
else
|
87
|
-
logger.info("filtered host(s): #{(
|
88
|
-
|
87
|
+
logger.info("filtered host(s): #{(tuples - filtered_tuples).map {|tuple| tuple.first }.inspect}")
|
88
|
+
filtered_tuples
|
89
89
|
end
|
90
90
|
else
|
91
|
-
|
91
|
+
tuples
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
def validate_hosts!(
|
96
|
-
if
|
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(
|
200
|
-
|
201
|
-
if options[:index] and options[:index] <
|
202
|
-
[
|
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
|
-
|
204
|
+
tuples
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
-
def validate_hosts!(
|
208
|
+
def validate_hosts!(tuples, fields)
|
209
209
|
super
|
210
|
-
if
|
211
|
-
result =
|
212
|
-
STDERR.print(format(result, fields: ["index"
|
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
|
data/lib/hotdog/version.rb
CHANGED
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.
|
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
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|