dorian-anonymize-yaml 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-yaml +9 -14
  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: 4b4a24d6484fb6c4079c7777f0f1bfdb54c4d0f16bd53ebb771388fd009d6cc3
4
+ data.tar.gz: 93debeed80b244757704efc1e610a2e0db4a3e58cc74bc3a4a6b2e3c32279006
5
5
  SHA512:
6
- metadata.gz: 7df4cc43e24901283516d5298aa7fece2a3abdd61b111b55f7418348b4c775a4d8704b290617cb20ef69c81487c98a5ac6ca589d698c54061018d524ebc8bcda
7
- data.tar.gz: 64ac555dea1272b5d15444b1881634aae2a7623d98f5520c86f560eb03097e8e2b72a12ac97d562d6b065b15cdd3ccbeb66012ab1ddb56ad02ab9826363b332b
6
+ metadata.gz: 0543dc286a648769f4fe64fbdbc71a5f56d2e6fb13d8f596b58e89e6118ab811e4d0c1b6dc050ae7a4d83f51583626ede4736983c0a80539df4d57df2ce4ed79
7
+ data.tar.gz: cb86e85bbd65cc9f20374ad95af72a6d2936b7545583b845540835c39275ec823fab52fdbe55effacd35a7f75e2c614f64d267373b467297a375ff3f266af8f4
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,17 @@ 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
 
34
+ inputs = parsed.arguments + parsed.files.map { |file| File.read(file) }
35
+ inputs = [$stdin.each_line.to_a.join] if inputs.empty?
36
+
40
37
  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)
38
+ puts anonymize_yaml(YAML.safe_load(input)).to_yaml
44
39
  end
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: 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
12
- dependencies: []
11
+ date: 2024-08-22 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: