json2csv 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 249febdf6137898ce7a43bd9f12ba1d7fbffd5d5
4
- data.tar.gz: 8d606d373e79e91632d69236ba314481cf53347c
3
+ metadata.gz: fafc220de1efe1b009dbafad0dfb1fd51d90378b
4
+ data.tar.gz: 3ec4b13c80bf1157ff03856520509a3bd233730d
5
5
  SHA512:
6
- metadata.gz: d67e8524e08b0182186b8b351fbe56ae6cdb83f4cfe73db0f19f576f82b658e9ada51d351e7c52e1e82c69cb4add5aa42cbb0063976c06aaed17ff954c8c44ca
7
- data.tar.gz: 79499ae598cc5e21cca31a761171e13850f22faaf1203c510698f6847bb5f778258b63cd1f9d6fd5338889f428a29420a18b3609e82f9df2c980f861bd565423
6
+ metadata.gz: 49fbdd06e9b8ccb53eebaf53bd1343dd115d0b166f756b44df52fb89624ca3249e2ee89edf1fb23dd16b14ed00060dd0ae14f567d566cd516f5db6b6682283f3
7
+ data.tar.gz: ffa661d34acf6f647221b1e5a06ae3f7fb28fc5ca6a373c81e1da3f7d36107410114af71d5652fa9434984bc31061ebf460f7dc0cff3b0a9397af5dd3382e23d
data/.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.name = 'json2csv'
11
11
  s.version = Json2Csv::VERSION
12
12
  s.summary = 'Simple tool for converting json2csv'
13
- s.description = 'Quick and Dirty - No time to waste time'
13
+ s.description = 'JSON to CSV conversion tool with user friendly CLI'
14
14
  s.authors = [
15
15
  'Tomas Korcak'
16
16
  ]
@@ -31,7 +31,6 @@ Gem::Specification.new do |s|
31
31
 
32
32
  s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7.0r'
33
33
  s.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
34
- # s.add_development_dependency 'ruby-debug-ide' if RUBY_VERSION >= '2.1'
35
34
  s.add_development_dependency 'rubocop', '~> 0.24', '>= 0.24.0'
36
35
  s.add_development_dependency 'simplecov', '~> 0.8', '>= 0.8.2'
37
36
  end
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.box
2
2
  .idea/
3
+ *.json.csv
3
4
  .vagrant/
4
5
 
5
6
  Gemfile.lock
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 0.0.3
4
+
5
+ - Customizable delimiters
6
+ - Automagically processing nested structures
7
+
8
+ ## 0.0.2
9
+
10
+ - Fist working version with lot of hardcoded stuff
11
+
12
+ ## 0.0.1
13
+
14
+ - Initial revision
data/README.md CHANGED
@@ -4,7 +4,11 @@ Simple tool for converting JSON to CSV
4
4
 
5
5
  ## Status
6
6
 
