Last active
August 29, 2015 14:21
-
-
Save tadast/97016c420f83c13e7e99 to your computer and use it in GitHub Desktop.
Unused YAML keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_keys(hash) | |
hash.flat_map do |key, value| | |
if value.is_a?(Hash) | |
find_keys(value) | |
else | |
key | |
end | |
end | |
end | |
phrases = YAML.load_file("lib/smart_answer_flows/locales/en/marriage-abroad.yml") | |
keys = find_keys(phrases).uniq | |
logic_file = File.open("lib/smart_answer_flows/marriage-abroad.rb", "r").read | |
test_file = File.open("test/integration/smart_answer_flows/marriage_abroad_test.rb", "r").read | |
unused = keys.select do |key| | |
logic_file.exclude?(key) && test_file.exclude?(key) | |
end - %w(description hint) | |
puts "Potentially unused keys (they may be coming from interpolated strings in the logic file):" | |
puts unused |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment