dorian-anonymize-yaml 0.2.2 → 1.0.0

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-yaml +9 -16
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4377ecb7776a4a3066f68ccfbd3f4ed116844f2d40ac873d21343edfeacd2d54
4
- data.tar.gz: a8d00e1e4d18d1dfa9ab16257654fdba65c972ba7c9959f93d93c569ecc6b215
3
+ metadata.gz: 4db5df8ba7510e6f188c108dd7481bd90f1024a221628b95db9d305f82cc1590
4
+ data.tar.gz: be3ef4a1b9e02a2ff67fbca7561310775851bf00c0e9e20ee8c3db80bcd64de6
5
5
  SHA512:
6
- metadata.gz: 7df4cc43e24901283516d5298aa7fece2a3abdd61b111b55f7418348b4c775a4d8704b290617cb20ef69c81487c98a5ac6ca589d698c54061018d524ebc8bcda
7
- data.tar.gz: 64ac555dea1272b5d15444b1881634aae2a7623d98f5520c86f560eb03097e8e2b72a12ac97d562d6b065b15cdd3ccbeb66012ab1ddb56ad02ab9826363b332b
6
+ metadata.gz: 479293ea0edfcae42e5a9d87677140c24698f05abc7dc7a231fccfcdac614f316359b750f439ef41925a347d3affb5f50d9073280ea2f0e6ba29915acbc6ac56
7
+ data.tar.gz: 5a8a2563881c6441881e5a79dd047436f4d8a765719662b82339117cd25276fda89517f922f3991bc9cd5f2fe9474018e6c2f1717f14fa4e5d93cf5415b462ca
data/bin/anonymize-yaml CHANGED
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "yaml"
5
+ require "dorian/arguments"
5
6
 
6
7
  def anonymize_yaml(data)
7
8
  case data
@@ -22,23 +23,15 @@ def anonymize_yaml(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
 
40
- inputs.each do |input|
41
- content = File.exist?(input) ? File.read(input) : input
42
- yaml = anonymize_yaml(YAML.safe_load(content)).to_yaml
43
- File.exist?(input) ? File.write(input, yaml) : puts(yaml)
44
- end
34
+ inputs = parsed.arguments + parsed.files.map { |file| File.read(file) }
35
+ inputs = [$stdin.each_line.to_a.join] if inputs.empty?
36
+
37
+ inputs.each { |input| puts anonymize_yaml(YAML.safe_load(input)).to_yaml }
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-anonymize-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.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-18 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dorian-arguments
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: anonymize yaml file
14
28
  email: dorian@dorianmarie.com
15
29
  executables: