dorian-yaml-compare 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/yaml-compare +2 -1
- data/lib/dorian/yaml/compare.rb +11 -11
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfb6914c636ac9da87f840c4791845f6ac23d483e136f472d08b67e61a284dd7
|
4
|
+
data.tar.gz: 13f3ada06ad6990193eeddade67eb8573b508de4f07439ff9e0419546c9b7e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df6fa9e9cfae5482c12e02ce84438984c76da48af6ce6a66f6653528c3237d752943e8d09fdb0712723bffd0371851e7725f8edb2d6c2780f313aa49d2f6478
|
7
|
+
data.tar.gz: 1d8eb292169bfc5f9627c1ee7f0c3a7552dca3aa0ab6e381cde7a939d2d619e033f8a5f212cc0675ee4637221e8d746b6f1780be1c0a57d97561e2c2b0dea738
|
data/bin/yaml-compare
CHANGED
data/lib/dorian/yaml/compare.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "yaml"
|
2
4
|
|
3
5
|
module Dorian
|
@@ -9,12 +11,12 @@ module Dorian
|
|
9
11
|
exit
|
10
12
|
end
|
11
13
|
|
12
|
-
file1 = YAML.
|
13
|
-
file2 = YAML.
|
14
|
+
file1 = YAML.safe_load_file(ARGV[0])
|
15
|
+
file2 = YAML.safe_load_file(ARGV[1])
|
14
16
|
root1 = ARGV[2]
|
15
17
|
root2 = ARGV[3]
|
16
|
-
file1 = file1[root1]
|
17
|
-
file2 = file2[root2]
|
18
|
+
file1 = file1[root1] unless root1.nil?
|
19
|
+
file2 = file2[root2] unless root2.nil?
|
18
20
|
|
19
21
|
output = with_captured_stdout { compare(file1, file2) }
|
20
22
|
|
@@ -22,14 +24,12 @@ module Dorian
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def self.compare(hash1, hash2, current: "")
|
25
|
-
if hash1.
|
26
|
-
hash1.each.with_index
|
27
|
-
|
28
|
-
|
29
|
-
elsif hash1.kind_of?(String) || hash2.kind_of?(String)
|
30
|
-
if !hash1.kind_of?(String)
|
27
|
+
if hash1.is_a?(Array)
|
28
|
+
hash1.each.with_index { |_, i| compare(hash1[i], hash2[i], current:) }
|
29
|
+
elsif hash1.is_a?(String) || hash2.is_a?(String)
|
30
|
+
if !hash1.is_a?(String)
|
31
31
|
puts "key \"#{current}\" is a string in #{ARGV[1]}"
|
32
|
-
elsif !hash2.
|
32
|
+
elsif !hash2.is_a?(String)
|
33
33
|
puts "key \"#{current}\" is a string in #{ARGV[0]}"
|
34
34
|
end
|
35
35
|
else
|
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-yaml-compare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2024-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Compares keys of two YAML files, typically locales files in a Ruby on Rails application
|
15
15
|
|
16
16
|
e.g. `yaml-compare config/locales/en.yml config/locales/fr.yml en fr`
|
17
|
-
email: dorian@dorianmarie.
|
17
|
+
email: dorian@dorianmarie.com
|
18
18
|
executables:
|
19
19
|
- yaml-compare
|
20
20
|
extensions: []
|
@@ -22,7 +22,7 @@ extra_rdoc_files: []
|
|
22
22
|
files:
|
23
23
|
- bin/yaml-compare
|
24
24
|
- lib/dorian/yaml/compare.rb
|
25
|
-
homepage: https://github.com/
|
25
|
+
homepage: https://github.com/dorianmariecom/yaml-compare
|
26
26
|
licenses:
|
27
27
|
- MIT
|
28
28
|
metadata:
|
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
45
|
+
rubygems_version: 3.5.3
|
46
46
|
signing_key:
|
47
47
|
specification_version: 4
|
48
48
|
summary: Compares keys of two YAML files, typically locales files in a Ruby on Rails
|