cli-format 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/cli_format/presenter/json.rb +14 -5
- data/lib/cli_format/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3578ea2fd961227a7eaf9585993a7f1abe70893b3e76ae081a3f1c79c9e6517
|
4
|
+
data.tar.gz: c2820a193eecc3e114a01c5286cd85f71dcfa162338ad5146745aa5da86d3f04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1187e637dc016d84f603e80091d55f93a0c7cf0f687aea430e51acc3f56df2b696a8f567a94fe25559fb863e450fc8182f0999dfa517e2d6adf64ac1107b703
|
7
|
+
data.tar.gz: 60adf6e26342f5f5823353cc5b0f30041995beefad42c9d681067fccb487eb6d27c7372b8f87f8eee5368b32375237e311a3133fcc432e97ccf3e13b7db65859
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely* adheres to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.6.1] - 2024-04-27
|
7
|
+
- [#6](https://github.com/boltops-tools/cli-format/pull/6) improve json format with no header, simple hash
|
8
|
+
|
6
9
|
## [0.6.0] - 2024-04-15
|
7
10
|
- [#5](https://github.com/boltops-tools/cli-format/pull/5) More formats
|
8
11
|
- dotenv format
|
@@ -3,13 +3,22 @@ require "json"
|
|
3
3
|
class CliFormat::Presenter
|
4
4
|
class Json < Base
|
5
5
|
def text
|
6
|
-
json_data = @
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
json_data = if @header
|
7
|
+
@rows.map do |row|
|
8
|
+
item = {}
|
9
|
+
@header.each_with_index do |header, i|
|
10
|
+
item[header] = row[i]
|
11
|
+
end
|
12
|
+
item
|
10
13
|
end
|
11
|
-
|
14
|
+
elsif @rows.first.size == 2
|
15
|
+
@rows.each_with_object({}) { |(k, v), h|
|
16
|
+
h[k] = v
|
17
|
+
}
|
18
|
+
else # 1 row
|
19
|
+
@rows
|
12
20
|
end
|
21
|
+
|
13
22
|
JSON.pretty_generate(json_data)
|
14
23
|
end
|
15
24
|
end
|
data/lib/cli_format/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|