dorian-sort-json 0.1.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dorian/sort-json.rb +20 -9
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 044bd64a6db1e47c642b1495bd3f03e0217555a37a9fc1a186a8e5001b252f4a
|
4
|
+
data.tar.gz: ada1eadd785f91c4469f034c15b3143bb44677aa36dce794501ce1d2427f1678
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9efa6990cc8b57177e8d40a965461131e101095612a3dfe41ff77363d04e432e4c587f96372850534841d0ee4349518fdac6118072692eab9a07df94007abe50
|
7
|
+
data.tar.gz: 6ea7b8307b8997cd0251b82111979b2b8b47909d884e4ac2d68763e992a9e9564a239d61c3392fe1f79985491df1b550158a109ce70d73ab84f2449f5fbd447b
|
data/lib/dorian/sort-json.rb
CHANGED
@@ -1,19 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require "json"
|
2
2
|
|
3
3
|
module Dorian
|
4
4
|
class SortJson
|
5
5
|
def self.run
|
6
|
-
if ARGV
|
7
|
-
puts
|
6
|
+
if ARGV[0] == "--help" || ARGV[0] == "-h"
|
7
|
+
puts "USAGE: sort-json FILES..."
|
8
|
+
puts "USAGE: ... | sort-json"
|
8
9
|
exit
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
)
|
12
|
+
inputs = ARGV
|
13
|
+
|
14
|
+
if inputs.size.zero?
|
15
|
+
inputs = STDIN.each_line.to_a
|
16
|
+
|
17
|
+
if File.exist?(inputs.first.strip)
|
18
|
+
inputs = inputs.map(&:strip)
|
19
|
+
else
|
20
|
+
inputs = [inputs.join]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
inputs.each do |input|
|
25
|
+
content = File.exist?(input) ? File.read(input) : input
|
26
|
+
json = JSON.pretty_generate(sort_json(JSON.parse(content))) + "\n"
|
27
|
+
File.exist?(input) ? File.write(input, json) : puts(json)
|
17
28
|
end
|
18
29
|
end
|
19
30
|
|
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: 0.4.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: 2021-
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Sorts keys of hashes of JSON files
|
@@ -25,7 +25,8 @@ files:
|
|
25
25
|
homepage: https://github.com/dorianmariefr/sort-json
|
26
26
|
licenses:
|
27
27
|
- MIT
|
28
|
-
metadata:
|
28
|
+
metadata:
|
29
|
+
rubygems_mfa_required: 'true'
|
29
30
|
post_install_message:
|
30
31
|
rdoc_options: []
|
31
32
|
require_paths:
|