dorian-yaml-compare 0.3.0 → 0.3.1
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 +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d04aae43888d5b7e10630c507246ed9e5808ed6445f38272ecb8ecc2e163e237
|
4
|
+
data.tar.gz: 626a3f19c97012e67af790fc6c48c33e1d1c2b8b3438ddd4f9d4e9e738010471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40c1edf694258fffb0359adc010c101382e0b3b149e738a961baaa0cd73ab5e41299042f7b62d53ddf01755dbf6d997625e4ca3da0d71383efed01003bca05e
|
7
|
+
data.tar.gz: 79aa89ad7b386cd5d78eb0f8fc2b82296e659a426586e5dc88010809a67e7fec8687dc71588a99437fe7a3dc77547b086a58adc7e172ff047219e6b6c88fa2be
|
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,14 +1,14 @@
|
|
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.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:
|
11
|
+
date: 2024-02-08 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
|
@@ -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
|