aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-05-15 21:54:46 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-05-15 21:54:46 +0100
commit879493c35fd8d9e12e5cf3e56cd67ff07c3345c5 (patch)
tree9615859e1d9a52f71da444b0b7359817bb6acc50 /activesupport
parentd6ecce66f4e125531875006eea8022b73fe135b5 (diff)
parentfc02eabf296d6edb74a95174c7322293a54c9492 (diff)
downloadrails-879493c35fd8d9e12e5cf3e56cd67ff07c3345c5.tar.gz
rails-879493c35fd8d9e12e5cf3e56cd67ff07c3345c5.tar.bz2
rails-879493c35fd8d9e12e5cf3e56cd67ff07c3345c5.zip
Merge commit 'mainstream/master'
Conflicts: actionmailer/lib/action_mailer/base.rb
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/MIT-LICENSE2
-rw-r--r--activesupport/lib/active_support.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb2
-rw-r--r--activesupport/lib/active_support/deprecation.rb13
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb43
-rw-r--r--activesupport/lib/active_support/ordered_options.rb44
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb2
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb9
-rw-r--r--activesupport/lib/active_support/version.rb2
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb2
-rw-r--r--activesupport/test/deprecation_test.rb10
-rw-r--r--activesupport/test/ordered_hash_test.rb45
-rw-r--r--activesupport/test/ordered_options_test.rb44
14 files changed, 99 insertions, 122 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 185aff9088..e8821060f9 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,4 +1,4 @@
-*SVN*
+*2.1.0 RC1 (May 11th, 2008)*
* Remove unused JSON::RESERVED_WORDS, JSON.valid_identifier? and JSON.reserved_word? methods. Resolves #164. [Cheah Chu Yeow]
diff --git a/activesupport/MIT-LICENSE b/activesupport/MIT-LICENSE
index dbe78035ba..2ba4e17035 100644
--- a/activesupport/MIT-LICENSE
+++ b/activesupport/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2005-2007 David Heinemeier Hansson
+Copyright (c) 2005-2008 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb
index 4d2f873a8d..e4cb145c98 100644
--- a/activesupport/lib/active_support.rb
+++ b/activesupport/lib/active_support.rb
@@ -39,6 +39,7 @@ require 'active_support/cache'
require 'active_support/dependencies'
require 'active_support/deprecation'
+require 'active_support/ordered_hash'
require 'active_support/ordered_options'
require 'active_support/option_merger'
diff --git a/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb b/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
index 371d074d34..8724a492bf 100644
--- a/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
+++ b/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
@@ -128,7 +128,7 @@ class Class # :nodoc:
new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
else
new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)|
- memo.update(key => (value.dup rescue value))
+ memo.update(key => value.duplicable? ? value.dup : value)
end
end
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index 7613652c71..6aa379b550 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -176,19 +176,6 @@ module ActiveSupport
end
end
- class DeprecatedInstanceVariable < Delegator #:nodoc:
- def initialize(value, method)
- super(value)
- @method = method
- @value = value
- end
-
- def __getobj__
- ActiveSupport::Deprecation.warn("Instance variable @#{@method} is deprecated! Call instance method #{@method} instead.")
- @value
- end
- end
-
end
end
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
new file mode 100644
index 0000000000..6993621ef9
--- /dev/null
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -0,0 +1,43 @@
+# OrderedHash is namespaced to prevent conflicts with other implementations
+module ActiveSupport
+ # Hash is ordered in Ruby 1.9!
+ if RUBY_VERSION >= '1.9'
+ OrderedHash = ::Hash
+ else
+ class OrderedHash < Array #:nodoc:
+ def []=(key, value)
+ if pair = assoc(key)
+ pair.pop
+ pair << value
+ else
+ self << [key, value]
+ end
+ end
+
+ def [](key)
+ pair = assoc(key)
+ pair ? pair.last : nil
+ end
+
+ def delete(key)
+ pair = assoc(key)
+ pair ? array_index = index(pair) : nil
+ array_index ? delete_at(array_index).last : nil
+ end
+
+ def keys
+ collect { |key, value| key }
+ end
+
+ def values
+ collect { |key, value| value }
+ end
+
+ def to_hash
+ returning({}) do |hash|
+ each { |array| hash[array[0]] = array[1] }
+ end
+ end
+ end
+ end
+end
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb
index 3172f62f0d..306376e9ae 100644
--- a/activesupport/lib/active_support/ordered_options.rb
+++ b/activesupport/lib/active_support/ordered_options.rb
@@ -1,47 +1,3 @@
-# OrderedHash is namespaced to prevent conflicts with other implementations
-module ActiveSupport
- # Hash is ordered in Ruby 1.9!
- if RUBY_VERSION >= '1.9'
- OrderedHash = ::Hash
- else
- class OrderedHash < Array #:nodoc:
- def []=(key, value)
- if pair = assoc(key)
- pair.pop
- pair << value
- else
- self << [key, value]
- end
- end
-
- def [](key)
- pair = assoc(key)
- pair ? pair.last : nil
- end
-
- def delete(key)
- pair = assoc(key)
- pair ? array_index = index(pair) : nil
- array_index ? delete_at(array_index).last : nil
- end
-
- def keys
- collect { |key, value| key }
- end
-
- def values
- collect { |key, value| value }
- end
-
- def to_hash
- returning({}) do |hash|
- each { |array| hash[array[0]] = array[1] }
- end
- end
- end
- end
-end
-
class OrderedOptions < ActiveSupport::OrderedHash #:nodoc:
def []=(key, value)
super(key.to_sym, value)
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 21ddcaad48..48606dbcff 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -78,7 +78,7 @@ module ActiveSupport
def to_json(options = nil)
if ActiveSupport.use_standard_json_time_format
- utc.xmlschema.inspect
+ xmlschema.inspect
else
%("#{time.strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
end
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 0fa99135e2..f522b64108 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -325,6 +325,9 @@ class TimeZone
ZONES.sort!
ZONES.freeze
ZONES_MAP.freeze
+
+ US_ZONES = ZONES.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
+ US_ZONES.freeze
end
class << self
@@ -361,14 +364,10 @@ class TimeZone
end
end
- # A regular expression that matches the names of all time zones in
- # the USA.
- US_ZONES = /US|Arizona|Indiana|Hawaii|Alaska/.freeze
-
# A convenience method for returning a collection of TimeZone objects
# for time zones in the USA.
def us_zones
- all.find_all { |z| z.name =~ US_ZONES }
+ US_ZONES
end
end
end
diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb
index 83fbaec62c..f3d141cf72 100644
--- a/activesupport/lib/active_support/version.rb
+++ b/activesupport/lib/active_support/version.rb
@@ -2,7 +2,7 @@ module ActiveSupport
module VERSION #:nodoc:
MAJOR = 2
MINOR = 0
- TINY = 2
+ TINY = 991
STRING = [MAJOR, MINOR, TINY].join('.')
end
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 64fcb4af09..70c393dd46 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -70,7 +70,7 @@ class TimeWithZoneTest < Test::Unit::TestCase
def test_to_json_with_use_standard_json_time_format_config_set_to_true
old, ActiveSupport.use_standard_json_time_format = ActiveSupport.use_standard_json_time_format, true
- assert_equal "\"2000-01-01T00:00:00Z\"", @twz.to_json
+ assert_equal "\"1999-12-31T19:00:00-05:00\"", @twz.to_json
ensure
ActiveSupport.use_standard_json_time_format = old
end
diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb
index 11357e250f..ebfa405947 100644
--- a/activesupport/test/deprecation_test.rb
+++ b/activesupport/test/deprecation_test.rb
@@ -149,13 +149,3 @@ class DeprecationTest < Test::Unit::TestCase
assert_nil @last_message
end
end
-
-class DeprecatedIvarTest < Test::Unit::TestCase
-
- def test_deprecated_ivar
- @action = ActiveSupport::Deprecation::DeprecatedInstanceVariable.new("fubar", :foobar)
-
- assert_deprecated(/Instance variable @foobar is deprecated! Call instance method foobar instead/) { assert_equal "fubar", @action }
- end
-
-end
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
new file mode 100644
index 0000000000..14be48724e
--- /dev/null
+++ b/activesupport/test/ordered_hash_test.rb
@@ -0,0 +1,45 @@
+require 'abstract_unit'
+
+class OrderedHashTest < Test::Unit::TestCase
+ def setup
+ @keys = %w( blue green red pink orange )
+ @values = %w( 000099 009900 aa0000 cc0066 cc6633 )
+ @ordered_hash = ActiveSupport::OrderedHash.new
+
+ @keys.each_with_index do |key, index|
+ @ordered_hash[key] = @values[index]
+ end
+ end
+
+ def test_order
+ assert_equal @keys, @ordered_hash.keys
+ assert_equal @values, @ordered_hash.values
+ end
+
+ def test_access
+ assert @keys.zip(@values).all? { |k, v| @ordered_hash[k] == v }
+ end
+
+ def test_assignment
+ key, value = 'purple', '5422a8'
+
+ @ordered_hash[key] = value
+ assert_equal @keys.length + 1, @ordered_hash.length
+ assert_equal key, @ordered_hash.keys.last
+ assert_equal value, @ordered_hash.values.last
+ assert_equal value, @ordered_hash[key]
+ end
+
+ def test_delete
+ key, value = 'white', 'ffffff'
+ bad_key = 'black'
+
+ @ordered_hash[key] = value
+ assert_equal @keys.length + 1, @ordered_hash.length
+
+ assert_equal value, @ordered_hash.delete(key)
+ assert_equal @keys.length, @ordered_hash.length
+
+ assert_nil @ordered_hash.delete(bad_key)
+ end
+end
diff --git a/activesupport/test/ordered_options_test.rb b/activesupport/test/ordered_options_test.rb
index 3d537a0ae4..fb7a58d0b0 100644
--- a/activesupport/test/ordered_options_test.rb
+++ b/activesupport/test/ordered_options_test.rb
@@ -1,49 +1,5 @@
require 'abstract_unit'
-class OrderedHashTest < Test::Unit::TestCase
- def setup
- @keys = %w( blue green red pink orange )
- @values = %w( 000099 009900 aa0000 cc0066 cc6633 )
- @ordered_hash = ActiveSupport::OrderedHash.new
-
- @keys.each_with_index do |key, index|
- @ordered_hash[key] = @values[index]
- end
- end
-
- def test_order
- assert_equal @keys, @ordered_hash.keys
- assert_equal @values, @ordered_hash.values
- end
-
- def test_access
- assert @keys.zip(@values).all? { |k, v| @ordered_hash[k] == v }
- end
-
- def test_assignment
- key, value = 'purple', '5422a8'
-
- @ordered_hash[key] = value
- assert_equal @keys.length + 1, @ordered_hash.length
- assert_equal key, @ordered_hash.keys.last
- assert_equal value, @ordered_hash.values.last
- assert_equal value, @ordered_hash[key]
- end
-
- def test_delete
- key, value = 'white', 'ffffff'
- bad_key = 'black'
-
- @ordered_hash[key] = value
- assert_equal @keys.length + 1, @ordered_hash.length
-
- assert_equal value, @ordered_hash.delete(key)
- assert_equal @keys.length, @ordered_hash.length
-
- assert_nil @ordered_hash.delete(bad_key)
- end
-end
-
class OrderedOptionsTest < Test::Unit::TestCase
def test_usage
a = OrderedOptions.new