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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 620323cd9db295c0d65d974f1161550aa8f3f5e0
4
- data.tar.gz: 6ea419f4716a1b4672d4576e25185eeb54586f05
3
+ metadata.gz: 994ffc110fca456fa2aafe2c680b5336fb469989
4
+ data.tar.gz: 2a68fa27a1dab929c0b9ff5e63d031bd7747dbef
5
5
  SHA512:
6
- metadata.gz: b3d6b14d0ba95834736734681fcdc40df1b5579b05818fd6324eacb2c8655771d6a5516a71e317f56fca6aa83b2920be0e1ad082308506a0515a98b274b8d32e
7
- data.tar.gz: b2e2a01aa4dbdaf7095504c1ce3be093d8d1ef4ea70629f1118b301464040058ac51d74d5e7a201b91719d560b6fdf536f652fdf7fd8ffb809896679d17acd4f
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).maybe_query(options)
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
@@ -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,7 +6,7 @@ module Hotdog
6
6
  module Formatters
7
7
  class Csv < BaseFormatter
8
8
  def format(result, options={})
9
- result = result.dup
9
+ result = prepare(result)
10
10
  if options[:headers] and options[:fields]
11
11
  result.unshift(options[:fields])
12
12
  end
@@ -6,11 +6,11 @@ module Hotdog
6
6
  module Formatters
7
7
  class Json < BaseFormatter
8
8
  def format(result, options={})
9
- result = result.dup
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) + "\n"
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 { |column| column.join(":") }.join("\t")
10
- }.join("\n") + "\n"
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("\n") + "\n"
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 = "\n"
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 + "\n"
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.dup
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("\n") + "\n"
13
+ }.join(newline) + newline
14
14
  end
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ module Hotdog
6
6
  module Formatters
7
7
  class Yaml < BaseFormatter
8
8
  def format(result, options={})
9
- result = result.dup
9
+ result = prepare(result)
10
10
  if options[:headers] and options[:fields]
11
11
  result.unshift(options[:fields])
12
12
  end
@@ -6,6 +6,15 @@ module Hotdog
6
6
  def format(result, options={})
7
7
  raise(NotImplementedError)
8
8
  end
9
+
10
+ private
11
+ def prepare(result)
12
+ result.map { |row| row.map { |column| column or "<nil>" } }
13
+ end
14
+
15
+ def newline()
16
+ "\n"
17
+ end
9
18
  end
10
19
  end
11
20
  end
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu