diff options
Diffstat (limited to 'activesupport/lib/active_support')
9 files changed, 110 insertions, 42 deletions
diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb index f3e4b8c13b..c1a713b4c5 100644 --- a/activesupport/lib/active_support/cache/memory_store.rb +++ b/activesupport/lib/active_support/cache/memory_store.rb @@ -3,63 +3,35 @@ module ActiveSupport class MemoryStore < Store def initialize @data = {} - @guard = Monitor.new - end - - def fetch(key, options = {}) - @guard.synchronize do - super - end end def read(name, options = nil) - @guard.synchronize do - super - @data[name] - end + super + @data[name] end def write(name, value, options = nil) - @guard.synchronize do - super - @data[name] = value.freeze - end + super + @data[name] = value.freeze end def delete(name, options = nil) - @guard.synchronize do - @data.delete(name) - end + super + @data.delete(name) end def delete_matched(matcher, options = nil) - @guard.synchronize do - @data.delete_if { |k,v| k =~ matcher } - end + super + @data.delete_if { |k,v| k =~ matcher } end def exist?(name,options = nil) - @guard.synchronize do - @data.has_key?(name) - end - end - - def increment(key, amount = 1) - @guard.synchronize do - super - end - end - - def decrement(key, amount = 1) - @guard.synchronize do - super - end + super + @data.has_key?(name) end def clear - @guard.synchronize do - @data.clear - end + @data.clear end end end diff --git a/activesupport/lib/active_support/cache/synchronized_memory_store.rb b/activesupport/lib/active_support/cache/synchronized_memory_store.rb new file mode 100644 index 0000000000..d2ff28768f --- /dev/null +++ b/activesupport/lib/active_support/cache/synchronized_memory_store.rb @@ -0,0 +1,46 @@ +module ActiveSupport + module Cache + class SynchronizedMemoryStore < MemoryStore + def initialize + super + @guard = Monitor.new + end + + def fetch(key, options = {}) + @guard.synchronize { super } + end + + def read(name, options = nil) + @guard.synchronize { super } + end + + def write(name, value, options = nil) + @guard.synchronize { super } + end + + def delete(name, options = nil) + @guard.synchronize { super } + end + + def delete_matched(matcher, options = nil) + @guard.synchronize { super } + end + + def exist?(name,options = nil) + @guard.synchronize { super } + end + + def increment(key, amount = 1) + @guard.synchronize { super } + end + + def decrement(key, amount = 1) + @guard.synchronize { super } + end + + def clear + @guard.synchronize { super } + end + end + end +end diff --git a/activesupport/lib/active_support/core_ext/hash/except.rb b/activesupport/lib/active_support/core_ext/hash/except.rb index f26d01553d..949976d741 100644 --- a/activesupport/lib/active_support/core_ext/hash/except.rb +++ b/activesupport/lib/active_support/core_ext/hash/except.rb @@ -10,7 +10,7 @@ module ActiveSupport #:nodoc: module Except # Returns a new hash without the given keys. def except(*keys) - clone.except!(*keys) + dup.except!(*keys) end # Replaces the hash without the given keys. diff --git a/activesupport/lib/active_support/core_ext/string.rb b/activesupport/lib/active_support/core_ext/string.rb index 25386af70a..7ff2f11eff 100644 --- a/activesupport/lib/active_support/core_ext/string.rb +++ b/activesupport/lib/active_support/core_ext/string.rb @@ -6,6 +6,7 @@ require 'active_support/core_ext/string/iterators' require 'active_support/core_ext/string/unicode' require 'active_support/core_ext/string/xchar' require 'active_support/core_ext/string/filters' +require 'active_support/core_ext/string/behavior' class String #:nodoc: include ActiveSupport::CoreExtensions::String::Access @@ -15,4 +16,5 @@ class String #:nodoc: include ActiveSupport::CoreExtensions::String::StartsEndsWith include ActiveSupport::CoreExtensions::String::Iterators include ActiveSupport::CoreExtensions::String::Unicode + include ActiveSupport::CoreExtensions::String::Behavior end diff --git a/activesupport/lib/active_support/core_ext/string/behavior.rb b/activesupport/lib/active_support/core_ext/string/behavior.rb new file mode 100644 index 0000000000..a93ca3027f --- /dev/null +++ b/activesupport/lib/active_support/core_ext/string/behavior.rb @@ -0,0 +1,13 @@ +module ActiveSupport #:nodoc: + module CoreExtensions #:nodoc: + module String #:nodoc: + module Behavior + # Enable more predictable duck-typing on String-like classes. See + # Object#acts_like?. + def acts_like_string? + true + end + end + end + end +end
\ No newline at end of file diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index e5f0063285..8a917a9eb2 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -257,7 +257,7 @@ module ActiveSupport # <%= link_to(@person.name, person_path %> # # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a> def parameterize(string, sep = '-') - string.gsub(/[^a-z0-9]+/i, sep).downcase + string.chars.normalize(:kd).to_s.gsub(/[^\x00-\x7F]+/, '').gsub(/[^a-z0-9_\-]+/i, sep).downcase end # Create the name of a table like Rails does for models to table names. This method diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 185d03020c..de2c83f8d1 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -49,6 +49,11 @@ module ActiveSupport::Multibyte #:nodoc: false end + # Enable more predictable duck-typing on String-like classes. See Object#acts_like?. + def acts_like_string? + true + end + # Create a new Chars instance. def initialize(str) @string = str.respond_to?(:string) ? str.string : str diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 788d40bfa8..a294dd0ba3 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -124,7 +124,7 @@ module ActiveSupport "Kathmandu" => "Asia/Katmandu", "Astana" => "Asia/Dhaka", "Dhaka" => "Asia/Dhaka", - "Sri Jayawardenepura" => "Asia/Dhaka", + "Sri Jayawardenepura" => "Asia/Colombo", "Almaty" => "Asia/Almaty", "Novosibirsk" => "Asia/Novosibirsk", "Rangoon" => "Asia/Rangoon", diff --git a/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Colombo.rb b/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Colombo.rb new file mode 100644 index 0000000000..f6531fa819 --- /dev/null +++ b/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Colombo.rb @@ -0,0 +1,30 @@ +require 'tzinfo/timezone_definition' + +module TZInfo + module Definitions + module Asia + module Colombo + include TimezoneDefinition + + timezone 'Asia/Colombo' do |tz| + tz.offset :o0, 19164, 0, :LMT + tz.offset :o1, 19172, 0, :MMT + tz.offset :o2, 19800, 0, :IST + tz.offset :o3, 19800, 1800, :IHST + tz.offset :o4, 19800, 3600, :IST + tz.offset :o5, 23400, 0, :LKT + tz.offset :o6, 21600, 0, :LKT + + tz.transition 1879, 12, :o1, 17335550003, 7200 + tz.transition 1905, 12, :o2, 52211763607, 21600 + tz.transition 1942, 1, :o3, 116657485, 48 + tz.transition 1942, 8, :o4, 9722413, 4 + tz.transition 1945, 10, :o2, 38907909, 16 + tz.transition 1996, 5, :o5, 832962600 + tz.transition 1996, 10, :o6, 846266400 + tz.transition 2006, 4, :o2, 1145039400 + end + end + end + end +end |