diff --git a/lib/twitter_cldr/resources/import/tailoring.rb b/lib/twitter_cldr/resources/import/tailoring.rb index 54e34f99f..a07d03475 100644 --- a/lib/twitter_cldr/resources/import/tailoring.rb +++ b/lib/twitter_cldr/resources/import/tailoring.rb @@ -58,10 +58,10 @@ def import(locale) print "Importing %8s\t--\t" % locale if tailoring_present?(locale) - YAML.dump(tailoring_data(locale), open(resource_file_path(locale), 'w')) + dump(locale, tailoring_data(locale)) puts "Done." else - YAML.dump(EMPTY_TAILORING_DATA, open(resource_file_path(locale), 'w')) + dump(locale, EMPTY_TAILORING_DATA) puts "Missing (generated empty tailoring resource)." end rescue ImportError => e @@ -70,6 +70,10 @@ def import(locale) private + def dump(locale, data) + open(resource_file_path(locale), 'w') { |file| YAML.dump(data, file) } + end + def tailoring_present?(locale) File.file?(locale_file_path(locale)) end