dorian-anonymize-json 0.1.0 → 0.1.2

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 +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b78a46795d6921a2142115f0f08420643eeda864651145cc424762321e8a1f87
4
- data.tar.gz: 179aae0ba279126b9ca76cecfc97ed356bd75b81b6069c30d843e8e055a32fda
3
+ metadata.gz: 1ca9bc6cbdae04b5c3247c6d3350bdd7040184a53ffe1c57607a2353bcbd1e61
4
+ data.tar.gz: 179f73c8d8ed18c69d5bf880c415eb4c5e82d6303ea65523887832dbd6f13956
5
5
  SHA512:
6
- metadata.gz: 87e6885624b0d0325adc0c69bdf30cf70c35157b2bc5a4d0b822620c058117fc2b47c71d2af5ae48f53cc2cb1bc593823f23dc8a58108ae06c1fbf4ffdf8540a
7
- data.tar.gz: d9be58723ca1b53a3792bb389606d5dd1d5b9ae0a449be1a771204be15319454e828cedc61b1981061f37c2e1c47d77544f2aea88b8fba0ccbe130eb8d007174
6
+ metadata.gz: 6eb482c337f23bf1d1bddd8070ab46afe7bd38d45a77e78ba91f53c216aaf2ee9bde63dbe136a6238560782c27b1a209acfd571dffc04f742cc2caa20267150f
7
+ data.tar.gz: a02155f3628345f72f623016410371331cf764d1e053a544fd1694bbc336bc53345fc800c88e2feec85cb929ec17fe9806aa6a72f533f059126d42f9497c815e
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.2
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
@@ -48,7 +48,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: '0'
51
+ version: 3.3.0
52
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="