dorian-anonymize-json 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/anonymize-json +9 -14
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a41e212b9a574fbec638caaf9284b6b515531783a2456ea3a750dc919b609bf
4
- data.tar.gz: e637b61d363632ff5c8522142c75337b90dedd8d37063c6f72e392c08051b848
3
+ metadata.gz: 576644015b54dbfd4bc96de89357d92cfcabf889aefd2a23a7fde2525e0d93a6
4
+ data.tar.gz: cab3b5381f7c207cac6811d8eaf49a38fd4f0172ce5d1d577a217692066c4492
5
5
  SHA512:
6
- metadata.gz: c0f7bea86a0976d03e53dde2c75f6a08206ca801d4b3b759c6a38d9cd16cdcbd8efb0fad2826832056816e5e62dfc84c622aefafe09c7fd3cf8354fcdc2ae826
7
- data.tar.gz: 9758c797ab0e80059ea76ee73e02f989ef9032847a98ee56067fe51d5f452b2576ba317a388e45b62f67e44812c597df29e697dcd966102645715d96e745f9ad
6
+ metadata.gz: 6a6b597c6fdc1023c10ba2f1ca687c8f2b15051f586a978655d17d97943eb419ea776e3b77ff094660d1c930c1b968fdecbbbd9b1451bc367179b9e84d664d7c
7
+ data.tar.gz: e75c347c6c89a9275f9691dc41abbc3373816c6b172e981f9ffa314c596e774468a7d315588c105eeffa3d01f572410c0f9190135f253986094cfc278ce82379
data/bin/anonymize-json CHANGED
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "json"
5
+ require "dorian/arguments"
5
6
 
6
7
  def anonymize_json(data)
7
8
  case data
@@ -22,23 +23,17 @@ def anonymize_json(data)
22
23
  end
23
24
  end
24
25
 
25
- if ARGV[0] == "--help" || ARGV[0] == "-h"
26
- puts "USAGE: anonymize-yaml FILES..."
27
- puts "USAGE: ... | anonymize-yaml"
28
- exit
29
- end
30
-
31
- inputs = ARGV
26
+ parsed = Dorian::Arguments.parse(version: { alias: :v }, help: { alias: :h })
32
27
 
33
- if inputs.empty?
34
- inputs = $stdin.each_line.to_a
28
+ abort parsed.help if parsed.options.help
35
29
 
36
- inputs =
37
- (File.exist?(inputs.first.strip) ? inputs.map(&:strip) : [inputs.join])
30
+ if parsed.options.version
31
+ abort File.read(File.expand_path("../../VERSION", __FILE__))
38
32
  end
39
33
 
34
+ inputs = parsed.arguments + parsed.files.map { |file| File.read(file) }
35
+ inputs = [$stdin.each_line.to_a.map(&:strip).join] if inputs.empty?
36
+
40
37
  inputs.each do |input|
41
- content = File.exist?(input) ? File.read(input) : input
42
- json = JSON.pretty_generate(anonymize_json(JSON.parse(content)))
43
- File.exist?(input) ? File.write(input, json) : puts(json)
38
+ puts(JSON.pretty_generate(anonymize_json(JSON.parse(input))))
44
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-anonymize-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
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-18 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dorian-arguments
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: anonymize json file
28
42
  email: dorian@dorianmarie.com
29
43
  executables: