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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c762eea37cef48b1e77ad7ff752104eeb38082e3
4
- data.tar.gz: ec51f5cdc67ec3112188438e6f24d40e9bae4624
3
+ metadata.gz: a23883464db0f7638a741072ace4c6251c99ccca
4
+ data.tar.gz: d09ef94c849e83df926a0b494bd4da4c02925e53
5
5
  SHA512:
6
- metadata.gz: 5aae1f00e344f9328e033eef38e53dbcc5e3256ad4a594f3d15bf6674d6f52717f4361dc5e46c33693d7a4989044f2f66f16d139560203f18f150f1de5da4317
7
- data.tar.gz: fc94018049aa90686ab51c81b63d8d3caebe547f57744d7bf4d3b4172af402875820b0bb0403f1762ddbfb8617e4be57e6b0e1f04775785036edc7e95b9a065e
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
- @remote_command = args.slice(args.index("--") + 1, args.length).join(" ")
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
- QueryExpressionNode.new(q, [args[1]] + intermediate, fallback: nil).evaluate(environment, options)
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
- q = "SELECT hosts_tags.host_id FROM hosts_tags " \
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, [args[1]] + intermediate, fallback: nil).evaluate(environment, options)
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(", ")
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.16.1"
2
+ VERSION = "0.17.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.16.1
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-07 00:00:00.000000000 Z
11
+ date: 2016-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler