aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorŁukasz Strzałkowski <lukasz.strzalkowski@gmail.com>2010-07-20 11:07:13 +0200
committerJosé Valim <jose.valim@gmail.com>2010-07-26 17:26:59 +0200
commitda845275dde0f7c13f4a24c0366f809c5006e70a (patch)
treeca232b3d90866e0d5c174fe0fa66e487850bd570 /actionpack/lib
parentf70c0b348d2f703d763a8136df7837567f7cb691 (diff)
downloadrails-da845275dde0f7c13f4a24c0366f809c5006e70a.tar.gz
rails-da845275dde0f7c13f4a24c0366f809c5006e70a.tar.bz2
rails-da845275dde0f7c13f4a24c0366f809c5006e70a.zip
Removed deprecated APIs in text and number helpers [#5156 state:resolved]
They're deprecated since 2008. It's time to get rid of them. Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb48
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb21
2 files changed, 5 insertions, 64 deletions
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index 37e5d91d8b..f11027bc93 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -186,14 +186,7 @@ module ActionView
# number_with_delimiter(12345678.05, :locale => :fr) # => 12 345 678,05
# number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",")
# # => 98 765 432,98
- #
- # You can still use <tt>number_with_delimiter</tt> with the old API that accepts the
- # +delimiter+ as its optional second and the +separator+ as its
- # optional third parameter:
- # number_with_delimiter(12345678, " ") # => 12 345 678
- # number_with_delimiter(12345678.05, ".", ",") # => 12.345.678,05
- def number_with_delimiter(number, *args)
- options = args.extract_options!
+ def number_with_delimiter(number, options = {})
options.symbolize_keys!
begin
@@ -207,14 +200,6 @@ module ActionView
end
defaults = I18n.translate(:'number.format', :locale => options[:locale], :default => {})
-
- unless args.empty?
- ActiveSupport::Deprecation.warn('number_with_delimiter takes an option hash ' +
- 'instead of separate delimiter and precision arguments.', caller)
- options[:delimiter] ||= args[0] if args[0]
- options[:separator] ||= args[1] if args[1]
- end
-
options = options.reverse_merge(defaults)
parts = number.to_s.split('.')
@@ -249,13 +234,7 @@ module ActionView
# number_with_precision(389.32314, :precision => 4, :significant => true) # => 389.3
# number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')
# # => 1.111,23
- #
- # You can still use <tt>number_with_precision</tt> with the old API that accepts the
- # +precision+ as its optional second parameter:
- # number_with_precision(111.2345, 2) # => 111.23
- def number_with_precision(number, *args)
-
- options = args.extract_options!
+ def number_with_precision(number, options = {})
options.symbolize_keys!
number = begin
@@ -272,13 +251,6 @@ module ActionView
precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale], :default => {})
defaults = defaults.merge(precision_defaults)
- #Backwards compatibility
- unless args.empty?
- ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' +
- 'instead of a separate precision argument.', caller)
- options[:precision] ||= args[0] if args[0]
- end
-
options = options.reverse_merge(defaults) # Allow the user to unset default values: Eg.: :significant => false
precision = options.delete :precision
significant = options.delete :significant
@@ -337,13 +309,7 @@ module ActionView
# <tt>:strip_insignificant_zeros</tt> to +false+ to change that):
# number_to_human_size(1234567890123, :precision => 5) # => "1.1229 TB"
# number_to_human_size(524288000, :precision=>5) # => "500 MB"
- #
- # You can still use <tt>number_to_human_size</tt> with the old API that accepts the
- # +precision+ as its optional second parameter:
- # number_to_human_size(1234567, 1) # => 1 MB
- # number_to_human_size(483989, 2) # => 470 KB
- def number_to_human_size(number, *args)
- options = args.extract_options!
+ def number_to_human_size(number, options = {})
options.symbolize_keys!
number = begin
@@ -359,13 +325,7 @@ module ActionView
defaults = I18n.translate(:'number.format', :locale => options[:locale], :default => {})
human = I18n.translate(:'number.human.format', :locale => options[:locale], :default => {})
defaults = defaults.merge(human)
-
- unless args.empty?
- ActiveSupport::Deprecation.warn('number_to_human_size takes an option hash ' +
- 'instead of a separate precision argument.', caller)
- options[:precision] ||= args[0] if args[0]
- end
-
+
options = options.reverse_merge(defaults)
#for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
options[:strip_insignificant_zeros] = true if not options.key?(:strip_insignificant_zeros)
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 0be8a2c36e..52a016c9c1 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -61,27 +61,8 @@ module ActionView
#
# truncate("<p>Once upon a time in a world far far away</p>")
# # => "<p>Once upon a time in a wo..."
- #
- # You can still use <tt>truncate</tt> with the old API that accepts the
- # +length+ as its optional second and the +ellipsis+ as its
- # optional third parameter:
- # truncate("Once upon a time in a world far far away", 14)
- # # => "Once upon a..."
- #
- # truncate("And they found that many people were sleeping better.", 25, "... (continued)")
- # # => "And they f... (continued)"
- def truncate(text, *args)
- options = args.extract_options!
- unless args.empty?
- ActiveSupport::Deprecation.warn('truncate takes an option hash instead of separate ' +
- 'length and omission arguments', caller)
-
- options[:length] = args[0] || 30
- options[:omission] = args[1] || "..."
- end
-
+ def truncate(text, options = {})
options.reverse_merge!(:length => 30)
-
text.truncate(options.delete(:length), options) if text
end