dorian-anonymize-json 0.2.0 → 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 +18 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cbc94530d9624b0091c24d1b59dd1764b37d194b35688f35ebff758cf3e3f87
4
- data.tar.gz: 2b9dba4f44ed5e8fa1a1c1166c309f05a0251cc74385a374bb72aa1c36a70eec
3
+ metadata.gz: 576644015b54dbfd4bc96de89357d92cfcabf889aefd2a23a7fde2525e0d93a6
4
+ data.tar.gz: cab3b5381f7c207cac6811d8eaf49a38fd4f0172ce5d1d577a217692066c4492
5
5
  SHA512:
6
- metadata.gz: 195a4459c140f3f1c15a891f52be4f854c7088870be1cdb82f1e1daf9562cd8b0c4eaec4cddfd772fccaf618c00ae4f0c09e1df6e0922077782b8f9d8a1df767
7
- data.tar.gz: 9b935e87961bf7c9695b8a404c2cd67799560bb838f3e1036396ad3d17c66735eaad4b0b84c0b311454dee1fd11f24e73f10c595ca692f94631de31f4a7bd300
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.0
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-07-05 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,10 +24,21 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: |-
28
- Anonymize JSON file
29
-
30
- e.g. `anonymize-json spec/**/*.json`
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'
41
+ description: anonymize json file
31
42
  email: dorian@dorianmarie.com
32
43
  executables:
33
44
  - anonymize-json
@@ -58,5 +69,5 @@ requirements: []
58
69
  rubygems_version: 3.5.11
59
70
  signing_key:
60
71
  specification_version: 4
61
- summary: Anonymize JSON file
72
+ summary: anonymize json file
62
73
  test_files: []