hotdog 0.16.1 → 0.17.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/commands/search.rb +9 -1
- data/lib/hotdog/expression/semantics.rb +17 -5
- 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: a23883464db0f7638a741072ace4c6251c99ccca
|
4
|
+
data.tar.gz: d09ef94c849e83df926a0b494bd4da4c02925e53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccdef2dbf2a090258ae0c89d5a35ae18c45859a2842c2236989583a8cf9ffe9c6394f734fca5d5e510c67554267c09f97d1f395f65d645deab0c6ac442158728
|
7
|
+
data.tar.gz: 4ab9d3132fd5d7af46bcc57282f14fc76946a9c94acd077d40b1ee61045b528bde159aefb76f044bf574bfc6a4ec9fd9baea7a1dd53c3ebe010151828e230ab7
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "json"
|
4
4
|
require "parslet"
|
5
|
+
require "shellwords"
|
5
6
|
require "hotdog/expression"
|
6
7
|
|
7
8
|
module Hotdog
|
@@ -15,7 +16,14 @@ module Hotdog
|
|
15
16
|
|
16
17
|
def parse_options(optparse, args=[])
|
17
18
|
if args.index("--")
|
18
|
-
|
19
|
+
command_args = args.slice(args.index("--") + 1, args.length)
|
20
|
+
if command_args.length <= 1
|
21
|
+
# Use given argument as is if the remote command is specified as a quoted string
|
22
|
+
# e.g. 'for f in /tmp/foo*; do echo $f; done'
|
23
|
+
@remote_command = command_args.first
|
24
|
+
else
|
25
|
+
@remote_command = Shellwords.shelljoin(command_args)
|
26
|
+
end
|
19
27
|
optparse.parse(args.slice(0, args.index("--")))
|
20
28
|
else
|
21
29
|
@remote_command = nil
|
@@ -458,21 +458,33 @@ module Hotdog
|
|
458
458
|
args[0].evaluate(environment, options).take(args[1] || 1)
|
459
459
|
when :GROUP_BY
|
460
460
|
intermediate = args[0].evaluate(environment, options)
|
461
|
-
q = "SELECT hosts_tags.host_id FROM hosts_tags " \
|
461
|
+
q = "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags " \
|
462
462
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
463
463
|
"WHERE tags.name = ? AND hosts_tags.host_id IN (%s) " \
|
464
464
|
"GROUP BY tags.value;" % intermediate.map { "?" }.join(", ")
|
465
|
-
|
465
|
+
if TagExpressionNode === args[1]
|
466
|
+
# workaround for expressions like `ORDER_BY((environment:development),role)`
|
467
|
+
args1 = args[1].tag_name
|
468
|
+
else
|
469
|
+
args1 = args[1]
|
470
|
+
end
|
471
|
+
QueryExpressionNode.new(q, [args1] + intermediate, fallback: nil).evaluate(environment, options)
|
466
472
|
when :ORDER_BY
|
467
473
|
intermediate = args[0].evaluate(environment, options)
|
468
474
|
if args[1]
|
469
|
-
|
475
|
+
if TagExpressionNode === args[1]
|
476
|
+
# workaround for expressions like `ORDER_BY((environment:development),role)`
|
477
|
+
args1 = args[1].tag_name
|
478
|
+
else
|
479
|
+
args1 = args[1]
|
480
|
+
end
|
481
|
+
q = "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags " \
|
470
482
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
471
483
|
"WHERE tags.name = ? AND hosts_tags.host_id IN (%s) " \
|
472
484
|
"ORDER BY tags.value;" % intermediate.map { "?" }.join(", ")
|
473
|
-
QueryExpressionNode.new(q, [
|
485
|
+
QueryExpressionNode.new(q, [args1] + intermediate, fallback: nil).evaluate(environment, options)
|
474
486
|
else
|
475
|
-
q = "SELECT hosts_tags.host_id FROM hosts_tags " \
|
487
|
+
q = "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags " \
|
476
488
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
477
489
|
"WHERE hosts_tags.host_id IN (%s) " \
|
478
490
|
"ORDER BY hosts_tags.host_id;" % intermediate.map { "?" }.join(", ")
|
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.17.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-11-
|
11
|
+
date: 2016-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|