dorian-anonymize-yaml 0.1.2 → 0.1.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 +8 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 448c95f5d663f8cd1ed6b0e63a4eee34fbae647023ab391b6bdfa1b0acb9fc1c
4
- data.tar.gz: 0b7becac5519496c641f71f82dd6c066c80403b69d4892bc0468dc4c7a79b404
3
+ metadata.gz: 0d8e810270458b2e549c0445708077302556fe894cea8f0449088f025789e147
4
+ data.tar.gz: b8302f656297f15f006d76e8ab0c38b88ab526518bf098fa1079b9923ec24c3d
5
5
  SHA512:
6
- metadata.gz: 6677e442abc21d0a1589e3a941a005b20c5f9d97be524b3f5db230a24d248e8e6ef9ba1da6a080692cd61299e9a4ae5edc960290896ebe423ce05f421295a500
7
- data.tar.gz: 3d5f9f7dcb9a49d9124002888dcca3348591438045edd86fe49b0dd7055f27876d05d2180ec3c6d8e8d443643a0fdb7ed6f9fd87a7ede10813aba1d703de4baf
6
+ metadata.gz: bfe6763f90d18d07df527905f0ed4697469daa2bee8866fe5c4001939da5a644dbff2eb8ecbc3048186627544b98cab2efd901b383a970f1eddb7c55f3589f79
7
+ data.tar.gz: 42f84c5f1a44deddb06af23e894073f63222a427c1fac87900bce2d35d6773a9ddfd320d912690246ca48e3e9921d6ff122eb7f0899964b082d3bd18c66416f5
data/bin/anonymize-yaml CHANGED
@@ -1,22 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
- #!/usr/bin/env ruby
4
- # frozen_string_literal: true
5
3
 
6
4
  require "yaml"
7
5
 
8
6
  def anonymize_yaml(data)
9
- if data.is_a?(Array)
7
+ case data
8
+ when Array
10
9
  data.map { |element| anonymize_yaml(element) }
11
- elsif data.is_a?(Hash)
10
+ when Hash
12
11
  data.transform_values { |value| anonymize_yaml(value) }
13
- elsif data.is_a?(String)
12
+ when String
14
13
  data.gsub(/[0-9]/, "0").gsub(/[a-z]/, "a").gsub(/[A-Z]/, "A")
15
- elsif data.is_a?(Integer)
14
+ when Integer
16
15
  0
17
- elsif data.is_a?(Float)
16
+ when Float
18
17
  0.0
19
- elsif data.is_a?(TrueClass) || data.is_a?(FalseClass)
18
+ when TrueClass, FalseClass
20
19
  false
21
20
  else
22
21
  raise NotImplementedError, data.class.name
@@ -35,11 +34,7 @@ if inputs.empty?
35
34
  inputs = $stdin.each_line.to_a
36
35
 
37
36
  inputs =
38
- if File.exist?(inputs.first.strip)
39
- inputs.map(&:strip)
40
- else
41
- [inputs.join]
42
- end
37
+ (File.exist?(inputs.first.strip) ? inputs.map(&:strip) : [inputs.join])
43
38
  end
44
39
 
45
40
  inputs.each do |input|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-anonymize-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.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-03-09 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Anonymize YAML file