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 +4 -4
- data/.gemspec +1 -2
- data/.gitignore +1 -0
- data/CHANGELOG.md +14 -0
- data/README.md +10 -6
- data/data/sample.json +2 -2
- data/data/sample_complex.json +37 -0
- data/lib/json2csv/cli/cmd/convert_cmd.rb +3 -3
- data/lib/json2csv/{cli/convert → convert}/convert.rb +6 -8
- data/lib/json2csv/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fafc220de1efe1b009dbafad0dfb1fd51d90378b
|
4
|
+
data.tar.gz: 3ec4b13c80bf1157ff03856520509a3bd233730d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = '
|
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
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -4,7 +4,11 @@ Simple tool for converting JSON to CSV
|
|
4
4
|
|
5
5
|
## Status
|
6
6
|
|
7
|
+
[](http://badge.fury.io/rb/json2csv)
|
8
|
+
[](http://rubygems.org/gems/json2csv)
|
7
9
|
[](https://travis-ci.org/korczis/json2csv)
|
10
|
+
[](https://codeclimate.com/github/korczis/json2csv)
|
11
|
+
[](https://gemnasium.com/korczis/json2csv)
|
8
12
|
[](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
|
-
"
|
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
|
-
"
|
91
|
+
"Note": "Korean Deli near to main entrance"
|
88
92
|
}
|
89
93
|
}
|
90
94
|
}
|
91
95
|
}
|
92
96
|
```
|
93
97
|
|
94
|
-
**Convert
|
98
|
+
**Convert JSON**
|
95
99
|
|
96
100
|
```
|
97
|
-
|
101
|
+
json2csv convert data/sample.json
|
98
102
|
Converting data/sample.json
|
99
103
|
|
100
104
|
```
|
101
105
|
|
102
|
-
**Output
|
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.
|
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
|
|
data/data/sample.json
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
"Street": "#2140 Taylor Street, 94133",
|
7
7
|
"City": "San Francisco",
|
8
8
|
"Details": {
|
9
|
-
"
|
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
|
-
"
|
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 '
|
8
|
+
require_relative '../../convert/convert'
|
9
9
|
|
10
10
|
desc 'Convert json file'
|
11
11
|
command :convert do |c|
|
12
|
-
c.flag [:r, :root], :
|
13
|
-
c.flag [:d, :delimiter], :
|
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 '
|
8
|
+
require_relative '../version'
|
9
9
|
|
10
10
|
module Json2Csv
|
11
11
|
# Apollon bootstrap module
|
12
12
|
module Convert
|
13
13
|
DEFAULT_OPTIONS = {
|
14
|
-
:
|
15
|
-
:
|
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
|
27
|
-
json = json[opts[:root]]
|
28
|
-
end
|
26
|
+
json = json[opts[:root]] if opts[:root]
|
29
27
|
|
30
|
-
|
31
|
-
process(json, DEFAULT_OPTIONS.merge(opts).merge(
|
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
|
|
data/lib/json2csv/version.rb
CHANGED
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.
|
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-
|
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:
|
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
|