From d7d11f0dab7f2875d04c17921e12fe62ac6e9566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 2 Dec 2013 22:31:05 -0200 Subject: [PATCH] :sicssors: --- .../lib/active_support/number_helper/number_converter.rb | 4 ++-- .../number_helper/number_to_currency_converter.rb | 2 -- .../number_helper/number_to_delimited_converter.rb | 2 -- .../active_support/number_helper/number_to_human_converter.rb | 2 -- .../number_helper/number_to_human_size_converter.rb | 2 -- .../number_helper/number_to_percentage_converter.rb | 2 -- .../active_support/number_helper/number_to_phone_converter.rb | 1 - .../number_helper/number_to_rounded_converter.rb | 2 -- 8 files changed, 2 insertions(+), 15 deletions(-) diff --git a/activesupport/lib/active_support/number_helper/number_converter.rb b/activesupport/lib/active_support/number_helper/number_converter.rb index 157d7820c3..4bc8b4a8e7 100644 --- a/activesupport/lib/active_support/number_helper/number_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_converter.rb @@ -7,7 +7,6 @@ require 'active_support/core_ext/class/attribute' module ActiveSupport module NumberHelper class NumberConverter # :nodoc: - # Default and i18n option namespace per class class_attribute :namespace @@ -149,9 +148,11 @@ module ActiveSupport def i18n_format_options #:nodoc: locale = opts[:locale] options = I18n.translate(:'number.format', locale: locale, default: {}).dup + if namespace options.merge!(I18n.translate(:"number.#{namespace}.format", locale: locale, default: {})) end + options end @@ -172,7 +173,6 @@ module ActiveSupport rescue ArgumentError, TypeError false end - end end end diff --git a/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb b/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb index 90a3cede3a..28f33164a5 100644 --- a/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb @@ -1,7 +1,6 @@ module ActiveSupport module NumberHelper class NumberToCurrencyConverter < NumberConverter # :nodoc: - self.namespace = :currency def convert @@ -42,7 +41,6 @@ module ActiveSupport i18n[:negative_format] ||= "-#{i18n[:format]}" if i18n[:format] i18n end - end end end diff --git a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb b/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb index 6604b9cce4..2b5dbd1d5a 100644 --- a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb @@ -1,7 +1,6 @@ module ActiveSupport module NumberHelper class NumberToDelimitedConverter < NumberConverter #:nodoc: - self.need_valid_float = true DELIMITED_REGEX = /(\d)(?=(\d\d\d)+(?!\d))/ @@ -17,7 +16,6 @@ module ActiveSupport left.gsub!(DELIMITED_REGEX) { "#{$1}#{options[:delimiter]}" } [left, right].compact end - end end end diff --git a/activesupport/lib/active_support/number_helper/number_to_human_converter.rb b/activesupport/lib/active_support/number_helper/number_to_human_converter.rb index 0c1a7250e3..9cdc18c373 100644 --- a/activesupport/lib/active_support/number_helper/number_to_human_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_human_converter.rb @@ -1,7 +1,6 @@ module ActiveSupport module NumberHelper class NumberToHumanConverter < NumberConverter # :nodoc: - DECIMAL_UNITS = { 0 => :unit, 1 => :ten, 2 => :hundred, 3 => :thousand, 6 => :million, 9 => :billion, 12 => :trillion, 15 => :quadrillion, -1 => :deci, -2 => :centi, -3 => :mili, -6 => :micro, -9 => :nano, -12 => :pico, -15 => :femto } INVERTED_DECIMAL_UNITS = DECIMAL_UNITS.invert @@ -62,7 +61,6 @@ module ActiveSupport raise ArgumentError, ":units must be a Hash or String translation scope." end.keys.map { |e_name| INVERTED_DECIMAL_UNITS[e_name] }.sort_by { |e| -e } end - end end end diff --git a/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb b/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb index 467ad030b5..33fc6e3553 100644 --- a/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb @@ -1,7 +1,6 @@ module ActiveSupport module NumberHelper class NumberToHumanSizeConverter < NumberConverter - STORAGE_UNITS = [:byte, :kb, :mb, :gb, :tb] self.namespace = :human @@ -53,7 +52,6 @@ module ActiveSupport def base opts[:prefix] == :si ? 1000 : 1024 end - end end end diff --git a/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb b/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb index c654bfaa3a..eafe2844f7 100644 --- a/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb @@ -1,14 +1,12 @@ module ActiveSupport module NumberHelper class NumberToPercentageConverter < NumberConverter # :nodoc: - self.namespace = :percentage def convert rounded_number = NumberToRoundedConverter.convert(number, options) options[:format].gsub('%n', rounded_number) end - end end end diff --git a/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb b/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb index c4aa5c311a..9828bec053 100644 --- a/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb @@ -44,7 +44,6 @@ module ActiveSupport def phone_ext(ext) ext.blank? ? "" : " x #{ext}" end - end end end diff --git a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb index 820e1534e2..ab430bbc7a 100644 --- a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb @@ -1,7 +1,6 @@ module ActiveSupport module NumberHelper class NumberToRoundedConverter < NumberConverter # :nodoc: - self.namespace = :precision self.need_valid_float = true @@ -55,7 +54,6 @@ module ActiveSupport number end end - end end end