From cbd2111c67b1603c97c00ebbd5f6f67e4b24eebd Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Mon, 12 Aug 2013 11:43:42 +0200 Subject: Rely on NoMethodError#name when deciding to raise DelegationError. Different Ruby implementations present backtraces differently, as it should be an information consumed by humans. A better implementation should use data from the error, in this case returned by NoMethodError#name. Fixes issues with Rubinius, which presents backtraces differently from MRI. --- activesupport/lib/active_support/core_ext/module/delegation.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index bca3800344..182e74d9e1 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -192,8 +192,7 @@ class Module _ = #{to} # _ = client _.#{method}(#{definition}) # _.name(*args, &block) rescue NoMethodError => e # rescue NoMethodError => e - location = "%s:%d:in `%s'" % [__FILE__, __LINE__ - 2, '#{method_prefix}#{method}'] # location = "%s:%d:in `%s'" % [__FILE__, __LINE__ - 2, 'customer_name'] - if _.nil? && e.backtrace.first == location # if _.nil? && e.backtrace.first == location + if _.nil? && e.name == :#{method} # if _.nil? && e.name == :name #{exception} # # add helpful message to the exception else # else raise # raise -- cgit v1.2.3 From 7193f750ffe0276a16b3703f4cf05e7b36e7df7b Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sun, 18 Aug 2013 17:02:25 -0500 Subject: Rename @locals to @_locals in Thread to avoid conflict with Rubinius. Closes #11831 --- activesupport/lib/active_support/core_ext/thread.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/thread.rb b/activesupport/lib/active_support/core_ext/thread.rb index 5481766f10..de752f14ef 100644 --- a/activesupport/lib/active_support/core_ext/thread.rb +++ b/activesupport/lib/active_support/core_ext/thread.rb @@ -23,14 +23,14 @@ class Thread # for the fiber local. The fiber is executed in the same thread, so the # thread local values are available. def thread_variable_get(key) - locals[key.to_sym] + _locals[key.to_sym] end # Sets a thread local with +key+ to +value+. Note that these are local to # threads, and not to fibers. Please see Thread#thread_variable_get for # more information. def thread_variable_set(key, value) - locals[key.to_sym] = value + _locals[key.to_sym] = value end # Returns an an array of the names of the thread-local variables (as Symbols). @@ -45,7 +45,7 @@ class Thread # Note that these are not fiber local variables. Please see Thread#thread_variable_get # for more details. def thread_variables - locals.keys + _locals.keys end # Returns true if the given string (or symbol) exists as a @@ -59,16 +59,16 @@ class Thread # Note that these are not fiber local variables. Please see Thread#thread_variable_get # for more details. def thread_variable?(key) - locals.has_key?(key.to_sym) + _locals.has_key?(key.to_sym) end private - def locals + def _locals if defined?(@locals) - @locals + @_locals else - LOCK.synchronize { @locals ||= {} } + LOCK.synchronize { @_locals ||= {} } end end end unless Thread.instance_methods.include?(:thread_variable_set) -- cgit v1.2.3 From 48c8135423dd7a8ff676b858cad6795a15903826 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 18 Aug 2013 16:52:15 -0700 Subject: duration is called multiple times in dev, so lets cache it --- activesupport/lib/active_support/notifications/instrumenter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 0c9a729ce5..3a244b34b5 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -54,10 +54,11 @@ module ActiveSupport @transaction_id = transaction_id @end = ending @children = [] + @duration = nil end def duration - 1000.0 * (self.end - time) + @duration ||= 1000.0 * (self.end - time) end def <<(event) -- cgit v1.2.3 From 726001485005629b155240fe85f8a011f15d6b84 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sun, 18 Aug 2013 19:47:33 -0500 Subject: oops, I missed this in 7193f75 --- activesupport/lib/active_support/core_ext/thread.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/thread.rb b/activesupport/lib/active_support/core_ext/thread.rb index de752f14ef..878ec73ef0 100644 --- a/activesupport/lib/active_support/core_ext/thread.rb +++ b/activesupport/lib/active_support/core_ext/thread.rb @@ -65,7 +65,7 @@ class Thread private def _locals - if defined?(@locals) + if defined?(@_locals) @_locals else LOCK.synchronize { @_locals ||= {} } -- cgit v1.2.3 From dfb923e6e52d1fed768672b5b7e6277a599f136a Mon Sep 17 00:00:00 2001 From: Nick Howard Date: Mon, 19 Aug 2013 12:39:40 -0600 Subject: ensure freeze on Thread freezes locals --- activesupport/lib/active_support/core_ext/thread.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/thread.rb b/activesupport/lib/active_support/core_ext/thread.rb index 878ec73ef0..e80f442973 100644 --- a/activesupport/lib/active_support/core_ext/thread.rb +++ b/activesupport/lib/active_support/core_ext/thread.rb @@ -62,6 +62,11 @@ class Thread _locals.has_key?(key.to_sym) end + def freeze + _locals.freeze + super + end + private def _locals -- cgit v1.2.3 From 3fd134c5594a4c05934a41bb66db4048ab5e3cb9 Mon Sep 17 00:00:00 2001 From: wangjohn Date: Sat, 24 Aug 2013 23:33:56 -0400 Subject: Changing deprecation_horizon to be Rails 4.2 Also, +ActiveRecord::Migrator.proper_table_name+ should actually have a deprecation horizon of Rails 4.2 (not 4.1). --- activesupport/lib/active_support/deprecation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 0281c9222e..ab16977bda 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -32,7 +32,7 @@ module ActiveSupport # and the second is a library name # # ActiveSupport::Deprecation.new('2.0', 'MyLibrary') - def initialize(deprecation_horizon = '4.1', gem_name = 'Rails') + def initialize(deprecation_horizon = '4.2', gem_name = 'Rails') self.gem_name = gem_name self.deprecation_horizon = deprecation_horizon # By default, warnings are not silenced and debugging is off. -- cgit v1.2.3 From b4a96686267c8bb261eca21c02acab9fd5f7ca96 Mon Sep 17 00:00:00 2001 From: Simon Coffey Date: Fri, 26 Jul 2013 17:37:00 +0100 Subject: Ensure all-caps nested consts marked as autoloaded Previously, an autoloaded constant `HTML::SomeClass` would not be marked as autoloaded by AS::Dependencies. This is because the `#loadable_constants_for_path` method uses `String#camelize` on the inferred file path, which in turn means that, unless otherwise directed, AS::Dependencies watches for loaded constants in the `Html` namespace. By passing the original qualified constant name to `#load_or_require`, this inference step is avoided, and the new constant is picked up in the correct namespace. --- activesupport/lib/active_support/dependencies.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 73559bfe0e..db9f5d4baa 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -459,7 +459,7 @@ module ActiveSupport #:nodoc: if loaded.include?(expanded) raise "Circular dependency detected while autoloading constant #{qualified_name}" else - require_or_load(expanded) + require_or_load(expanded, qualified_name) raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" unless from_mod.const_defined?(const_name, false) return from_mod.const_get(const_name) end -- cgit v1.2.3 From 63949ae0122afcad084c01b56dd0c1640322c75d Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Tue, 27 Aug 2013 20:02:21 +0530 Subject: Fix doc for singularize - `pluralized` => `singularized` --- activesupport/lib/active_support/inflector/methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index d063fcb49c..ffdb7b53c4 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -36,7 +36,7 @@ module ActiveSupport # string. # # If passed an optional +locale+ parameter, the word will be - # pluralized using rules defined for that language. By default, + # singularized using rules defined for that language. By default, # this parameter is set to :en. # # 'posts'.singularize # => "post" -- cgit v1.2.3 From adbe8b18b8eb7b50a2eb5ca925c39b6a3c100cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 26 Aug 2013 13:47:09 -0300 Subject: Remove gist link from the code It is not good to include links in the code. These links can be in the future outdated and nobody will upgrade they. [ci skip] --- activesupport/lib/active_support/cache/memory_store.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb index b979521c99..34ac91334a 100644 --- a/activesupport/lib/active_support/cache/memory_store.rb +++ b/activesupport/lib/active_support/cache/memory_store.rb @@ -124,7 +124,6 @@ module ActiveSupport protected - # See https://gist.github.com/ssimeonov/6047200 PER_ENTRY_OVERHEAD = 240 def cached_size(key, entry) -- cgit v1.2.3