activesupport 5.0.0.beta3 → 5.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +171 -4
  3. data/lib/active_support.rb +12 -0
  4. data/lib/active_support/cache.rb +32 -23
  5. data/lib/active_support/cache/strategy/local_cache.rb +1 -1
  6. data/lib/active_support/callbacks.rb +4 -4
  7. data/lib/active_support/concurrency/share_lock.rb +2 -2
  8. data/lib/active_support/core_ext/array/grouping.rb +6 -10
  9. data/lib/active_support/core_ext/date/conversions.rb +1 -0
  10. data/lib/active_support/core_ext/date_and_time/calculations.rb +2 -0
  11. data/lib/active_support/core_ext/date_and_time/compatibility.rb +18 -0
  12. data/lib/active_support/core_ext/date_time.rb +1 -1
  13. data/lib/active_support/core_ext/date_time/calculations.rb +30 -8
  14. data/lib/active_support/core_ext/date_time/compatibility.rb +5 -0
  15. data/lib/active_support/core_ext/enumerable.rb +16 -0
  16. data/lib/active_support/core_ext/hash/conversions.rb +1 -1
  17. data/lib/active_support/core_ext/hash/keys.rb +1 -1
  18. data/lib/active_support/core_ext/marshal.rb +5 -2
  19. data/lib/active_support/core_ext/module/attribute_accessors.rb +2 -2
  20. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +2 -2
  21. data/lib/active_support/core_ext/module/delegation.rb +2 -5
  22. data/lib/active_support/core_ext/module/introspection.rb +4 -0
  23. data/lib/active_support/core_ext/object/blank.rb +7 -3
  24. data/lib/active_support/core_ext/object/json.rb +6 -0
  25. data/lib/active_support/core_ext/string/conversions.rb +3 -2
  26. data/lib/active_support/core_ext/string/inflections.rb +9 -0
  27. data/lib/active_support/core_ext/string/output_safety.rb +1 -1
  28. data/lib/active_support/core_ext/time.rb +1 -0
  29. data/lib/active_support/core_ext/time/calculations.rb +7 -0
  30. data/lib/active_support/core_ext/time/compatibility.rb +5 -0
  31. data/lib/active_support/dependencies.rb +9 -52
  32. data/lib/active_support/dependencies/interlock.rb +6 -8
  33. data/lib/active_support/deprecation/reporting.rb +0 -1
  34. data/lib/active_support/duration.rb +20 -0
  35. data/lib/active_support/duration/iso8601_parser.rb +122 -0
  36. data/lib/active_support/duration/iso8601_serializer.rb +51 -0
  37. data/lib/active_support/evented_file_update_checker.rb +18 -13
  38. data/lib/active_support/execution_wrapper.rb +117 -0
  39. data/lib/active_support/executor.rb +6 -0
  40. data/lib/active_support/file_update_checker.rb +22 -2
  41. data/lib/active_support/gem_version.rb +1 -1
  42. data/lib/active_support/i18n_railtie.rb +2 -2
  43. data/lib/active_support/inflector/methods.rb +9 -0
  44. data/lib/active_support/number_helper.rb +8 -1
  45. data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -1
  46. data/lib/active_support/number_helper/number_to_phone_converter.rb +11 -2
  47. data/lib/active_support/number_helper/number_to_rounded_converter.rb +5 -3
  48. data/lib/active_support/reloader.rb +129 -0
  49. data/lib/active_support/rescuable.rb +10 -0
  50. data/lib/active_support/time_with_zone.rb +9 -14
  51. data/lib/active_support/values/time_zone.rb +14 -5
  52. metadata +12 -5
  53. data/lib/active_support/core_ext/date_time/zones.rb +0 -6
@@ -126,7 +126,7 @@ module ActiveSupport
126
126
  def set_cache_value(value, name, amount, options) # :nodoc:
127
127
  ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
128
128
  `set_cache_value` is deprecated and will be removed from Rails 5.1.
129
- Please use `write_cache_value`
129
+ Please use `write_cache_value` instead.
130
130
  MESSAGE
131
131
  write_cache_value name, value, options
132
132
  end
@@ -571,15 +571,15 @@ module ActiveSupport
571
571
 
572
572
  # Install a callback for the given event.
573
573
  #
574
- # set_callback :save, :before, :before_meth
575
- # set_callback :save, :after, :after_meth, if: :condition
574
+ # set_callback :save, :before, :before_method
575
+ # set_callback :save, :after, :after_method, if: :condition
576
576
  # set_callback :save, :around, ->(r, block) { stuff; result = block.call; stuff }
577
577
  #
578
578
  # The second argument indicates whether the callback is to be run +:before+,
579
579
  # +:after+, or +:around+ the event. If omitted, +:before+ is assumed. This
580
580
  # means the first example above can also be written as:
581
581
  #
582
- # set_callback :save, :before_meth
582
+ # set_callback :save, :before_method
583
583
  #
584
584
  # The callback can be specified as a symbol naming an instance method; as a
585
585
  # proc, lambda, or block; as a string to be instance evaluated(deprecated); or as an
@@ -782,7 +782,7 @@ module ActiveSupport
782
782
 
783
783
  def display_deprecation_warning_for_false_terminator
784
784
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
785
- Returning `false` in Active Record and Active Model callbacks will not implicitly halt a callback chain in the next release of Rails.
785
+ Returning `false` in Active Record and Active Model callbacks will not implicitly halt a callback chain in Rails 5.1.
786
786
  To explicitly halt the callback chain, please use `throw :abort` instead.
787
787
  MSG
788
788
  end
@@ -144,9 +144,9 @@ module ActiveSupport
144
144
  end
145
145
  compatible |= [false] unless block_share
146
146
  @waiting[Thread.current] = [purpose, compatible]
147
-
148
- @cv.broadcast
149
147
  end
148
+
149
+ @cv.broadcast
150
150
  end
151
151
 
152
152
  begin
@@ -100,17 +100,13 @@ class Array
100
100
  results
101
101
  end
102
102
  else
103
- results, arr = [[]], self.dup
104
- until arr.empty?
105
- if (idx = arr.index(value))
106
- results.last.concat(arr.shift(idx))
107
- arr.shift
108
- results << []
109
- else
110
- results.last.concat(arr.shift(arr.size))
111
- end
103
+ arr = self.dup
104
+ result = []
105
+ while (idx = arr.index(value))
106
+ result << arr.shift(idx)
107
+ arr.shift
112
108
  end
113
- results
109
+ result << arr
114
110
  end
115
111
  end
116
112
  end
@@ -80,6 +80,7 @@ class Date
80
80
  #
81
81
  # date.to_time(:utc) # => 2007-11-10 00:00:00 UTC
82
82
  def to_time(form = :local)
83
+ raise ArgumentError, "Expected :local or :utc, got #{form.inspect}." unless [:local, :utc].include?(form)
83
84
  ::Time.send(form, year, month, day)
84
85
  end
85
86
 
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/try'
2
+
1
3
  module DateAndTime
2
4
  module Calculations
