dorian-yaml-compare 0.1.0 → 0.2.0

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/lib/dorian/yaml/compare.rb +18 -4
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 209600762585c87f04acd78162361b374f5bceb7d707e21c5914dd12ff955afe
4
- data.tar.gz: b3a86e92e978644b43c7e3605cd691f61b7375ef0540d5bc88178dac2a749651
3
+ metadata.gz: dac547da5922e8c9f27d5c659acfa6b0e5fbb478b302209cdce31042797827f0
4
+ data.tar.gz: 9c012120b1bc9008171d94dabbca387a8684979267831cfa6f4782070753aa46
5
5
  SHA512:
6
- metadata.gz: a3cc98cb1d6de336a4ecff3717d1c7199da3cbcf79d4ebc163995e8d02941dc6466067479b1b5492c73806b0d3a7e9cca51ea0ddbc1d68aa0c3f6075d8533907
7
- data.tar.gz: a82c4e747761e8bc2a35c8524f64b21f8164afacf3220ba4a75d161b88407a5aa855ce81a17009173ae0fb8d014b9f9eb8f81c2df88a19e56f9be729224f1a45
6
+ metadata.gz: 043b5831a42e8a996398488a0336dc14d47596148b00cc14b178f8c5762961afde71708bcea6bd9cc0ac576f3161f791fe6d080ffdba3642bc2f1a545b476f63
7
+ data.tar.gz: c4e39944b73c7c1533cc6aeee00275f535b27d22b6f7cd4ddc4b7f0b38ede95f919b473be8c1c5f16becd9adc8e0cad873c274f374c1f415b72af1c1d53fe21a
@@ -1,11 +1,11 @@
1
- require 'yaml'
1
+ require "yaml"
2
2
 
3
3
  module Dorian
4
4
  module Yaml
5
5
  class Compare
6
6
  def self.run
7
7
  if ARGV.size < 2 || ARGV.size > 4
8
- puts 'USAGE: yaml-compare FILE1 FILE2 [ROOT1] [ROOT2]'
8
+ puts "USAGE: yaml-compare FILE1 FILE2 [ROOT1] [ROOT2]"
9
9
  exit
10
10
  end
11
11
 
@@ -16,10 +16,15 @@ module Dorian
16
16
  file1 = file1[root1] if !root1.nil?
17
17
  file2 = file2[root2] if !root2.nil?
18
18
 
19
- compare(file1, file2)
19
+ output = with_captured_stdout { compare(file1, file2) }
20
+
21
+ if output != ""
22
+ $stderr.puts output
23
+ exit 1
24
+ end
20
25
  end
21
26
 
22
- def self.compare(hash1, hash2, current: '')
27
+ def self.compare(hash1, hash2, current: "")
23
28
  if hash1.kind_of?(Array)
24
29
  hash1.each.with_index do |_, i|
25
30
  compare(hash1[i], hash2[i], current: current)
@@ -43,6 +48,15 @@ module Dorian
43
48
  end
44
49
  end
45
50
  end
51
+
52
+ def self.with_captured_stdout(&block)
53
+ original_stdout = $stdout
54
+ $stdout = StringIO.new
55
+ block.call
56
+ $stdout.string
57
+ ensure
58
+ $stdout = original_stdout
59
+ end
46
60
  end
47
61
  end
48
62
  end
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-10 00:00:00.000000000 Z
11
+ date: 2021-11-18 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
@@ -25,7 +25,8 @@ files:
25
25
  homepage: https://github.com/dorianmariefr/yaml-compare
26
26
  licenses:
27
27
  - MIT
28
- metadata: {}
28
+ metadata:
29
+ rubygems_mfa_required: 'true'
29
30
  post_install_message:
30
31
  rdoc_options: []
31
32
  require_paths: