diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index c323bd2ea5..792388d2b6 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added Fixnum#even? and Fixnum#odd? + * Fixed problem with classes being required twice. Object#const_missing now uses require_dependency to load files. It used to use require_or_load which would cause models to be loaded twice, which was not good for validations and other class methods #971 [Nicholas Seckar] diff --git a/activesupport/Rakefile b/activesupport/Rakefile index 99e49e9083..51294d4de6 100644 --- a/activesupport/Rakefile +++ b/activesupport/Rakefile @@ -58,13 +58,13 @@ end desc "Publish the beta gem" task :pgem => [:package] do - Rake::SshFilePublisher.new("davidhh@comox.textdrive.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh davidhh@comox.textdrive.com './gemupdate.sh'` + Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload + `ssh davidhh@wrath.rubyonrails.com './gemupdate.sh'` end desc "Publish the API documentation" task :pdoc => [:rdoc] do - Rake::SshDirPublisher.new("davidhh@comox.textdrive.com", "public_html/as", "doc").upload + Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.com", "public_html/as", "doc").upload end desc "Publish the release files to RubyForge." diff --git a/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb b/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb new file mode 100644 index 0000000000..1fa6b95846 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb @@ -0,0 +1,20 @@ +module ActiveSupport #:nodoc: + module CoreExtensions #:nodoc: + module Fixnum #:nodoc: + # For checking if a fixnum is even or odd. + # * 1.even? # => false + # * 1.odd? # => true + # * 2.even? # => true + # * 2.odd? # => false + module EvenOdd + def even? + self % 2 == 0 + end + + def odd? + !even? + end + end + end + end +end diff --git a/activesupport/test/core_ext/fixnum_ext_test.rb b/activesupport/test/core_ext/fixnum_ext_test.rb new file mode 100644 index 0000000000..627c282b8b --- /dev/null +++ b/activesupport/test/core_ext/fixnum_ext_test.rb @@ -0,0 +1,14 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/fixnum' + +class FixnumExtTest < Test::Unit::TestCase + def test_even + assert [ -2, 0, 2, 4 ].all? { |i| i.even? } + assert ![ -1, 1, 3 ].all? { |i| i.even? } + end + + def test_odd + assert ![ -2, 0, 2, 4 ].all? { |i| i.odd? } + assert [ -1, 1, 3 ].all? { |i| i.odd? } + end +end