From b60c8a573e63998b4aa3f93a1728bb9b6c6fb8f9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 11 May 2008 18:29:44 -0500 Subject: Making ready for RC1 release --- activesupport/lib/active_support/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') 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 -- cgit v1.2.3 From 828914a062d3fd6cd51ebd3881acea11eede45cc Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 10 May 2008 10:47:06 -0500 Subject: Ruby 1.9 compat: define __setobj__ for Delegator --- activesupport/lib/active_support/deprecation.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 7613652c71..e01ec92660 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -178,15 +178,19 @@ module ActiveSupport class DeprecatedInstanceVariable < Delegator #:nodoc: def initialize(value, method) - super(value) @method = method - @value = value + super(value) + __setobj__(value) end def __getobj__ ActiveSupport::Deprecation.warn("Instance variable @#{@method} is deprecated! Call instance method #{@method} instead.") @value end + + def __setobj__(value) + @value = value + end end end -- cgit v1.2.3 From f2e4bf218f95ab279e1a1527c37115faf65ac283 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 10 May 2008 10:47:49 -0500 Subject: Use #duplicable? instead of anonymous rescue --- .../lib/active_support/core_ext/class/inheritable_attributes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') 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 -- cgit v1.2.3 From 2270371f5dbabdd25ffcc59389249a795ba324a1 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 13 May 2008 10:39:45 +0100 Subject: Remove unnecessary DeprecatedInstanceVariable class --- activesupport/lib/active_support/deprecation.rb | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index e01ec92660..6aa379b550 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -176,23 +176,6 @@ module ActiveSupport end end - class DeprecatedInstanceVariable < Delegator #:nodoc: - def initialize(value, method) - @method = method - super(value) - __setobj__(value) - end - - def __getobj__ - ActiveSupport::Deprecation.warn("Instance variable @#{@method} is deprecated! Call instance method #{@method} instead.") - @value - end - - def __setobj__(value) - @value = value - end - end - end end -- cgit v1.2.3 From f498f221bdd88a04458f56ee917c360bca833e94 Mon Sep 17 00:00:00 2001 From: Daniel Morrison Date: Mon, 12 May 2008 22:02:04 -0400 Subject: Include time zone offset in TimeWithZone#to_json --- activesupport/lib/active_support/time_with_zone.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') 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 -- cgit v1.2.3 From 49846f85864f4b59d5593c30ee3c59b584d2975d Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 14 May 2008 12:48:37 -0500 Subject: Create a seperate file for ActiveSupport::OrderedHash. --- activesupport/lib/active_support.rb | 1 + activesupport/lib/active_support/ordered_hash.rb | 43 +++++++++++++++++++++ .../lib/active_support/ordered_options.rb | 44 ---------------------- 3 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 activesupport/lib/active_support/ordered_hash.rb (limited to 'activesupport/lib') 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/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) -- cgit v1.2.3 From fc02eabf296d6edb74a95174c7322293a54c9492 Mon Sep 17 00:00:00 2001 From: Martin Eisenhardt Date: Thu, 15 May 2008 09:21:43 -0500 Subject: Precompute TimeZone.us_zones [#199 state:resolved] Signed-off-by: Joshua Peek --- activesupport/lib/active_support/values/time_zone.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'activesupport/lib') 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 -- cgit v1.2.3