7
+ [![Gem Version](https://badge.fury.io/rb/json2csv.svg)](http://badge.fury.io/rb/json2csv)
8
+ [![Downloads](http://img.shields.io/gem/dt/json2csv.svg)](http://rubygems.org/gems/json2csv)
7
9
  [![Build Status](https://travis-ci.org/korczis/json2csv.svg)](https://travis-ci.org/korczis/json2csv)
10
+ [![Code Climate](https://codeclimate.com/github/korczis/json2csv/badges/gpa.svg)](https://codeclimate.com/github/korczis/json2csv)
11
+ [![Dependency Status](https://gemnasium.com/korczis/json2csv.svg)](https://gemnasium.com/korczis/json2csv)
8
12
  [![Coverage Status](https://coveralls.io/repos/korczis/json2csv/badge.png)](https://coveralls.io/r/korczis/json2csv)
9
13
 
10
14
  ## Getting started
@@ -72,7 +76,7 @@ cat data/sample.json
72
76
  "Street": "#2140 Taylor Street, 94133",
73
77
  "City": "San Francisco",
74
78
  "Details": {
75
- "note": "Pool available"
79
+ "Note": "Pool available"
76
80
  }
77
81
  }
78
82
  },
@@ -84,27 +88,27 @@ cat data/sample.json
84
88
  "Street": "#111 Sutter St, 94104",
85
89
  "City": "San Francisco",
86
90
  "Details": {
87
- "note": "Korean Deli near to main entrance"
91
+ "Note": "Korean Deli near to main entrance"
88
92
  }
89
93
  }
90
94
  }
91
95
  }
92
96
  ```
93
97
 
94
- **Convert json**
98
+ **Convert JSON**
95
99
 
96
100
  ```
97
- ./bin/json2csv convert data/sample.json
101
+ json2csv convert data/sample.json
98
102
  Converting data/sample.json
99
103
 
100
104
  ```
101
105
 
102
- **Output json**
106
+ **Output CSV**
103
107
 
104
108
  ```
105
109
  cat data/sample.json.csv
106
110
 
107
- id,Firstname,Lastname,Address.Street,Address.City,Address.Details.note
111
+ id,Firstname,Lastname,Address.Street,Address.City,Address.Details.Note
108
112
  12345,Joe,Doe,"#2140 Taylor Street, 94133",San Francisco,Pool available
109
113
  45678,Jack,Plumber,"#111 Sutter St, 94104",San Francisco,Korean Deli near to main entrance
110
114
 
@@ -6,7 +6,7 @@
6
6
  "Street": "#2140 Taylor Street, 94133",
7
7
  "City": "San Francisco",
8
8
  "Details": {
9
- "note": "Pool available"
9
+ "Note": "Pool available"
10
10
  }
11
11
  }
12
12
  },
@@ -18,7 +18,7 @@
18
18
  "Street": "#111 Sutter St, 94104",
19
19
  "City": "San Francisco",
20
20
  "Details": {
21
- "note": "Korean Deli near to main entrance"
21
+ "Note": "Korean Deli near to main entrance"
22
22
  }
23
23
  }
24
24
  }
@@ -0,0 +1,37 @@
1
+ {
2
+ "Addresses": {
3
+ "12345": {
4
+ "Firstname": "Joe",
5
+ "Lastname": "Doe",
6
+ "Address": {
7
+ "Street": "#2140 Taylor Street, 94133",
8
+ "City": "San Francisco",
9
+ "Details": {
10
+ "note": "Pool available"
11
+ }
12
+ }
13
+ },
14
+
15
+ "45678": {
16
+ "Firstname": "Jack",
17
+ "Lastname": "Plumber",
18
+ "Address": {
19
+ "Street": "#111 Sutter St, 94104",
20
+ "City": "San Francisco",
21
+ "Details": {
22
+ "note": "Korean Deli near to main entrance"
23
+ }
24
+ }
25
+ }
26
+ },
27
+
28
+ "Items": {
29
+ "ABC": {
30
+ "Name": "Apple"
31
+ },
32
+
33
+ "DEF": {
34
+ "Name": "Banana"
35
+ }
36
+ }
37
+ }
@@ -5,12 +5,12 @@ require 'gli'
5
5
  include GLI::App
6
6
 
7
7
  require_relative '../shared'
8
- require_relative '../convert/convert'
8
+ require_relative '../../convert/convert'
9
9
 
10
10
  desc 'Convert json file'
11
11
  command :convert do |c|
12
- c.flag [:r, :root], :type => String
13
- c.flag [:d, :delimiter], :type => String, :default_value => ','
12
+ c.flag [:r, :root], type: String
13
+ c.flag [:d, :delimiter], type: String, default_value: ','
14
14
 
15
15
  c.action do |global_options, options, args|
16
16
  fail ArgumentError, 'No file to convert specified' if args.empty?
@@ -5,14 +5,14 @@ require 'multi_json'
5
5
  require 'pathname'
6
6
  require 'pp'
7
7
 
8
- require_relative '../../version'
8
+ require_relative '../version'
9
9
 
10
10
  module Json2Csv
11
11
  # Apollon bootstrap module
12
12
  module Convert
13
13
  DEFAULT_OPTIONS = {
14
- :out_path => 'out.txt',
15
- :delimiter => ','
14
+ out_path: 'out.txt',
15
+ delimiter: ','
16
16
  }
17
17
 
18
18
  class << self
@@ -23,12 +23,10 @@ module Json2Csv
23
23
 
24
24
  json = load_file(path)
25
25
 
26
- if(opts[:root])
27
- json = json[opts[:root]]
28
- end
26
+ json = json[opts[:root]] if opts[:root]
29
27
 
30
- real_opts =
31
- process(json, DEFAULT_OPTIONS.merge(opts).merge(:out_path => "#{path}.csv"))
28
+ tmp_opts = { out_path: "#{path}.csv" }
29
+ process(json, DEFAULT_OPTIONS.merge(opts).merge(tmp_opts))
32
30
  end
33
31
  end
34
32
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Apollon module
4
4
  module Json2Csv
5
- VERSION = '0.0.3'
5
+ VERSION = '0.0.4'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json2csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Korcak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-29 00:00:00.000000000 Z
11
+ date: 2014-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -178,7 +178,7 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: 0.8.2
181
- description: Quick and Dirty - No time to waste time
181
+ description: JSON to CSV conversion tool with user friendly CLI
182
182
  email: korczis@gmail.com
183
183
  executables:
184
184
  - json2csv
@@ -188,19 +188,21 @@ files:
188
188
  - ".gemspec"
189
189
  - ".gitignore"
190
190
  - ".travis.yml"
191
+ - CHANGELOG.md
191
192
  - Gemfile
192
193
  - LICENSE
193
194
  - README.md
194
195
  - Rakefile
195
196
  - bin/json2csv
196
197
  - data/sample.json
198
+ - data/sample_complex.json
197
199
  - lib/json2csv.rb
198
200
  - lib/json2csv/cli/app.rb
199
201
  - lib/json2csv/cli/cli.rb
200
202
  - lib/json2csv/cli/cmd/convert_cmd.rb
201
203
  - lib/json2csv/cli/cmd/version_cmd.rb
202
- - lib/json2csv/cli/convert/convert.rb
203
204
  - lib/json2csv/cli/shared.rb
205
+ - lib/json2csv/convert/convert.rb
204
206
  - lib/json2csv/lib.rb
205
207
  - lib/json2csv/version.rb
206
208
  - spec/spec_helper.rb