dorian-anonymize-json 0.1.0 → 0.1.1

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 +8 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b78a46795d6921a2142115f0f08420643eeda864651145cc424762321e8a1f87
4
- data.tar.gz: 179aae0ba279126b9ca76cecfc97ed356bd75b81b6069c30d843e8e055a32fda
3
+ metadata.gz: 5b10d9d8a9ef04993832be6ab68a62c9bba02e9a15b6535fae0a02f9c8b55081
4
+ data.tar.gz: e0840d07bdc4d87740838f7905a3144e57e39ad7396579d9b72c6bd42e55402a
5
5
  SHA512:
6
- metadata.gz: 87e6885624b0d0325adc0c69bdf30cf70c35157b2bc5a4d0b822620c058117fc2b47c71d2af5ae48f53cc2cb1bc593823f23dc8a58108ae06c1fbf4ffdf8540a
7
- data.tar.gz: d9be58723ca1b53a3792bb389606d5dd1d5b9ae0a449be1a771204be15319454e828cedc61b1981061f37c2e1c47d77544f2aea88b8fba0ccbe130eb8d007174
6
+ metadata.gz: 85f30cf6569e7bf7c557f7336cdaa878dab40613b4abf22bb3d314ca398882fa4c662e7f92be1bec36fe3849d285533e859713ba29475c16801212b40810128b
7
+ data.tar.gz: d7ac659d52ebc290348c8137c24f938fa87c029dba56bb746c23b72366932ae16f7599e5f53826f9e5efff9dc3387fb8328f42a3b3344bbfd56daf192e57b01f
data/bin/anonymize-json CHANGED
@@ -4,17 +4,18 @@
4
4
  require "json"
5
5
 
6
6
  def anonymize_json(data)
7
- if data.is_a?(Array)
7
+ case data
8
+ when Array
8
9
  data.map { |element| anonymize_json(element) }
9
- elsif data.is_a?(Hash)
10
+ when Hash
10
11
  data.transform_values { |value| anonymize_json(value) }
11
- elsif data.is_a?(String)
12
+ when String
12
13
  data.gsub(/[0-9]/, "0").gsub(/[a-z]/, "a").gsub(/[A-Z]/, "A")
13
- elsif data.is_a?(Integer)
14
+ when Integer
14
15
  0
15
- elsif data.is_a?(Float)
16
+ when Float
16
17
  0.0
17
- elsif data.is_a?(TrueClass) || data.is_a?(FalseClass)
18
+ when TrueClass, FalseClass
18
19
  false
19
20
  else
20
21
  raise NotImplementedError, data.class.name
@@ -33,11 +34,7 @@ if inputs.empty?
33
34
  inputs = $stdin.each_line.to_a
34
35
 
35
36
  inputs =
36
- if File.exist?(inputs.first.strip)
37
- inputs.map(&:strip)
38
- else
39
- [inputs.join]
40
- end
37
+ (File.exist?(inputs.first.strip) ? inputs.map(&:strip) : [inputs.join])
41
38
  end
42
39
 
43
40
  inputs.each do |input|
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.1.0
4
+ version: 0.1.1
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-29 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json