3
5
  DAYS_INTO_WEEK = {
@@ -0,0 +1,18 @@
1
+ require 'active_support/core_ext/module/attribute_accessors'
2
+
3
+ module DateAndTime
4
+ module Compatibility
5
+ # If true, +to_time+ preserves the timezone offset of receiver.
6
+ #
7
+ # NOTE: With Ruby 2.4+ the default for +to_time+ changed from
8
+ # converting to the local system time, to preserving the offset
9
+ # of the receiver. For backwards compatibility we're overriding
10
+ # this behavior, but new apps will have an initializer that sets
11
+ # this to true, because the new behavior is preferred.
12
+ mattr_accessor(:preserve_timezone, instance_writer: false) { false }
13
+
14
+ def to_time
15
+ preserve_timezone ? getlocal(utc_offset) : getlocal
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  require 'active_support/core_ext/date_time/acts_like'
2
2
  require 'active_support/core_ext/date_time/blank'
3
3
  require 'active_support/core_ext/date_time/calculations'
4
+ require 'active_support/core_ext/date_time/compatibility'
4
5
  require 'active_support/core_ext/date_time/conversions'
5
- require 'active_support/core_ext/date_time/zones'
@@ -28,6 +28,13 @@ class DateTime
28
28
  end_of_day.to_i - to_i
29
29
  end
30
30
 
31
+ # Returns the fraction of a second as a +Rational+
32
+ #
33
+ # DateTime.new(2012, 8, 29, 0, 0, 0.5).subsec # => (1/2)
34
+ def subsec
35
+ sec_fraction
36
+ end
37
+
31
38
  # Returns a new DateTime where one or more of the elements have been changed
32
39
  # according to the +options+ parameter. The time options (<tt>:hour</tt>,
33
40
  # <tt>:min</tt>, <tt>:sec</tt>) reset cascadingly, so if only the hour is
@@ -143,14 +150,32 @@ class DateTime
143
150
  end
144
151
  alias :at_end_of_minute :end_of_minute
145
152
 
146
- # Adjusts DateTime to UTC by adding its offset value; offset is set to 0.
153
+ # Returns a <tt>Time</tt> instance of the simultaneous time in the system timezone.
154
+ def localtime(utc_offset = nil)
155
+ utc = new_offset(0)
156
+
157
+ Time.utc(
158
+ utc.year, utc.month, utc.day,
159
+ utc.hour, utc.min, utc.sec + utc.sec_fraction
160
+ ).getlocal(utc_offset)
161
+ end
162
+ alias_method :getlocal, :localtime
163
+
164
+ # Returns a <tt>Time</tt> instance of the simultaneous time in the UTC timezone.
147
165
  #
148
166
  # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)) # => Mon, 21 Feb 2005 10:11:12 -0600
149
- # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)).utc # => Mon, 21 Feb 2005 16:11:12 +0000
167
+ # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)).utc # => Mon, 21 Feb 2005 16:11:12 UTC
150
168
  def utc
151
- new_offset(0)
169
+ utc = new_offset(0)
170
+
171
+ Time.utc(
172
+ utc.year, utc.month, utc.day,
173
+ utc.hour, utc.min, utc.sec + utc.sec_fraction
174
+ )
152
175
  end
176
+ alias_method :getgm, :utc
153
177
  alias_method :getutc, :utc
178
+ alias_method :gmtime, :utc
154
179
 
155
180
  # Returns +true+ if <tt>offset == 0</tt>.
156
181
  def utc?
@@ -165,13 +190,10 @@ class DateTime
165
190
  # Layers additional behavior on DateTime#<=> so that Time and
166
191
  # ActiveSupport::TimeWithZone instances can be compared with a DateTime.
167
192
  def <=>(other)
168
- if other.kind_of?(Infinity)
169
- super
170
- elsif other.respond_to? :to_datetime
193
+ if other.respond_to? :to_datetime
171
194
  super other.to_datetime rescue nil
172
195
  else
173
- nil
196
+ super
174
197
  end
175
198
  end
176
-
177
199
  end
@@ -0,0 +1,5 @@
1
+ require 'active_support/core_ext/date_and_time/compatibility'
2
+
3
+ class DateTime
4
+ prepend DateAndTime::Compatibility
5
+ end
@@ -104,3 +104,19 @@ class Range #:nodoc:
104
104
  end
105
105
  end
106
106
  end
107
+
108
+ # Array#sum was added in Ruby 2.4 but it only works with Numeric elements.
109
+ #
110
+ # We tried shimming it to attempt the fast native method, rescue TypeError,
111
+ # and fall back to the compatible implementation, but that's much slower than
112
+ # just calling the compat method in the first place.
113
+ if Array.instance_methods(false).include?(:sum) && !(%w[a].sum rescue false)
114
+ class Array
115
+ remove_method :sum
116
+
117
+ def sum(*args) #:nodoc:
118
+ # Use Enumerable#sum instead.
119
+ super
120
+ end
121
+ end
122
+ end
@@ -31,7 +31,7 @@ class Hash
31
31
  # with +key+ as <tt>:root</tt>, and +key+ singularized as second argument. The
32
32
  # callable can add nodes by using <tt>options[:builder]</tt>.
33
33
  #
34
- # 'foo'.to_xml(lambda { |options, key| options[:builder].b(key) })
34
+ # {foo: lambda { |options, key| options[:builder].b(key) }}.to_xml
35
35
  # # => "<b>foo</b>"
36
36
  #
37
37
  # * If +value+ responds to +to_xml+ the method is invoked with +key+ as <tt>:root</tt>.
@@ -11,7 +11,7 @@ class Hash
11
11
  # hash.transform_keys.with_index { |k, i| [k, i].join } # => {"name0"=>"Rob", "age1"=>"28"}
12
12
  def transform_keys
13
13
  return enum_for(:transform_keys) { size } unless block_given?
14
- result = self.class.new
14
+ result = {}
15
15
  each_key do |key|
16
16
  result[yield(key)] = self[key]
17
17
  end
@@ -3,9 +3,12 @@ module ActiveSupport
3
3
  def load(source)
4
4
  super(source)
5
5
  rescue ArgumentError, NameError => exc
6
- if exc.message.match(%r|undefined class/module (.+)|)
6
+ if exc.message.match(%r|undefined class/module (.+?)(?:::)?\z|)
7
7
  # try loading the class/module
8
- $1.constantize
8
+ loaded = $1.constantize
9
+
10
+ raise unless $1 == loaded.name
11
+
9
12
  # if it is an IO we need to go back to read the object
10
13
  source.rewind if source.respond_to?(:rewind)
11
14
  retry
@@ -27,7 +27,7 @@ class Module
27
27
  # <tt>instance_reader: false</tt> or <tt>instance_accessor: false</tt>.
28
28
  #
29
29
  # module HairColors
30
- # mattr_writer :hair_colors, instance_reader: false
30
+ # mattr_reader :hair_colors, instance_reader: false
31
31
  # end
32
32
  #
33
33
  # class Person
@@ -40,7 +40,7 @@ class Module
40
40
  # Also, you can pass a block to set up the attribute with a default value.
41
41
  #
42
42
  # module HairColors
43
- # cattr_reader :hair_colors do
43
+ # mattr_reader :hair_colors do
44
44
  # [:brown, :black, :blonde, :red]
45
45
  # end
46
46
  # end
@@ -47,7 +47,7 @@ class Module
47
47
  unless options[:instance_reader] == false || options[:instance_accessor] == false
48
48
  class_eval(<<-EOS, __FILE__, __LINE__ + 1)
49
49
  def #{sym}
50
- Thread.current[:"attr_#{self.class.name}_#{sym}"]
50
+ Thread.current[:"attr_#{name}_#{sym}"]
51
51
  end
52
52
  EOS
53
53
  end
@@ -86,7 +86,7 @@ class Module
86
86
  unless options[:instance_writer] == false || options[:instance_accessor] == false
87
87
  class_eval(<<-EOS, __FILE__, __LINE__ + 1)
88
88
  def #{sym}=(obj)
89
- Thread.current[:"attr_#{self.class.name}_#{sym}"] = obj
89
+ Thread.current[:"attr_#{name}_#{sym}"] = obj
90
90
  end
91
91
  EOS
92
92
  end
@@ -149,14 +149,11 @@ class Module
149
149
  #
150
150
  # The target method must be public, otherwise it will raise +NoMethodError+.
151
151
  #
152
- def delegate(*methods)
153
- options = methods.pop
154
- unless options.is_a?(Hash) && to = options[:to]
152
+ def delegate(*methods, to: nil, prefix: nil, allow_nil: nil)
153
+ unless to
155
154
  raise ArgumentError, 'Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, to: :greeter).'
156
155
  end
157
156
 
158
- prefix, allow_nil = options.values_at(:prefix, :allow_nil)
159
-
160
157
  if prefix == true && to =~ /^[^a-z_]/
161
158
  raise ArgumentError, 'Can only automatically set the delegation prefix when delegating to a method.'
162
159
  end
@@ -57,6 +57,10 @@ class Module
57
57
  end
58
58
 
59
59
  def local_constants #:nodoc:
60
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
61
+ Module#local_constants is deprecated and will be removed in Rails 5.1.
62
+ Use Module#constants(false) instead.
63
+ MSG
60
64
  constants(false)
61
65
  end
62
66
  end
@@ -97,8 +97,6 @@ class Hash
97
97
  end
98
98
 
99
99
  class String
100
- BLANK_RE = /\A[[:space:]]*\z/
101
-
102
100
  # A string is blank if it's empty or contains whitespaces only:
103
101
  #
104
102
  # ''.blank? # => true
@@ -112,7 +110,13 @@ class String
112
110
  #
113
111
  # @return [true, false]
114
112
  def blank?
115
- BLANK_RE === self
113
+ # The regexp that matches blank strings is expensive. For the case of empty
114
+ # strings we can speed up this method (~3.5x) with an empty? call. The
115
+ # penalty for the rest of strings is marginal.
116
+ #
117
+ # Double negation in the second operand is also a performance tweak, it is
118
+ # faster than the positive \A[[:space:]]*\z.
119
+ empty? || !(/[[:^space:]]/ === self)
116
120
  end
117
121
  end
118
122
 
@@ -197,3 +197,9 @@ class Process::Status #:nodoc:
197
197
  { :exitstatus => exitstatus, :pid => pid }
198
198
  end
199
199
  end
200
+
201
+ class Exception
202
+ def as_json(options = nil)
203
+ to_s
204
+ end
205
+ end
@@ -18,7 +18,8 @@ class String
18
18
  # "12/13/2012".to_time # => ArgumentError: argument out of range
19
19
  def to_time(form = :local)
20
20
  parts = Date._parse(self, false)
21
- return if parts.empty?
21
+ used_keys = %i(year mon mday hour min sec sec_fraction offset)
22
+ return if (parts.keys & used_keys).empty?
22
23
 
23
24
  now = Time.now
24
25
  time = Time.new(
@@ -31,7 +32,7 @@ class String
31
32
  parts.fetch(:offset, form == :utc ? 0 : nil)
32
33
  )
33
34
 
34
- form == :utc ? time.utc : time.getlocal
35
+ form == :utc ? time.utc : time.to_time
35
36
  end
36
37
 
37
38
  # Converts a string to a Date value.
@@ -222,6 +222,15 @@ class String
222
222
  ActiveSupport::Inflector.humanize(self, options)
223
223
  end
224
224
 
225
+ # Converts just the first character to uppercase.
226
+ #
227
+ # 'what a Lovely Day'.upcase_first # => "What a Lovely Day"
228
+ # 'w'.upcase_first # => "W"
229
+ # ''.upcase_first # => ""
230
+ def upcase_first
231
+ ActiveSupport::Inflector.upcase_first(self)
232
+ end
233
+
225
234
  # Creates a foreign key name from a class name.
226
235
  # +separate_class_name_and_id_with_underscore+ sets whether
227
236
  # the method should put '_' between the name and 'id'.
@@ -250,7 +250,7 @@ end
250
250
 
251
251
  class String
252
252
  # Marks a string as trusted safe. It will be inserted into HTML with no
253
- # additional escaping performed. It is your responsibilty to ensure that the
253
+ # additional escaping performed. It is your responsibility to ensure that the
254
254
  # string contains no malicious content. This method is equivalent to the
255
255
  # `raw` helper in views. It is recommended that you use `sanitize` instead of
256
256
  # this method. It should never be called on user input.
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/time/acts_like'
2
2
  require 'active_support/core_ext/time/calculations'
3
+ require 'active_support/core_ext/time/compatibility'
3
4
  require 'active_support/core_ext/time/conversions'
4
5
  require 'active_support/core_ext/time/zones'
@@ -73,6 +73,13 @@ class Time
73
73
  end_of_day.to_i - to_i
74
74
  end
75
75
 
76
+ # Returns the fraction of a second as a +Rational+
77
+ #
78
+ # Time.new(2012, 8, 29, 0, 0, 0.5).sec_fraction # => (1/2)
79
+ def sec_fraction
80
+ subsec
81
+ end
82
+
76
83
  # Returns a new Time where one or more of the elements have been changed according
77
84
  # to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
78
85
  # <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only
@@ -0,0 +1,5 @@
1
+ require 'active_support/core_ext/date_and_time/compatibility'
2
+
3
+ class Time
4
+ prepend DateAndTime::Compatibility
5
+ end
@@ -88,15 +88,6 @@ module ActiveSupport #:nodoc:
88
88
  mattr_accessor :explicitly_unloadable_constants
89
89
  self.explicitly_unloadable_constants = []
90
90
 
91
- # The logger is used for generating information on the action run-time
92
- # (including benchmarking) if available. Can be set to nil for no logging.
93
- # Compatible with both Ruby's own Logger and Log4r loggers.
94
- mattr_accessor :logger
95
-
96
- # Set to +true+ to enable logging of const_missing and file loads.
97
- mattr_accessor :log_activity
98
- self.log_activity = false
99
-
100
91
  # The WatchStack keeps a stack of the modules being watched as files are
101
92
  # loaded. If a file in the process of being loaded (parent.rb) triggers the
102
93
  # load of another file (child.rb) the stack will ensure that child.rb
@@ -143,7 +134,7 @@ module ActiveSupport #:nodoc:
143
134
  next unless mod.is_a?(Module)
144
135
 
145
136
  # Get a list of the constants that were added
146
- new_constants = mod.local_constants - original_constants
137
+ new_constants = mod.constants(false) - original_constants
147
138
 
148
139
  # @stack[namespace] returns an Array of the constants that are being evaluated
149
140
  # for that namespace. For instance, if parent.rb requires child.rb, the first
@@ -171,7 +162,7 @@ module ActiveSupport #:nodoc:
171
162
  @watching << namespaces.map do |namespace|
172
163
  module_name = Dependencies.to_constant_name(namespace)
173
164
  original_constants = Dependencies.qualified_const_defined?(module_name) ?
174
- Inflector.constantize(module_name).local_constants : []
165
+ Inflector.constantize(module_name).constants(false) : []
175
166
 
176
167
  @stack[module_name] << original_constants
177
168
  module_name
@@ -352,7 +343,6 @@ module ActiveSupport #:nodoc:
352
343
  end
353
344
 
354
345
  def clear
355
- log_call
356
346
  Dependencies.unload_interlock do
357
347
  loaded.clear
358
348
  loading.clear
@@ -361,7 +351,6 @@ module ActiveSupport #:nodoc:
361
351
  end
362
352
 
363
353
  def require_or_load(file_name, const_path = nil)
364
- log_call file_name, const_path
365
354
  file_name = $` if file_name =~ /\.rb\z/
366
355
  expanded = File.expand_path(file_name)
367
356
  return if loaded.include?(expanded)
@@ -377,8 +366,6 @@ module ActiveSupport #:nodoc:
377
366
 
378
367
  begin
379
368
  if load?
380
- log "loading #{file_name}"
381
-
382
369
  # Enable warnings if this file has not been loaded before and
383
370
  # warnings_on_first_load is set.
384
371
  load_args = ["#{file_name}.rb"]
@@ -390,7 +377,6 @@ module ActiveSupport #:nodoc:
390
377
  enable_warnings { result = load_file(*load_args) }
391
378
  end
392
379
  else
393
- log "requiring #{file_name}"
394
380
  result = require file_name
395
381
  end
396
382
  rescue Exception
@@ -483,7 +469,6 @@ module ActiveSupport #:nodoc:
483
469
  # set of names that the file at +path+ may define. See
484
470
  # +loadable_constants_for_path+ for more details.
485
471
  def load_file(path, const_paths = loadable_constants_for_path(path))
486
- log_call path, const_paths
487
472
  const_paths = [const_paths].compact unless const_paths.is_a? Array
488
473
  parent_paths = const_paths.collect { |const_path| const_path[/.*(?=::)/] || ::Object }
489
474
 
@@ -494,7 +479,6 @@ module ActiveSupport #:nodoc:
494
479
 
495
480
  autoloaded_constants.concat newly_defined_paths unless load_once_path?(path)
496
481
  autoloaded_constants.uniq!
497
- log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty?
498
482
  result
499
483
  end
500
484
 
@@ -508,8 +492,6 @@ module ActiveSupport #:nodoc:
508
492
  # it is not possible to load the constant into from_mod, try its parent
509
493
  # module using +const_missing+.
510
494
  def load_missing_constant(from_mod, const_name)
511
- log_call from_mod, const_name
512
-
513
495
  unless qualified_const_defined?(from_mod.name) && Inflector.constantize(from_mod.name).equal?(from_mod)
514
496
  raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!"
515
497
  end
@@ -673,25 +655,20 @@ module ActiveSupport #:nodoc:
673
655
  # exception, any new constants are regarded as being only partially defined
674
656
  # and will be removed immediately.
675
657
  def new_constants_in(*descs)
676
- log_call(*descs)
677
-
678
658
  constant_watch_stack.watch_namespaces(descs)
679
- aborting = true
659
+ success = false
680
660
 
681
661
  begin
682
662
  yield # Now yield to the code that is to define new constants.
683
- aborting = false
663
+ success = true
684
664
  ensure
685
665
  new_constants = constant_watch_stack.new_constants
686
666
 
687
- log "New constants: #{new_constants * ', '}"
688
- return new_constants unless aborting
667
+ return new_constants if success
689
668
 
690
- log "Error during loading, removing partially loaded constants "
691
- new_constants.each { |c| remove_constant(c) }.clear
669
+ # Remove partially loaded constants.
670
+ new_constants.each { |c| remove_constant(c) }
692
671
  end
693
-
694
- []
695
672
  end
696
673
 
697
674
  # Convert the provided const desc to a qualified constant name (as a string).
@@ -738,8 +715,6 @@ module ActiveSupport #:nodoc:
738
715
  parent = constantize(parent_name)
739
716
  end
740
717
 
741
- log "removing constant #{const}"
742
-
743
718
  # In an autoloaded user.rb like this
744
719
  #
745
720
  # autoload :Foo, 'foo'
@@ -760,7 +735,7 @@ module ActiveSupport #:nodoc:
760
735
  begin
761
736
  constantized = parent.const_get(to_remove, false)
762
737
  rescue NameError
763
- log "the constant #{const} is not reachable anymore, skipping"
738
+ # The constant is no longer reachable, just skip it.
764
739
  return
765
740
  else
766
741
  constantized.before_remove_const if constantized.respond_to?(:before_remove_const)
@@ -770,27 +745,9 @@ module ActiveSupport #:nodoc:
770
745
  begin
771
746
  parent.instance_eval { remove_const to_remove }
772
747
  rescue NameError
773
- log "the constant #{const} is not reachable anymore, skipping"
748
+ # The constant is no longer reachable, just skip it.
774
749
  end
775
750
  end
776
-
777
- protected
778
- def log_call(*args)
779
- if log_activity?
780
- arg_str = args.collect(&:inspect) * ', '
781
- /in `([a-z_\?\!]+)'/ =~ caller(1).first
782
- selector = $1 || '<unknown>'
783
- log "called #{selector}(#{arg_str})"
784
- end
785
- end
786
-
787
- def log(msg)
788
- logger.debug "Dependencies: #{msg}" if log_activity?
789
- end
790
-
791
- def log_activity?
792
- logger && log_activity
793
- end
794
751
  end
795
752
  end
796
753