dorian-json-uniq 0.0.3 → 1.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/json-uniq +34 -6
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3033cd4be67a923df782720e82d70015a911b7da1951e2684422308f46d2d70
4
- data.tar.gz: 7fa5c784d56c478e3889cb4aef1a62dfa9c12e2c5b6525b1348ac89abeb5f355
3
+ metadata.gz: a75f3539c3c66f47f359dccc487552b0b5e47d313534e7bf464d1ead44622fea
4
+ data.tar.gz: 3f3fcebdc98581a3e1c5a7e97a55290e520dcce88ae6696a90ca4b525c4c03f1
5
5
  SHA512:
6
- metadata.gz: b31da611b0fc99e2fe3fa6393c73dce402e2555b3aa0e1e56238736789b2a915c30426492dfb8a72362c359bcde0a3f461cbaec59243fb8098bbab31dfba929e
7
- data.tar.gz: 1128cf94daa682d0207bae924ebeb073fe17e46c7460b5962d1fe810f26495be4a42a452fa6c3d945d863c2e29781960704f92b2d6a5f4ff9f7240f31136e0cb
6
+ metadata.gz: 19cb214a7d4efb1131363d556803060ca1ddd24462d6645941d677e28b51a8ee13c788efbff1f0738d1c8d9b7cb14f730fcb87d29e2c0b210a9f652814d260f5
7
+ data.tar.gz: 25d59d06a13908edfa2448d1f646a1a89274eeabf6c2ae448c904bc0ba3c93d8c63f9dce6afb06aa9f975feffb2461e954f9feab4d2bf770e479708b23daae6d
data/bin/json-uniq CHANGED
@@ -1,12 +1,40 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- if ARGV.size != 1 || ARGV[0] == "--help" || ARGV[0] == "-h"
5
- puts "USAGE: ... | each CODE"
6
- exit
4
+ require "dorian/arguments"
5
+ require "json"
6
+
7
+ parsed =
8
+ Dorian::Arguments.parse(
9
+ pretty: {
10
+ alias: :p,
11
+ default: true
12
+ },
13
+ version: {
14
+ alias: :v
15
+ },
16
+ help: {
17
+ alias: :h
18
+ }
19
+ )
20
+
21
+ abort parsed.help if parsed.options.help
22
+
23
+ if parsed.options.version
24
+ abort File.read(File.expand_path("../VERSION", __dir__))
7
25
  end
8
26
 
9
- $stdin.each_line do |it|
10
- it.strip!
11
- eval(ARGV.first)
27
+ inputs = parsed.files.map { |file| File.read(file) }
28
+ inputs += parsed.arguments
29
+ inputs = [$stdin.each_line.to_a.map(&:strip).join("\n")] if inputs.empty?
30
+
31
+ inputs.each do |input|
32
+ json = JSON.parse(input)
33
+ json.uniq! if json.is_a?(Array)
34
+
35
+ if parsed.options.pretty
36
+ puts JSON.pretty_generate(json)
37
+ else
38
+ puts json.to_json
39
+ end
12
40
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-json-uniq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.1.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-22 00:00:00.000000000 Z
11
+ date: 2024-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: json
14
+ name: dorian-arguments
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dorian-arguments
28
+ name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -57,9 +57,9 @@ require_paths:
57
57
  - lib
58
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: 3.3.4
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="