cli-format 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: d8aac542c4c1f36ffb6df02868633539c1a3f3fc7f5bf5c1d42cd22eb8925a20
4
- data.tar.gz: bf568ed13e7f0e3e6ffdf6331f6983236ec1fe1a8cb963a3fef4b65a1a16b6a6
3
+ metadata.gz: 7787622c725718db9f2da155ca771914a479461de6c951a8bc98472e11f87720
4
+ data.tar.gz: fe8d99d2638510e4f86e0203c38aa641f5793aecfbb40c6a46fe41ff9ed95ba9
5
5
  SHA512:
6
- metadata.gz: 25570ef38bfef3dc4ae4d91cb14b79173c37e8da0b444a69b3c1ebc36d2ef2285e976c7e96faddac074474fef84633f8c6953d427384087bbcac84807e217a67
7
- data.tar.gz: e0623dd69a6f1bf1c7a988ed4d5cff25cecdbf83c5dfece00ee0680659443205d34805eef6236432c129ea69668538083d135ae5c6b1667229f2901b8f6e0608
6
+ metadata.gz: 5de20b08ef2460450a2fa788d0b1c4610b414224b09e9554a252f48feea03f4fa1ca6969c688c5543c11672c14e82c44e4e84842e14be21624205f001962d2de
7
+ data.tar.gz: 91fdca86887bf627851cb6a5bf42ed6adbf615885a5f32713203a458d51c1bb4a0983a7a2deb79b1a4c1f4344ce84e9ce82460c95810d4d07d2906be0dee23e0
@@ -0,0 +1,10 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project *loosely* adheres to [Semantic Versioning](http://semver.org/), even before v1.0.
5
+
6
+ ## [0.2.0]
7
+ - #1 improve json format output - better usage with jq
8
+
9
+ ## [0.1.0]
10
+ - Initial release.
data/README.md CHANGED
@@ -71,6 +71,14 @@ Format json shows:
71
71
  }
72
72
  ```
73
73
 
74
+ ## Thor CLI Options
75
+
76
+ To expose the format in Thor CLI options, you can use `CliFormat.formats`. Example:
77
+
78
+ ```ruby
79
+ option :format, desc: "Output formats: #{CliFormat.formats.join(', ')}"
80
+ ```
81
+
74
82
  ## Text
75
83
 
76
84
  If you would like to grab just the text and not it shown, use the `text` method.
@@ -3,10 +3,13 @@ require "json"
3
3
  class CliFormat::Presenter
4
4
  class Json < Base
5
5
  def text
6
- json_data = {
7
- header: @header,
8
- data: @rows
9
- }
6
+ json_data = @rows.map do |row|
7
+ item = {}
8
+ @header.each_with_index do |header, i|
9
+ item[header] = row[i]
10
+ end
11
+ item
12
+ end
10
13
  JSON.pretty_generate(json_data)
11
14
  end
12
15
  end
@@ -1,3 +1,3 @@
1
1
  module CliFormat
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -104,6 +104,7 @@ files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
106
  - ".travis.yml"
107
+ - CHANGELOG.md
107
108
  - Gemfile
108
109
  - Gemfile.lock
109
110
  - LICENSE.txt