dorian-anonymize-yaml 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/anonymize-yaml +47 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e95c6ae483d3626f84f402084b54880e58f5e6cf51a1bef954b2f04678c11178
|
4
|
+
data.tar.gz: 97f3198888f4c7f6b206e88cfc04b8707be2c67acd55311b7afbe9814cd803a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5397b7268ea00efbabdb91eb17b1e5f342af476e5b3726b2ac5cc307b98afa500c348e613c9deae576ea199bfdf0714a2cb77e0b51a9c251dc7de973ea4dc82a
|
7
|
+
data.tar.gz: 7dc5c0a1c456117e31483892cdddf93b9306901f5a42d046e3bb8adcc3710e69186eef5d3944485240c8511386c62016a51eb09fe61519d2bfca1a56f028f0b5
|
data/bin/anonymize-yaml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#!/usr/bin/env ruby
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
def anonymize_yaml(data)
|
9
|
+
if data.is_a?(Array)
|
10
|
+
data.map { |element| anonymize_yaml(element) }
|
11
|
+
elsif data.is_a?(Hash)
|
12
|
+
data.transform_values { |value| anonymize_yaml(value) }
|
13
|
+
elsif data.is_a?(String)
|
14
|
+
data.gsub(/[0-9]/, "0").gsub(/[a-z]/, "a").gsub(/[A-Z]/, "A")
|
15
|
+
elsif data.is_a?(Integer)
|
16
|
+
0
|
17
|
+
elsif data.is_a?(Float)
|
18
|
+
0.0
|
19
|
+
else
|
20
|
+
raise NotImplementedError, data.class.name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if ARGV[0] == "--help" || ARGV[0] == "-h"
|
25
|
+
puts "USAGE: anonymize-yaml FILES..."
|
26
|
+
puts "USAGE: ... | anonymize-yaml"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
inputs = ARGV
|
31
|
+
|
32
|
+
if inputs.empty?
|
33
|
+
inputs = $stdin.each_line.to_a
|
34
|
+
|
35
|
+
inputs =
|
36
|
+
if File.exist?(inputs.first.strip)
|
37
|
+
inputs.map(&:strip)
|
38
|
+
else
|
39
|
+
[inputs.join]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
inputs.each do |input|
|
44
|
+
content = File.exist?(input) ? File.read(input) : input
|
45
|
+
yaml = anonymize_yaml(YAML.safe_load(content)).to_yaml
|
46
|
+
File.exist?(input) ? File.write(input, yaml) : puts(yaml)
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dorian-anonymize-yaml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dorian Marié
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |-
|
14
|
+
Anonymize YAML file
|
15
|
+
|
16
|
+
e.g. `anonymize-yaml spec/**/*.yml`
|
17
|
+
email: dorian@dorianmarie.com
|
18
|
+
executables:
|
19
|
+
- anonymize-yaml
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- bin/anonymize-yaml
|
24
|
+
homepage: https://github.com/dorianmariecom/anonymize-yaml
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata:
|
28
|
+
rubygems_mfa_required: 'true'
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubygems_version: 3.5.3
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Anonymize YAML file
|
48
|
+
test_files: []
|