lib/i18n/tasks/data/adapter/yaml_adapter.rb in i18n-tasks-1.0.12 vs lib/i18n/tasks/data/adapter/yaml_adapter.rb in i18n-tasks-1.0.13

- old
+ new

@@ -4,10 +4,11 @@ module I18n::Tasks module Data module Adapter module YamlAdapter EMOJI_REGEX = /\\u[\da-f]{8}/i.freeze + TRAILING_SPACE_REGEX = / $/.freeze class << self # @return [Hash] locale tree def parse(str, options) if YAML.method(:load).arity.abs == 2 @@ -18,15 +19,20 @@ end end # @return [String] def dump(tree, options) - restore_emojis(tree.to_yaml(options || {})) + strip_trailing_spaces(restore_emojis(tree.to_yaml(options || {}))) end # @return [String] def restore_emojis(yaml) yaml.gsub(EMOJI_REGEX) { |m| [m[-8..].to_i(16)].pack('U') } + end + + # @return [String] + def strip_trailing_spaces(yaml) + yaml.gsub(TRAILING_SPACE_REGEX, '') end end end end end