aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/numeric/conversions.rb12
-rw-r--r--activesupport/lib/active_support/core_ext/string/access.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/filters.rb2
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb2
-rw-r--r--activesupport/lib/active_support/number_helper.rb9
-rw-r--r--activesupport/lib/active_support/testing/performance.rb8
6 files changed, 15 insertions, 20 deletions
diff --git a/activesupport/lib/active_support/core_ext/numeric/conversions.rb b/activesupport/lib/active_support/core_ext/numeric/conversions.rb
index 2666387623..2bbfa78639 100644
--- a/activesupport/lib/active_support/core_ext/numeric/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/numeric/conversions.rb
@@ -2,7 +2,7 @@ require 'active_support/core_ext/big_decimal/conversions'
require 'active_support/number_helper'
class Numeric
-
+
# Provides options for converting numbers into formatted strings.
# Options are provided for phone numbers, currency, percentage,
# precision, positional notation, file size and pretty printing.
@@ -97,7 +97,7 @@ class Numeric
# 1234567.to_s(:human, :precision => 1,
# :separator => ',',
# :significant => false) # => "1,2 Million"
- def to_formatted_s(format = :default, options = {})
+ def to_formatted_s(format = :default, options = {})
case format
when :phone
return ActiveSupport::NumberHelper.number_to_phone(self, options)
@@ -117,19 +117,19 @@ class Numeric
self.to_default_s
end
end
-
+
[Float, Fixnum, Bignum, BigDecimal].each do |klass|
klass.send(:alias_method, :to_default_s, :to_s)
-
+
klass.send(:define_method, :to_s) do |*args|
if args[0].is_a?(Symbol)
format = args[0]
options = args[1] || {}
-
+
self.to_formatted_s(format, options)
else
to_default_s(*args)
end
end
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb
index 5c32a2453d..8fa8157d65 100644
--- a/activesupport/lib/active_support/core_ext/string/access.rb
+++ b/activesupport/lib/active_support/core_ext/string/access.rb
@@ -1,5 +1,3 @@
-require 'active_support/multibyte'
-
class String
# If you pass a single Fixnum, returns a substring of one character at that
# position. The first character of the string is at position 0, the next at
diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb
index 70f2dcb562..8644529806 100644
--- a/activesupport/lib/active_support/core_ext/string/filters.rb
+++ b/activesupport/lib/active_support/core_ext/string/filters.rb
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/string/multibyte'
-
class String
# Returns the string, first removing all whitespace on both ends of
# the string, and then changing remaining consecutive whitespace
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index 4fe925f7f4..87b1d76026 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -76,7 +76,7 @@ module ActiveSupport #:nodoc:
#
# 'Café périferôl'.mb_chars.split(/é/).map { |part| part.upcase.to_s } # => ["CAF", " P", "RIFERÔL"]
def split(*args)
- @wrapped_string.split(*args).map { |i| i.mb_chars }
+ @wrapped_string.split(*args).map { |i| self.class.new(i) }
end
# Works like like <tt>String#slice!</tt>, but returns an instance of Chars, or nil if the string was not
diff --git a/activesupport/lib/active_support/number_helper.rb b/activesupport/lib/active_support/number_helper.rb
index 981ab0cb36..fc97782697 100644
--- a/activesupport/lib/active_support/number_helper.rb
+++ b/activesupport/lib/active_support/number_helper.rb
@@ -498,14 +498,13 @@ module ActiveSupport
formatted_number = self.number_to_rounded(number, options)
decimal_format.gsub(/%n/, formatted_number).gsub(/%u/, unit).strip
end
-
-
+
def self.private_module_and_instance_method(method_name)
private method_name
private_class_method method_name
end
private_class_method :private_module_and_instance_method
-
+
def format_translations(namespace, locale)
defaults_translations(locale).merge(translations_for(namespace, locale))
end
@@ -527,6 +526,6 @@ module ActiveSupport
false
end
private_module_and_instance_method :valid_float?
-
+
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/testing/performance.rb b/activesupport/lib/active_support/testing/performance.rb
index 2bea0f991a..517926c74d 100644
--- a/activesupport/lib/active_support/testing/performance.rb
+++ b/activesupport/lib/active_support/testing/performance.rb
@@ -3,7 +3,8 @@ require 'rails/version'
require 'active_support/concern'
require 'active_support/core_ext/class/delegating_attributes'
require 'active_support/core_ext/string/inflections'
-require 'action_view/helpers/number_helper'
+require 'active_support/core_ext/module/delegation'
+require 'active_support/number_helper'
module ActiveSupport
module Testing
@@ -195,8 +196,7 @@ module ActiveSupport
end
class Base
- include ActionView::Helpers::NumberHelper
- include ActionView::Helpers::OutputSafetyHelper
+ include ActiveSupport::NumberHelper
attr_reader :total
@@ -240,7 +240,7 @@ module ActiveSupport
class Amount < Base
def format(measurement)
- number_with_delimiter(measurement.floor)
+ number_to_delimited(measurement.floor)
end
end