aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/fixnum.rb12
-rw-r--r--activesupport/lib/active_support/core_ext/integer.rb7
-rw-r--r--activesupport/lib/active_support/core_ext/integer/even_odd.rb (renamed from activesupport/lib/active_support/core_ext/fixnum/even_odd.rb)2
-rw-r--r--activesupport/lib/active_support/core_ext/integer/inflections.rb (renamed from activesupport/lib/active_support/core_ext/fixnum/inflections.rb)2
-rw-r--r--activesupport/test/core_ext/integer_ext_test.rb (renamed from activesupport/test/core_ext/fixnum_ext_test.rb)10
6 files changed, 17 insertions, 18 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index a2402c9187..51abed18d9 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Factor Fixnum and Bignum extensions into Integer extensions [Nicholas Seckar]
+
* Hooked #ordinalize into Fixnum and Bignum classes. [Nicholas Seckar, danp]
* Added stripping of _id to humanize, so "employee_id" becomes "Employee" #1574 [Justin French]
diff --git a/activesupport/lib/active_support/core_ext/fixnum.rb b/activesupport/lib/active_support/core_ext/fixnum.rb
deleted file mode 100644
index 519408fb0d..0000000000
--- a/activesupport/lib/active_support/core_ext/fixnum.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require File.dirname(__FILE__) + '/fixnum/even_odd'
-require File.dirname(__FILE__) + '/fixnum/inflections'
-
-class Fixnum #:nodoc:
- include ActiveSupport::CoreExtensions::Fixnum::EvenOdd
- include ActiveSupport::CoreExtensions::Fixnum::Inflections
-end
-
-class Bignum #:nodoc:
- include ActiveSupport::CoreExtensions::Fixnum::EvenOdd
- include ActiveSupport::CoreExtensions::Fixnum::Inflections
-end \ No newline at end of file
diff --git a/activesupport/lib/active_support/core_ext/integer.rb b/activesupport/lib/active_support/core_ext/integer.rb
new file mode 100644
index 0000000000..9346b88fd5
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/integer.rb
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/integer/even_odd'
+require File.dirname(__FILE__) + '/integer/inflections'
+
+class Integer #:nodoc:
+ include ActiveSupport::CoreExtensions::Integer::EvenOdd
+ include ActiveSupport::CoreExtensions::Integer::Inflections
+end
diff --git a/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb b/activesupport/lib/active_support/core_ext/integer/even_odd.rb
index c0e9da18fa..3762308cc3 100644
--- a/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb
+++ b/activesupport/lib/active_support/core_ext/integer/even_odd.rb
@@ -1,6 +1,6 @@
module ActiveSupport #:nodoc:
module CoreExtensions #:nodoc:
- module Fixnum #:nodoc:
+ module Integer #:nodoc:
# For checking if a fixnum is even or odd.
# * 1.even? # => false
# * 1.odd? # => true
diff --git a/activesupport/lib/active_support/core_ext/fixnum/inflections.rb b/activesupport/lib/active_support/core_ext/integer/inflections.rb
index 13c4f1130a..a86c4cc26c 100644
--- a/activesupport/lib/active_support/core_ext/fixnum/inflections.rb
+++ b/activesupport/lib/active_support/core_ext/integer/inflections.rb
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../../inflector'
module ActiveSupport #:nodoc:
module CoreExtensions #:nodoc:
- module Fixnum #:nodoc:
+ module Integer #:nodoc:
module Inflections
# 1.ordinalize # => "1st"
# 3.ordinalize # => "3rd"
diff --git a/activesupport/test/core_ext/fixnum_ext_test.rb b/activesupport/test/core_ext/integer_ext_test.rb
index 66297fc378..4435bc79d3 100644
--- a/activesupport/test/core_ext/fixnum_ext_test.rb
+++ b/activesupport/test/core_ext/integer_ext_test.rb
@@ -1,7 +1,7 @@
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/fixnum'
+require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/integer'
-class FixnumExtTest < Test::Unit::TestCase
+class IntegerExtTest < Test::Unit::TestCase
def test_even
assert [ -2, 0, 2, 4 ].all? { |i| i.even? }
assert ![ -1, 1, 3 ].all? { |i| i.even? }
@@ -15,11 +15,12 @@ class FixnumExtTest < Test::Unit::TestCase
def test_odd
assert ![ -2, 0, 2, 4 ].all? { |i| i.odd? }
assert [ -1, 1, 3 ].all? { |i| i.odd? }
+ assert 1000000000000000000000000000000000000000000000000000000001.odd?
end
def test_multiple_of
- assert [ -7, 0, 7, 14 ].all? { |i| i.multiple_of? 7 }
- assert ![ -7, 0, 7, 14 ].all? { |i| i.multiple_of? 6 }
+ [ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) }
+ [ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) }
# test with a prime
assert !22953686867719691230002707821868552601124472329079.multiple_of?(2)
assert !22953686867719691230002707821868552601124472329079.multiple_of?(3)
@@ -32,5 +33,6 @@ class FixnumExtTest < Test::Unit::TestCase
# It's results are tested comprehensively in the inflector test cases.
assert_equal '1st', 1.ordinalize
assert_equal '8th', 8.ordinalize
+ 1000000000000000000000000000000000000000000000000000000000000000000000.ordinalize
end
end