Skip to content

Commit

Permalink
Offer replacements for currency position deprecations (tonsky#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoarnold authored and antstorm committed Nov 13, 2018
1 parent 8e4ddaf commit 8f5ccc1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/money/money/formatting_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,18 @@ def symbol_position_from(rules)

def warn_about_deprecated_rules(rules)
if rules.has_key?(:symbol_position)
warn '[DEPRECATION] `symbol_position:` option is deprecated - use `format` to specify the formatting template.'
position = rules[:symbol_position]
template = position == :before ? '%u %n' : '%n %u'

warn "[DEPRECATION] `symbol_position: :#{position}` is deprecated - you can replace it with `format: #{template}`"
end

if rules.has_key?(:symbol_before_without_space)
warn '[DEPRECATION] `symbol_before_without_space:` option is deprecated - use `format` to specify the formatting template.'
warn "[DEPRECATION] `symbol_before_without_space:` option is deprecated - you can replace it with `format: '%u%n'`"
end

if rules.has_key?(:symbol_after_without_space)
warn '[DEPRECATION] `symbol_after_without_space:` option is deprecated - use `format` to specify the formatting template.'
warn "[DEPRECATION] `symbol_after_without_space:` option is deprecated - you can replace it with `format: '%n%u'`"
end

if rules.has_key?(:html)
Expand All @@ -121,7 +124,6 @@ def warn_about_deprecated_rules(rules)
if rules.has_key?(:html_wrap_symbol)
warn "[DEPRECATION] `html_wrap_symbol` is deprecated - use `html_wrap` instead. Please note that `html_wrap` will wrap all parts of currency."
end

end
end
end

0 comments on commit 8f5ccc1

Please sign in to comment.