dorian-sort-json 0.4.0 → 0.4.1
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 +2 -1
- data/lib/dorian/sort-json.rb +11 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf9b0042976b5aae24287008ac779c91e1f7cc07e552b0c88a84057277302923
|
4
|
+
data.tar.gz: 9b19afe31fdadbf4577002fb7520e22be5216950633df8ca7c97ec4672bbb220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49443a56012530f9a6ecaaca2ca7b6774b6282581ab4a76f860ba70f1e614488f213205022d394fbe985fca29e403a63dd1712402d3909c5adfb8e8f5fb48a65
|
7
|
+
data.tar.gz: 147f9d9f546088085336faf909e3ad713c7040727d6e34e67b054e9deb7b20dbae30baa6f1c1ed436262ad08a05a14036d528e3c99b941c1e639603be2966fa1
|
data/bin/sort-json
CHANGED
data/lib/dorian/sort-json.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "json"
|
2
4
|
|
3
5
|
module Dorian
|
@@ -11,19 +13,20 @@ module Dorian
|
|
11
13
|
|
12
14
|
inputs = ARGV
|
13
15
|
|
14
|
-
if inputs.
|
15
|
-
inputs =
|
16
|
+
if inputs.empty?
|
17
|
+
inputs = $stdin.each_line.to_a
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
inputs =
|
20
|
+
if File.exist?(inputs.first.strip)
|
21
|
+
inputs.map(&:strip)
|
22
|
+
else
|
23
|
+
[inputs.join]
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
27
|
inputs.each do |input|
|
25
28
|
content = File.exist?(input) ? File.read(input) : input
|
26
|
-
json = JSON.pretty_generate(sort_json(JSON.parse(content)))
|
29
|
+
json = "#{JSON.pretty_generate(sort_json(JSON.parse(content)))}\n"
|
27
30
|
File.exist?(input) ? File.write(input, json) : puts(json)
|
28
31
|
end
|
29
32
|
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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Sorts keys of hashes of JSON files
|
@@ -22,7 +22,7 @@ extra_rdoc_files: []
|
|
22
22
|
files:
|
23
23
|
- bin/sort-json
|
24
24
|
- lib/dorian/sort-json.rb
|
25
|
-
homepage: https://github.com/
|
25
|
+
homepage: https://github.com/dorianmariecom/sort-json
|
26
26
|
licenses:
|
27
27
|
- MIT
|
28
28
|
metadata:
|
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
45
|
+
rubygems_version: 3.5.3
|
46
46
|
signing_key:
|
47
47
|
specification_version: 4
|
48
48
|
summary: Sorts keys of hashes of JSON files
|