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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed37b92279060591308aba623808d5ea5e3dbe5f536bd2558dc4a64d0929488f
4
- data.tar.gz: 73b6ae66721753de030a17fa035773d227ec25d27c02fba45ac550e322853f59
3
+ metadata.gz: a3578ea2fd961227a7eaf9585993a7f1abe70893b3e76ae081a3f1c79c9e6517
4
+ data.tar.gz: c2820a193eecc3e114a01c5286cd85f71dcfa162338ad5146745aa5da86d3f04
5
5
  SHA512:
6
- metadata.gz: 36d90336bc7a83a91376d1710add6cddbf5c8969612d933493c49e969da7df696c22b5258283aa53f06f1a543cc64a6bbec7452a6ad089d38b137a9eb104d572
7
- data.tar.gz: ca3aecae2d366a4c05f2deca19873562b94c28f945fdd9ac7a8085754a4d58fbb1a89d153bf409181b24dbc34394a15086c748fed850fbac885bd20338eb7a26
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 = @rows.map do |row|
7
- item = {}
8
- @header.each_with_index do |header, i|
9
- item[header] = row[i]
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
- item
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
@@ -1,3 +1,3 @@
1
1
  module CliFormat
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
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.0
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-15 00:00:00.000000000 Z
11
+ date: 2024-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport