dorian-sort-json 0.5.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sort-json +27 -14
- 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: 38d2e31702100c63cfb56fd8074e16a70035391d591cfc45865b7c2f120ec0a2
|
4
|
+
data.tar.gz: e17b9bb93b7906a212f0834cb2262242ba10d4bca61fd3c052e40737677748c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6fc168c02e1961efd764fd5788839057650524ed196596904000e9c78bfdd3e62686e98136b5900f60f427e4650b867b5c19d615d0d1a20b88f7effd1d80684
|
7
|
+
data.tar.gz: '0418f36e2619992b282e485c741fba68df4f0bfec63fb8f580b5fa9d6b20737d0638dfbd5279b69b09b5534b339b9d9a7ba53b2e9650392cb0d31cc8e85e4be3'
|
data/bin/sort-json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require "dorian/arguments"
|
4
5
|
require "json"
|
5
6
|
|
6
7
|
def sort_json(data)
|
@@ -16,23 +17,35 @@ def sort_json(data)
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
parsed =
|
21
|
+
Dorian::Arguments.parse(
|
22
|
+
pretty: {
|
23
|
+
alias: :p,
|
24
|
+
default: true
|
25
|
+
},
|
26
|
+
version: {
|
27
|
+
alias: :v
|
28
|
+
},
|
29
|
+
help: {
|
30
|
+
alias: :h
|
31
|
+
}
|
32
|
+
)
|
26
33
|
|
27
|
-
if
|
28
|
-
inputs = $stdin.each_line.to_a
|
34
|
+
abort parsed.help if parsed.options.help
|
29
35
|
|
30
|
-
|
31
|
-
|
36
|
+
if parsed.options.version
|
37
|
+
abort File.read(File.expand_path("../../VERSION", __FILE__))
|
32
38
|
end
|
33
39
|
|
40
|
+
inputs = parsed.arguments + parsed.files.map { |file| File.read(file) }
|
41
|
+
inputs = [$stdin.each_line.to_a.map(&:strip).join("\n")] if inputs.empty?
|
42
|
+
|
34
43
|
inputs.each do |input|
|
35
|
-
|
36
|
-
|
37
|
-
|
44
|
+
output = sort_json(JSON.parse(input))
|
45
|
+
|
46
|
+
if parsed.options.pretty
|
47
|
+
puts JSON.pretty_generate(output)
|
48
|
+
else
|
49
|
+
puts output.to_json
|
50
|
+
end
|
38
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-sort-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dorian-arguments
|