hotdog 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hotdog/commands/search.rb +1 -1
- data/lib/hotdog/commands.rb +11 -2
- data/lib/hotdog/formatters/csv.rb +1 -1
- data/lib/hotdog/formatters/json.rb +2 -2
- data/lib/hotdog/formatters/ltsv.rb +6 -3
- data/lib/hotdog/formatters/plain.rb +3 -2
- data/lib/hotdog/formatters/tsv.rb +2 -2
- data/lib/hotdog/formatters/yaml.rb +1 -1
- data/lib/hotdog/formatters.rb +9 -0
- data/lib/hotdog/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 994ffc110fca456fa2aafe2c680b5336fb469989
|
4
|
+
data.tar.gz: 2a68fa27a1dab929c0b9ff5e63d031bd7747dbef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5afa560d648757a26676dadce8fb39aac67e43ae92aa707467b1bb681e1465b1303a7937a86ba8e9f64e1a5b07a6570715704aab9dfd8db02f25b064c47093ad
|
7
|
+
data.tar.gz: 1f747ae6f4e3cd107484c09372051e2dcc60e837c9c5faa00479acef6895a4cca791730d0349e4341f915469753e217f8dffa5a213ad229a8e3db99da72dda2e
|
@@ -1113,7 +1113,7 @@ module Hotdog
|
|
1113
1113
|
end
|
1114
1114
|
|
1115
1115
|
def maybe_fallback(options={})
|
1116
|
-
fallback = GlobNode.new(maybe_glob(identifier), separator)
|
1116
|
+
fallback = GlobNode.new(maybe_glob(identifier), separator)
|
1117
1117
|
if query = fallback.maybe_query(options)
|
1118
1118
|
QueryExpressionNode.new(query, fallback.condition_values(options))
|
1119
1119
|
else
|
data/lib/hotdog/commands.rb
CHANGED
@@ -146,9 +146,18 @@ module Hotdog
|
|
146
146
|
]
|
147
147
|
fields.map { |tag_name|
|
148
148
|
if tag_name == "host"
|
149
|
-
host_names.fetch(host_id,
|
149
|
+
host_names.fetch(host_id, nil)
|
150
150
|
else
|
151
|
-
tag_values.fetch(tag_name,
|
151
|
+
tag_value = tag_values.fetch(tag_name, nil)
|
152
|
+
if tag_value
|
153
|
+
if tag_value.empty?
|
154
|
+
tag_name # use `tag_name` as `tag_value` for the tags without any values
|
155
|
+
else
|
156
|
+
tag_value
|
157
|
+
end
|
158
|
+
else
|
159
|
+
nil
|
160
|
+
end
|
152
161
|
end
|
153
162
|
}
|
154
163
|
}
|
@@ -6,11 +6,11 @@ module Hotdog
|
|
6
6
|
module Formatters
|
7
7
|
class Json < BaseFormatter
|
8
8
|
def format(result, options={})
|
9
|
-
result = result
|
9
|
+
result = prepare(result)
|
10
10
|
if options[:headers] and options[:fields]
|
11
11
|
result.unshift(options[:fields])
|
12
12
|
end
|
13
|
-
JSON.pretty_generate(result) +
|
13
|
+
JSON.pretty_generate(result) + newline
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -4,14 +4,17 @@ module Hotdog
|
|
4
4
|
module Formatters
|
5
5
|
class Ltsv < BaseFormatter
|
6
6
|
def format(result, options={})
|
7
|
+
result = prepare(result)
|
7
8
|
if options[:fields]
|
8
9
|
result.map { |row|
|
9
|
-
options[:fields].zip(row).map { |
|
10
|
-
|
10
|
+
options[:fields].zip(row).map { |(field, column)|
|
11
|
+
"#{field}:#{column}"
|
12
|
+
}.join("\t")
|
13
|
+
}.join(newline) + newline
|
11
14
|
else
|
12
15
|
result.map { |row|
|
13
16
|
row.join("\t")
|
14
|
-
}.join(
|
17
|
+
}.join(newline) + newline
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -7,10 +7,11 @@ module Hotdog
|
|
7
7
|
if options[:print0]
|
8
8
|
sep = "\0"
|
9
9
|
elsif options[:print1]
|
10
|
-
sep =
|
10
|
+
sep = newline
|
11
11
|
else
|
12
12
|
sep = " "
|
13
13
|
end
|
14
|
+
result = prepare(result)
|
14
15
|
if options[:print1] and options[:headers] and options[:fields]
|
15
16
|
field_length = (0...result.last.length).map { |field_index|
|
16
17
|
result.reduce(0) { |length, row|
|
@@ -36,7 +37,7 @@ module Hotdog
|
|
36
37
|
if s.empty? or options[:print0]
|
37
38
|
s
|
38
39
|
else
|
39
|
-
s +
|
40
|
+
s + newline
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -4,13 +4,13 @@ module Hotdog
|
|
4
4
|
module Formatters
|
5
5
|
class Tsv < BaseFormatter
|
6
6
|
def format(result, options={})
|
7
|
-
result = result
|
7
|
+
result = prepare(result)
|
8
8
|
if options[:headers] and options[:fields]
|
9
9
|
result.unshift(options[:fields])
|
10
10
|
end
|
11
11
|
result.map { |row|
|
12
12
|
row.join("\t")
|
13
|
-
}.join(
|
13
|
+
}.join(newline) + newline
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/hotdog/formatters.rb
CHANGED
data/lib/hotdog/version.rb
CHANGED