From 90c2f93ea788e283e38e94bd0f07ce9b617422e6 Mon Sep 17 00:00:00 2001 From: Marcos Piccinini Date: Fri, 12 Dec 2014 21:25:49 -0200 Subject: [PATCH] deep_merge -> deep_sync, thanks @tmsrjs --- lib/i18n/sync.rb | 2 +- lib/i18n/sync/hash.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/i18n/sync.rb b/lib/i18n/sync.rb index fff9267..52213c4 100644 --- a/lib/i18n/sync.rb +++ b/lib/i18n/sync.rb @@ -51,7 +51,7 @@ def sync out "Writing #{filename}" (_comments, old) = read_file(filename, lang) # Initializing hash variable as empty if it does not exist - other = @words.dup.deep_merge! old + other = @words.dup.deep_sync! old write_file(filename, lang, @comments, other) end end diff --git a/lib/i18n/sync/hash.rb b/lib/i18n/sync/hash.rb index fbad37c..a262e75 100644 --- a/lib/i18n/sync/hash.rb +++ b/lib/i18n/sync/hash.rb @@ -1,10 +1,10 @@ class Hash # Ensures multilevel hash merging - def deep_merge!(other_hash) - other_hash.each do |k,v| + def deep_sync!(other_hash) + other_hash.each do |k, v| next unless tv = self[k] - self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.dup.deep_merge!(v) : v + self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.dup.deep_sync!(v) : v end self end