activesupport 5.0.0.beta2 → 5.0.0.beta3

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: feeceb08e3de4f23beb469414fac32aa949de4ca
4
- data.tar.gz: ed224db38f3a6524c78cd4833484eb93d4a4cc4f
3
+ metadata.gz: 4a5dea5a1bb0a9929afd19a9a16bf8c82cdc97a3
4
+ data.tar.gz: fd271c0c13149c6029f3b876f70b4463959cd5a5
5
5
  SHA512:
6
- metadata.gz: 2714c0f5258a1d8678f750cf4ec835f033db1a999652e439f958b5077d1b10bbec05323366393b2b7db06bcc049f01a4111e2a7aa8a82f7dd236523254bb586d
7
- data.tar.gz: 5dca3370c49f9d30af666064201f536cec39a49c2864fb3ccbaf56a1ab9c42fe0de7e6baca81b669873ed41471367a83271d338ccb8ace0f29aae812a051a4b4
6
+ metadata.gz: b97891236c826598c8b68c32104e7f39e08004cbd365c75fd3fce1214c535193a13bfb6a836788b7959ca7960838abc306b5220e0b36fdfe45aef163ff4c4ae7
7
+ data.tar.gz: d2d0aa34eb7dcdb0845735b6961a5d132ebe1f5d382de5c503b551dc040272fd35a00ca456ba9a5c103c992632277bf1874f8e3ccded9f11688decd1693f48f3
@@ -1,3 +1,33 @@
1
+ ## Rails 5.0.0.beta3 (February 24, 2016) ##
2
+
3
+ * Deprecate arguments on `assert_nothing_raised`.
4
+
5
+ `assert_nothing_raised` does not assert the arguments that have been passed
6
+ in (usually a specific exception class) since the method only yields the
7
+ block. So as not to confuse the users that the arguments have meaning, they
8
+ are being deprecated.
9
+
10
+ *Tara Scherner de la Fuente*
11
+
12
+ * Make `benchmark('something', silence: true)` actually work
13
+
14
+ *DHH*
15
+
16
+ * Add `#on_weekday?` method to `Date`, `Time`, and `DateTime`.
17
+
18
+ `#on_weekday?` returns `true` if the receiving date/time does not fall on a Saturday
19
+ or Sunday.
20
+
21
+ *Vipul A M*
22
+
23
+ * Add `Array#second_to_last` and `Array#third_to_last` methods.
24
+
25
+ *Brian Christian*
26
+
27
+ * Fix regression in `Hash#dig` for HashWithIndifferentAccess.
28
+
29
+ *Jon Moss*
30
+
1
31
  ## Rails 5.0.0.beta2 (February 01, 2016) ##
2
32
 
3
33
  * Change number_to_currency behavior for checking negativity.
@@ -38,7 +38,7 @@ module ActiveSupport
38
38
  options[:level] ||= :info
39
39
 
40
40
  result = nil
41
- ms = Benchmark.ms { result = options[:silence] ? silence { yield } : yield }
41
+ ms = Benchmark.ms { result = options[:silence] ? logger.silence { yield } : yield }
42
42
  logger.send(options[:level], '%s (%.1fms)' % [ message, ms ])
43
43
  result
44
44
  else
@@ -333,21 +333,19 @@ module ActiveSupport
333
333
  options = names.extract_options!
334
334
  options = merged_options(options)
335
335
 
336
- instrument_multi(:read, names, options) do |payload|
337
- results = {}
338
- names.each do |name|
339
- key = normalize_key(name, options)
340
- entry = read_entry(key, options)
341
- if entry
342
- if entry.expired?
343
- delete_entry(key, options)
344
- else
345
- results[name] = entry.value
346
- end
336
+ results = {}
337
+ names.each do |name|
338
+ key = normalize_key(name, options)
339
+ entry = read_entry(key, options)
340
+ if entry
341
+ if entry.expired?
342
+ delete_entry(key, options)
343
+ else
344
+ results[name] = entry.value
347
345
  end
348
346
  end
349
- results
350
347
  end
348
+ results
351
349
  end
352
350
 
353
351
  # Fetches data from the cache, using the given keys. If there is data in
@@ -555,17 +553,6 @@ module ActiveSupport
555
553
  ActiveSupport::Notifications.instrument("cache_#{operation}.active_support", payload){ yield(payload) }
556
554
  end
557
555
 
558
- def instrument_multi(operation, keys, options = nil)
559
- log do
560
- formatted_keys = keys.map { |k| "- #{k}" }.join("\n")
561
- "Caches multi #{operation}:\n#{formatted_keys}#{options.blank? ? "" : " (#{options.inspect})"}"
562
- end
563
-
564
- payload = { key: keys }
565
- payload.merge!(options) if options.is_a?(Hash)
566
- ActiveSupport::Notifications.instrument("cache_#{operation}_multi.active_support", payload) { yield(payload) }
567
- end
568
-
569
556
  def log
570
557
  return unless logger && logger.debug? && !silence?
571
558
  logger.debug(yield)
@@ -96,16 +96,14 @@ module ActiveSupport
96
96
  options = names.extract_options!
97
97
  options = merged_options(options)
98
98
 
99
- instrument_multi(:read, names, options) do
100
- keys_to_names = Hash[names.map{|name| [normalize_key(name, options), name]}]
101
- raw_values = @data.get_multi(keys_to_names.keys, :raw => true)
102
- values = {}
103
- raw_values.each do |key, value|
104
- entry = deserialize_entry(value)
105
- values[keys_to_names[key]] = entry.value unless entry.expired?
106
- end
107
- values
99
+ keys_to_names = Hash[names.map{|name| [normalize_key(name, options), name]}]
100
+ raw_values = @data.get_multi(keys_to_names.keys, :raw => true)
101
+ values = {}
102
+ raw_values.each do |key, value|
103
+ entry = deserialize_entry(value)
104
+ values[keys_to_names[key]] = entry.value unless entry.expired?
108
105
  end
106
+ values
109
107
  end
110
108
 
111
109
  # Increment a cached value. This method uses the memcached incr atomic
@@ -6,12 +6,6 @@ module ActiveSupport
6
6
  # A share/exclusive lock, otherwise known as a read/write lock.
7
7
  #
8
8
  # https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock
9
- #--
10
- # Note that a pending Exclusive lock attempt does not block incoming
11
- # Share requests (i.e., we are "read-preferring"). That seems
12
- # consistent with the behavior of "loose" upgrades, but may be the
13
- # wrong choice otherwise: it nominally reduces the possibility of
14
- # deadlock by risking starvation instead.
15
9
  class ShareLock
16
10
  include MonitorMixin
17
11
 
@@ -51,7 +45,7 @@ module ActiveSupport
51
45
  if busy_for_exclusive?(purpose)
52
46
  return false if no_wait
53
47
 
54
- yield_shares(purpose, compatible) do
48
+ yield_shares(purpose: purpose, compatible: compatible, block_share: true) do
55
49
  @cv.wait_while { busy_for_exclusive?(purpose) }
56
50
  end
57
51
  end
@@ -73,18 +67,28 @@ module ActiveSupport
73
67
  if @exclusive_depth == 0
74
68
  @exclusive_thread = nil
75
69
 
76
- yield_shares(nil, compatible) do
77
- @cv.broadcast
78
- @cv.wait_while { @exclusive_thread || eligible_waiters?(compatible) }
70
+ if eligible_waiters?(compatible)
71
+ yield_shares(compatible: compatible, block_share: true) do
72
+ @cv.wait_while { @exclusive_thread || eligible_waiters?(compatible) }
73
+ end
79
74
  end
75
+ @cv.broadcast
80
76
  end
81
77
  end
82
78
  end
83
79
 
84
- def start_sharing(purpose: :share)
80
+ def start_sharing
85
81
  synchronize do
86
- if @sharing[Thread.current] == 0 && @exclusive_thread != Thread.current && busy_for_sharing?(purpose)
87
- @cv.wait_while { busy_for_sharing?(purpose) }
82
+ if @sharing[Thread.current] > 0 || @exclusive_thread == Thread.current
83
+ # We already hold a lock; nothing to wait for
84
+ elsif @waiting[Thread.current]
85
+ # We're nested inside a +yield_shares+ call: we'll resume as
86
+ # soon as there isn't an exclusive lock in our way
87
+ @cv.wait_while { @exclusive_thread }
88
+ else
89
+ # This is an initial / outermost share call: any outstanding
90
+ # requests for an exclusive lock get to go first
91
+ @cv.wait_while { busy_for_sharing?(false) }
88
92
  end
89
93
  @sharing[Thread.current] += 1
90
94
  end
@@ -127,6 +131,40 @@ module ActiveSupport
127
131
  end
128
132
  end
129
133
 
134
+ # Temporarily give up all held Share locks while executing the
135
+ # supplied block, allowing any +compatible+ exclusive lock request
136
+ # to proceed.
137
+ def yield_shares(purpose: nil, compatible: [], block_share: false)
138
+ loose_shares = previous_wait = nil
139
+ synchronize do
140
+ if loose_shares = @sharing.delete(Thread.current)
141
+ if previous_wait = @waiting[Thread.current]
142
+ purpose = nil unless purpose == previous_wait[0]
143
+ compatible &= previous_wait[1]
144
+ end
145
+ compatible |= [false] unless block_share
146
+ @waiting[Thread.current] = [purpose, compatible]
147
+
148
+ @cv.broadcast
149
+ end
150
+ end
151
+
152
+ begin
153
+ yield
154
+ ensure
155
+ synchronize do
156
+ @cv.wait_while { @exclusive_thread && @exclusive_thread != Thread.current }
157
+
158
+ if previous_wait
159
+ @waiting[Thread.current] = previous_wait
160
+ else
161
+ @waiting.delete Thread.current
162
+ end
163
+ @sharing[Thread.current] = loose_shares if loose_shares
164
+ end
165
+ end
166
+ end
167
+
130
168
  private
131
169
 
132
170
  # Must be called within synchronize
@@ -143,18 +181,6 @@ module ActiveSupport
143
181
  def eligible_waiters?(compatible)
144
182
  @waiting.any? { |t, (p, _)| compatible.include?(p) && @waiting.all? { |t2, (_, c2)| t == t2 || c2.include?(p) } }
145
183
  end
146
-
147
- def yield_shares(purpose, compatible)
148
- loose_shares = @sharing.delete(Thread.current)
149
- @waiting[Thread.current] = [purpose, compatible] if loose_shares
150
-
151
- begin
152
- yield
153
- ensure
154
- @waiting.delete Thread.current
155
- @sharing[Thread.current] = loose_shares if loose_shares
156
- end
157
- end
158
184
  end
159
185
  end
160
186
  end
@@ -73,4 +73,18 @@ class Array
73
73
  def forty_two
74
74
  self[41]
75
75
  end
76
+
77
+ # Equal to <tt>self[-3]</tt>.
78
+ #
79
+ # %w( a b c d e ).third_to_last # => "c"
80
+ def third_to_last
81
+ self[-3]
82
+ end
83
+
84
+ # Equal to <tt>self[-2]</tt>.
85
+ #
86
+ # %w( a b c d e ).second_to_last # => "d"
87
+ def second_to_last
88
+ self[-2]
89
+ end
76
90
  end
@@ -51,6 +51,11 @@ module DateAndTime
51
51
  WEEKEND_DAYS.include?(wday)
52
52
  end
53
53
 
54
+ # Returns true if the date/time does not fall on a Saturday or Sunday.
55
+ def on_weekday?
56
+ !WEEKEND_DAYS.include?(wday)
57
+ end
58
+
54
59
  # Returns a new date/time the specified number of days ago.
55
60
  def days_ago(days)
56
61
  advance(:days => -days)
@@ -1,6 +1,8 @@
1
1
  require 'active_support/core_ext/module/concerning'
2
2
 
3
3
  module Kernel
4
+ module_function
5
+
4
6
  # A shortcut to define a toplevel concern, not within a module.
5
7
  #
6
8
  # See Module::Concerning for more.
@@ -1,4 +1,6 @@
1
1
  module Kernel
2
+ module_function
3
+
2
4
  # Sets $VERBOSE to nil for the duration of the block and back to its original
3
5
  # value afterwards.
4
6
  #
@@ -15,72 +15,72 @@ module ActiveSupport::NumericWithFormat
15
15
  # ==== Examples
16
16
  #
17
17
  # Phone Numbers:
18
- # 5551234.to_s(:phone) # => 555-1234
19
- # 1235551234.to_s(:phone) # => 123-555-1234
20
- # 1235551234.to_s(:phone, area_code: true) # => (123) 555-1234
21
- # 1235551234.to_s(:phone, delimiter: ' ') # => 123 555 1234
22
- # 1235551234.to_s(:phone, area_code: true, extension: 555) # => (123) 555-1234 x 555
23
- # 1235551234.to_s(:phone, country_code: 1) # => +1-123-555-1234
18
+ # 5551234.to_s(:phone) # => "555-1234"
19
+ # 1235551234.to_s(:phone) # => "123-555-1234"
20
+ # 1235551234.to_s(:phone, area_code: true) # => "(123) 555-1234"
21
+ # 1235551234.to_s(:phone, delimiter: ' ') # => "123 555 1234"
22
+ # 1235551234.to_s(:phone, area_code: true, extension: 555) # => "(123) 555-1234 x 555"
23
+ # 1235551234.to_s(:phone, country_code: 1) # => "+1-123-555-1234"
24
24
  # 1235551234.to_s(:phone, country_code: 1, extension: 1343, delimiter: '.')
25
- # # => +1.123.555.1234 x 1343
25
+ # # => "+1.123.555.1234 x 1343"
26
26
  #
27
27
  # Currency:
28
- # 1234567890.50.to_s(:currency) # => $1,234,567,890.50
29
- # 1234567890.506.to_s(:currency) # => $1,234,567,890.51
30
- # 1234567890.506.to_s(:currency, precision: 3) # => $1,234,567,890.506
31
- # 1234567890.506.to_s(:currency, locale: :fr) # => 1 234 567 890,51 €
28
+ # 1234567890.50.to_s(:currency) # => "$1,234,567,890.50"
29
+ # 1234567890.506.to_s(:currency) # => "$1,234,567,890.51"
30
+ # 1234567890.506.to_s(:currency, precision: 3) # => "$1,234,567,890.506"
31
+ # 1234567890.506.to_s(:currency, locale: :fr) # => "1 234 567 890,51 €"
32
32
  # -1234567890.50.to_s(:currency, negative_format: '(%u%n)')
33
- # # => ($1,234,567,890.50)
33
+ # # => "($1,234,567,890.50)"
34
34
  # 1234567890.50.to_s(:currency, unit: '&pound;', separator: ',', delimiter: '')
35
- # # => &pound;1234567890,50
35
+ # # => "&pound;1234567890,50"
36
36
  # 1234567890.50.to_s(:currency, unit: '&pound;', separator: ',', delimiter: '', format: '%n %u')
37
- # # => 1234567890,50 &pound;
37
+ # # => "1234567890,50 &pound;"
38
38
  #
39
39
  # Percentage:
40
- # 100.to_s(:percentage) # => 100.000%
41
- # 100.to_s(:percentage, precision: 0) # => 100%
42
- # 1000.to_s(:percentage, delimiter: '.', separator: ',') # => 1.000,000%
43
- # 302.24398923423.to_s(:percentage, precision: 5) # => 302.24399%
44
- # 1000.to_s(:percentage, locale: :fr) # => 1 000,000%
45
- # 100.to_s(:percentage, format: '%n %') # => 100.000 %
40
+ # 100.to_s(:percentage) # => "100.000%"
41
+ # 100.to_s(:percentage, precision: 0) # => "100%"
42
+ # 1000.to_s(:percentage, delimiter: '.', separator: ',') # => "1.000,000%"
43
+ # 302.24398923423.to_s(:percentage, precision: 5) # => "302.24399%"
44
+ # 1000.to_s(:percentage, locale: :fr) # => "1 000,000%"
45
+ # 100.to_s(:percentage, format: '%n %') # => "100.000 %"
46
46
  #
47
47
  # Delimited:
48
- # 12345678.to_s(:delimited) # => 12,345,678
49
- # 12345678.05.to_s(:delimited) # => 12,345,678.05
50
- # 12345678.to_s(:delimited, delimiter: '.') # => 12.345.678
51
- # 12345678.to_s(:delimited, delimiter: ',') # => 12,345,678
52
- # 12345678.05.to_s(:delimited, separator: ' ') # => 12,345,678 05
53
- # 12345678.05.to_s(:delimited, locale: :fr) # => 12 345 678,05
48
+ # 12345678.to_s(:delimited) # => "12,345,678"
49
+ # 12345678.05.to_s(:delimited) # => "12,345,678.05"
50
+ # 12345678.to_s(:delimited, delimiter: '.') # => "12.345.678"
51
+ # 12345678.to_s(:delimited, delimiter: ',') # => "12,345,678"
52
+ # 12345678.05.to_s(:delimited, separator: ' ') # => "12,345,678 05"
53
+ # 12345678.05.to_s(:delimited, locale: :fr) # => "12 345 678,05"
54
54
  # 98765432.98.to_s(:delimited, delimiter: ' ', separator: ',')
55
- # # => 98 765 432,98
55
+ # # => "98 765 432,98"
56
56
  #
57
57
  # Rounded:
58
- # 111.2345.to_s(:rounded) # => 111.235
59
- # 111.2345.to_s(:rounded, precision: 2) # => 111.23
60
- # 13.to_s(:rounded, precision: 5) # => 13.00000
61
- # 389.32314.to_s(:rounded, precision: 0) # => 389
62
- # 111.2345.to_s(:rounded, significant: true) # => 111
63
- # 111.2345.to_s(:rounded, precision: 1, significant: true) # => 100
64
- # 13.to_s(:rounded, precision: 5, significant: true) # => 13.000
65
- # 111.234.to_s(:rounded, locale: :fr) # => 111,234
58
+ # 111.2345.to_s(:rounded) # => "111.235"
59
+ # 111.2345.to_s(:rounded, precision: 2) # => "111.23"
60
+ # 13.to_s(:rounded, precision: 5) # => "13.00000"
61
+ # 389.32314.to_s(:rounded, precision: 0) # => "389"
62
+ # 111.2345.to_s(:rounded, significant: true) # => "111"
63
+ # 111.2345.to_s(:rounded, precision: 1, significant: true) # => "100"
64
+ # 13.to_s(:rounded, precision: 5, significant: true) # => "13.000"
65
+ # 111.234.to_s(:rounded, locale: :fr) # => "111,234"
66
66
  # 13.to_s(:rounded, precision: 5, significant: true, strip_insignificant_zeros: true)
67
- # # => 13
68
- # 389.32314.to_s(:rounded, precision: 4, significant: true) # => 389.3
67
+ # # => "13"
68
+ # 389.32314.to_s(:rounded, precision: 4, significant: true) # => "389.3"
69
69
  # 1111.2345.to_s(:rounded, precision: 2, separator: ',', delimiter: '.')
70
- # # => 1.111,23
70
+ # # => "1.111,23"
71
71
  #
72
72
  # Human-friendly size in Bytes:
73
- # 123.to_s(:human_size) # => 123 Bytes
74
- # 1234.to_s(:human_size) # => 1.21 KB
75
- # 12345.to_s(:human_size) # => 12.1 KB
76
- # 1234567.to_s(:human_size) # => 1.18 MB
77
- # 1234567890.to_s(:human_size) # => 1.15 GB
78
- # 1234567890123.to_s(:human_size) # => 1.12 TB
79
- # 1234567890123456.to_s(:human_size) # => 1.1 PB
80
- # 1234567890123456789.to_s(:human_size) # => 1.07 EB
81
- # 1234567.to_s(:human_size, precision: 2) # => 1.2 MB
82
- # 483989.to_s(:human_size, precision: 2) # => 470 KB
83
- # 1234567.to_s(:human_size, precision: 2, separator: ',') # => 1,2 MB
73
+ # 123.to_s(:human_size) # => "123 Bytes"
74
+ # 1234.to_s(:human_size) # => "1.21 KB"
75
+ # 12345.to_s(:human_size) # => "12.1 KB"
76
+ # 1234567.to_s(:human_size) # => "1.18 MB"
77
+ # 1234567890.to_s(:human_size) # => "1.15 GB"
78
+ # 1234567890123.to_s(:human_size) # => "1.12 TB"
79
+ # 1234567890123456.to_s(:human_size) # => "1.1 PB"
80
+ # 1234567890123456789.to_s(:human_size) # => "1.07 EB"
81
+ # 1234567.to_s(:human_size, precision: 2) # => "1.2 MB"
82
+ # 483989.to_s(:human_size, precision: 2) # => "470 KB"
83
+ # 1234567.to_s(:human_size, precision: 2, separator: ',') # => "1,2 MB"
84
84
  # 1234567890123.to_s(:human_size, precision: 5) # => "1.1228 TB"
85
85
  # 524288000.to_s(:human_size, precision: 5) # => "500 MB"
86
86
  #
@@ -171,7 +171,7 @@ module ActiveSupport #:nodoc:
171
171
  original_concat(value)
172
172
  end
173
173
 
174
- def initialize(*)
174
+ def initialize(str = '')
175
175
  @html_safe = true
176
176
  super
177
177
  end
@@ -145,9 +145,9 @@ module ActiveSupport #:nodoc:
145
145
  # Get a list of the constants that were added
146
146
  new_constants = mod.local_constants - original_constants
147
147
 
148
- # self[namespace] returns an Array of the constants that are being evaluated
148
+ # @stack[namespace] returns an Array of the constants that are being evaluated
149
149
  # for that namespace. For instance, if parent.rb requires child.rb, the first
150
- # element of self[Object] will be an Array of the constants that were present
150
+ # element of @stack[Object] will be an Array of the constants that were present
151
151
  # before parent.rb was required. The second element will be an Array of the
152
152
  # constants that were present before child.rb was required.
153
153
  @stack[namespace].each do |namespace_constants|
@@ -262,7 +262,7 @@ module ActiveSupport #:nodoc:
262
262
  end
263
263
 
264
264
  def load_dependency(file)
265
- if Dependencies.load? && ActiveSupport::Dependencies.constant_watch_stack.watching?
265
+ if Dependencies.load? && Dependencies.constant_watch_stack.watching?
266
266
  Dependencies.new_constants_in(Object) { yield }
267
267
  else
268
268
  yield
@@ -42,6 +42,12 @@ module ActiveSupport #:nodoc:
42
42
  yield
43
43
  end
44
44
  end
45
+
46
+ def permit_concurrent_loads
47
+ @lock.yield_shares(compatible: [:load]) do
48
+ yield
49
+ end
50
+ end
45
51
  end
46
52
  end
47
53
  end
@@ -11,7 +11,7 @@ module ActiveSupport
11
11
  DEFAULT_BEHAVIORS = {
12
12
  raise: ->(message, callstack) {
13
13
  e = DeprecationException.new(message)
14
- e.set_backtrace(callstack)
14
+ e.set_backtrace(callstack.map(&:to_s))
15
15
  raise e
16
16
  },
17
17
 
@@ -80,7 +80,7 @@ module ActiveSupport
80
80
  # example.old_request.to_s
81
81
  # # => DEPRECATION WARNING: @request is deprecated! Call request.to_s instead of
82
82
  # @request.to_s
83
- # (Bactrace information…)
83
+ # (Backtrace information…)
84
84
  # "special_request"
85
85
  #
86
86
  # example.request.to_s
@@ -118,7 +118,7 @@ module ActiveSupport
118
118
  #
119
119
  # PLANETS.map { |planet| planet.capitalize }
120
120
  # # => DEPRECATION WARNING: PLANETS is deprecated! Use PLANETS_POST_2006 instead.
121
- # (Bactrace information…)
121
+ # (Backtrace information…)
122
122
  # ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
123
123
  class DeprecatedConstantProxy < DeprecationProxy
124
124
  def initialize(old_const, new_const, deprecator = ActiveSupport::Deprecation.instance)
@@ -1,3 +1,5 @@
1
+ require 'rbconfig'
2
+
1
3
  module ActiveSupport
2
4
  class Deprecation
3
5
  module Reporting
@@ -81,17 +83,17 @@ module ActiveSupport
81
83
  def extract_callstack(callstack)
82
84
  return _extract_callstack(callstack) if callstack.first.is_a? String
83
85
 
84
- rails_gem_root = File.expand_path("../../../../..", __FILE__) + "/"
85
86
  offending_line = callstack.find { |frame|
86
- frame.absolute_path && !frame.absolute_path.start_with?(rails_gem_root)
87
+ frame.absolute_path && !ignored_callstack(frame.absolute_path)
87
88
  } || callstack.first
89
+
88
90
  [offending_line.path, offending_line.lineno, offending_line.label]
89
91
  end
90
92
 
91
93
  def _extract_callstack(callstack)
92
94
  warn "Please pass `caller_locations` to the deprecation API" if $VERBOSE
93
- rails_gem_root = File.expand_path("../../../../..", __FILE__) + "/"
94
- offending_line = callstack.find { |line| !line.start_with?(rails_gem_root) } || callstack.first
95
+ offending_line = callstack.find { |line| !ignored_callstack(line) } || callstack.first
96
+
95
97
  if offending_line
96
98
  if md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/)
97
99
  md.captures
@@ -100,6 +102,12 @@ module ActiveSupport
100
102
  end
101
103
  end
102
104
  end
105
+
106
+ RAILS_GEM_ROOT = File.expand_path("../../../../..", __FILE__) + "/"
107
+
108
+ def ignored_callstack(path)
109
+ path.start_with?(RAILS_GEM_ROOT) || path.start_with?(RbConfig::CONFIG['rubylibdir'])
110
+ end
103
111
  end
104
112
  end
105
113
  end
@@ -8,7 +8,7 @@ module ActiveSupport
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "beta2"
11
+ PRE = "beta3"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -69,9 +69,13 @@ module ActiveSupport
69
69
  end
70
70
 
71
71
  def default(*args)
72
- key = args.first
73
- args[0] = key.to_s if key.is_a?(Symbol)
74
- super(*args)
72
+ arg_key = args.first
73
+
74
+ if include?(key = convert_key(arg_key))
75
+ self[key]
76
+ else
77
+ super
78
+ end
75
79
  end
76
80
 
77
81
  def self.new_from_hash_copying_default(hash)
@@ -1,8 +1,10 @@
1
1
  require 'active_support/logger_silence'
2
+ require 'active_support/logger_thread_safe_level'
2
3
  require 'logger'
3
4
 
4
5
  module ActiveSupport
5
6
  class Logger < ::Logger
7
+ include ActiveSupport::LoggerThreadSafeLevel
6
8
  include LoggerSilence
7
9
 
8
10
  # Returns true if the logger destination matches one of the sources
@@ -48,6 +50,11 @@ module ActiveSupport
48
50
  logger.level = level
49
51
  super(level)
50
52
  end
53
+
54
+ define_method(:local_level=) do |level|
55
+ logger.local_level = level if logger.respond_to?(:local_level=)
56
+ super(level) if respond_to?(:local_level=)
57
+ end
51
58
  end
52
59
  end
53
60
 
@@ -7,39 +7,22 @@ module LoggerSilence
7
7
 
8
8
  included do
9
9
  cattr_accessor :silencer
10
- attr_reader :local_levels
11
10
  self.silencer = true
12
11
  end
13
12
 
14
- def after_initialize
15
- @local_levels = Concurrent::Map.new(:initial_capacity => 2)
16
- end
17
-
18
- def local_log_id
19
- Thread.current.__id__
20
- end
21
-
22
- def level
23
- local_levels[local_log_id] || super
24
- end
25
-
26
13
  # Silences the logger for the duration of the block.
27
14
  def silence(temporary_level = Logger::ERROR)
28
15
  if silencer
29
16
  begin
30
- old_local_level = local_levels[local_log_id]
31
- local_levels[local_log_id] = temporary_level
17
+ old_local_level = local_level
18
+ self.local_level = temporary_level
32
19
 
33
20
  yield self
34
21
  ensure
35
- if old_local_level
36
- local_levels[local_log_id] = old_local_level
37
- else
38
- local_levels.delete(local_log_id)
39
- end
22
+ self.local_level = old_local_level
40
23
  end
41
24
  else
42
25
  yield self
43
26
  end
44
27
  end
45
- end
28
+ end
@@ -0,0 +1,31 @@
1
+ require 'active_support/concern'
2
+
3
+ module ActiveSupport
4
+ module LoggerThreadSafeLevel # :nodoc:
5
+ extend ActiveSupport::Concern
6
+
7
+ def after_initialize
8
+ @local_levels = Concurrent::Map.new(initial_capacity: 2)
9
+ end
10
+
11
+ def local_log_id
12
+ Thread.current.__id__
13
+ end
14
+
15
+ def local_level
16
+ @local_levels[local_log_id]
17
+ end
18
+
19
+ def local_level=(level)
20
+ if level
21
+ @local_levels[local_log_id] = level
22
+ else
23
+ @local_levels.delete(local_log_id)
24
+ end
25
+ end
26
+
27
+ def level
28
+ local_level || super
29
+ end
30
+ end
31
+ end
@@ -24,6 +24,12 @@ module ActiveSupport
24
24
  # hash upon initialization:
25
25
  #
26
26
  # @verifier = ActiveSupport::MessageVerifier.new('s3Krit', serializer: YAML)
27
+ #
28
+ # +MessageVerifier+ creates HMAC signatures using SHA1 hash algorithm by default.
29
+ # If you want to use a different hash algorithm, you can change it by providing
30
+ # `:digest` key as an option while initializing the verifier:
31
+ #
32
+ # @verifier = ActiveSupport::MessageVerifier.new('s3Krit', digest: 'SHA256')
27
33
  class MessageVerifier
28
34
  class InvalidSignature < StandardError; end
29
35
 
@@ -29,17 +29,17 @@ module ActiveSupport
29
29
  # number.
30
30
  # ==== Examples
31
31
  #
32
- # number_to_phone(5551234) # => 555-1234
33
- # number_to_phone('5551234') # => 555-1234
34
- # number_to_phone(1235551234) # => 123-555-1234
35
- # number_to_phone(1235551234, area_code: true) # => (123) 555-1234
36
- # number_to_phone(1235551234, delimiter: ' ') # => 123 555 1234
37
- # number_to_phone(1235551234, area_code: true, extension: 555) # => (123) 555-1234 x 555
38
- # number_to_phone(1235551234, country_code: 1) # => +1-123-555-1234
39
- # number_to_phone('123a456') # => 123a456
32
+ # number_to_phone(5551234) # => "555-1234"
33
+ # number_to_phone('5551234') # => "555-1234"
34
+ # number_to_phone(1235551234) # => "123-555-1234"
35
+ # number_to_phone(1235551234, area_code: true) # => "(123) 555-1234"
36
+ # number_to_phone(1235551234, delimiter: ' ') # => "123 555 1234"
37
+ # number_to_phone(1235551234, area_code: true, extension: 555) # => "(123) 555-1234 x 555"
38
+ # number_to_phone(1235551234, country_code: 1) # => "+1-123-555-1234"
39
+ # number_to_phone('123a456') # => "123a456"
40
40
  #
41
41
  # number_to_phone(1235551234, country_code: 1, extension: 1343, delimiter: '.')
42
- # # => +1.123.555.1234 x 1343
42
+ # # => "+1.123.555.1234 x 1343"
43
43
  def number_to_phone(number, options = {})
44
44
  NumberToPhoneConverter.convert(number, options)
45
45
  end
@@ -78,18 +78,18 @@ module ActiveSupport
78
78
  #
79
79
  # ==== Examples
80
80
  #
81
- # number_to_currency(1234567890.50) # => $1,234,567,890.50
82
- # number_to_currency(1234567890.506) # => $1,234,567,890.51
83
- # number_to_currency(1234567890.506, precision: 3) # => $1,234,567,890.506
84
- # number_to_currency(1234567890.506, locale: :fr) # => 1 234 567 890,51 €
85
- # number_to_currency('123a456') # => $123a456
81
+ # number_to_currency(1234567890.50) # => "$1,234,567,890.50"
82
+ # number_to_currency(1234567890.506) # => "$1,234,567,890.51"
83
+ # number_to_currency(1234567890.506, precision: 3) # => "$1,234,567,890.506"
84
+ # number_to_currency(1234567890.506, locale: :fr) # => "1 234 567 890,51 €"
85
+ # number_to_currency('123a456') # => "$123a456"
86
86
  #
87
87
  # number_to_currency(-1234567890.50, negative_format: '(%u%n)')
88
- # # => ($1,234,567,890.50)
88
+ # # => "($1,234,567,890.50)"
89
89
  # number_to_currency(1234567890.50, unit: '&pound;', separator: ',', delimiter: '')
90
- # # => &pound;1234567890,50
90
+ # # => "&pound;1234567890,50"
91
91
  # number_to_currency(1234567890.50, unit: '&pound;', separator: ',', delimiter: '', format: '%n %u')
92
- # # => 1234567890,50 &pound;
92
+ # # => "1234567890,50 &pound;"
93
93
  def number_to_currency(number, options = {})
94
94
  NumberToCurrencyConverter.convert(number, options)
95
95
  end
@@ -118,15 +118,15 @@ module ActiveSupport
118
118
  #
119
119
  # ==== Examples
120
120
  #
121
- # number_to_percentage(100) # => 100.000%
122
- # number_to_percentage('98') # => 98.000%
123
- # number_to_percentage(100, precision: 0) # => 100%
124
- # number_to_percentage(1000, delimiter: '.', separator: ',') # => 1.000,000%
125
- # number_to_percentage(302.24398923423, precision: 5) # => 302.24399%
126
- # number_to_percentage(1000, locale: :fr) # => 1000,000%
127
- # number_to_percentage(1000, precision: nil) # => 1000%
128
- # number_to_percentage('98a') # => 98a%
129
- # number_to_percentage(100, format: '%n %') # => 100.000 %
121
+ # number_to_percentage(100) # => "100.000%"
122
+ # number_to_percentage('98') # => "98.000%"
123
+ # number_to_percentage(100, precision: 0) # => "100%"
124
+ # number_to_percentage(1000, delimiter: '.', separator: ',') # => "1.000,000%"
125
+ # number_to_percentage(302.24398923423, precision: 5) # => "302.24399%"
126
+ # number_to_percentage(1000, locale: :fr) # => "1000,000%"
127
+ # number_to_percentage(1000, precision: nil) # => "1000%"
128
+ # number_to_percentage('98a') # => "98a%"
129
+ # number_to_percentage(100, format: '%n %') # => "100.000 %"
130
130
  def number_to_percentage(number, options = {})
131
131
  NumberToPercentageConverter.convert(number, options)
132
132
  end
@@ -149,19 +149,19 @@ module ActiveSupport
149
149
  #
150
150
  # ==== Examples
151
151
  #
152
- # number_to_delimited(12345678) # => 12,345,678
153
- # number_to_delimited('123456') # => 123,456
154
- # number_to_delimited(12345678.05) # => 12,345,678.05
155
- # number_to_delimited(12345678, delimiter: '.') # => 12.345.678
156
- # number_to_delimited(12345678, delimiter: ',') # => 12,345,678
157
- # number_to_delimited(12345678.05, separator: ' ') # => 12,345,678 05
158
- # number_to_delimited(12345678.05, locale: :fr) # => 12 345 678,05
159
- # number_to_delimited('112a') # => 112a
152
+ # number_to_delimited(12345678) # => "12,345,678"
153
+ # number_to_delimited('123456') # => "123,456"
154
+ # number_to_delimited(12345678.05) # => "12,345,678.05"
155
+ # number_to_delimited(12345678, delimiter: '.') # => "12.345.678"
156
+ # number_to_delimited(12345678, delimiter: ',') # => "12,345,678"
157
+ # number_to_delimited(12345678.05, separator: ' ') # => "12,345,678 05"
158
+ # number_to_delimited(12345678.05, locale: :fr) # => "12 345 678,05"
159
+ # number_to_delimited('112a') # => "112a"
160
160
  # number_to_delimited(98765432.98, delimiter: ' ', separator: ',')
161
- # # => 98 765 432,98
161
+ # # => "98 765 432,98"
162
162
  # number_to_delimited("123456.78",
163
163
  # delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/)
164
- # # => 1,23,456.78
164
+ # # => "1,23,456.78"
165
165
  def number_to_delimited(number, options = {})
166
166
  NumberToDelimitedConverter.convert(number, options)
167
167
  end
@@ -190,22 +190,22 @@ module ActiveSupport
190
190
  #
191
191
  # ==== Examples
192
192
  #
193
- # number_to_rounded(111.2345) # => 111.235
194
- # number_to_rounded(111.2345, precision: 2) # => 111.23
195
- # number_to_rounded(13, precision: 5) # => 13.00000
196
- # number_to_rounded(389.32314, precision: 0) # => 389
197
- # number_to_rounded(111.2345, significant: true) # => 111
198
- # number_to_rounded(111.2345, precision: 1, significant: true) # => 100
199
- # number_to_rounded(13, precision: 5, significant: true) # => 13.000
200
- # number_to_rounded(13, precision: nil) # => 13
201
- # number_to_rounded(111.234, locale: :fr) # => 111,234
193
+ # number_to_rounded(111.2345) # => "111.235"
194
+ # number_to_rounded(111.2345, precision: 2) # => "111.23"
195
+ # number_to_rounded(13, precision: 5) # => "13.00000"
196
+ # number_to_rounded(389.32314, precision: 0) # => "389"
197
+ # number_to_rounded(111.2345, significant: true) # => "111"
198
+ # number_to_rounded(111.2345, precision: 1, significant: true) # => "100"
199
+ # number_to_rounded(13, precision: 5, significant: true) # => "13.000"
200
+ # number_to_rounded(13, precision: nil) # => "13"
201
+ # number_to_rounded(111.234, locale: :fr) # => "111,234"
202
202
  #
203
203
  # number_to_rounded(13, precision: 5, significant: true, strip_insignificant_zeros: true)
204
- # # => 13
204
+ # # => "13"
205
205
  #
206
- # number_to_rounded(389.32314, precision: 4, significant: true) # => 389.3
206
+ # number_to_rounded(389.32314, precision: 4, significant: true) # => "389.3"
207
207
  # number_to_rounded(1111.2345, precision: 2, separator: ',', delimiter: '.')
208
- # # => 1.111,23
208
+ # # => "1.111,23"
209
209
  def number_to_rounded(number, options = {})
210
210
  NumberToRoundedConverter.convert(number, options)
211
211
  end
@@ -237,17 +237,17 @@ module ActiveSupport
237
237
  #
238
238
  # ==== Examples
239
239
  #
240
- # number_to_human_size(123) # => 123 Bytes
241
- # number_to_human_size(1234) # => 1.21 KB
242
- # number_to_human_size(12345) # => 12.1 KB
243
- # number_to_human_size(1234567) # => 1.18 MB
244
- # number_to_human_size(1234567890) # => 1.15 GB
245
- # number_to_human_size(1234567890123) # => 1.12 TB
246
- # number_to_human_size(1234567890123456) # => 1.1 PB
247
- # number_to_human_size(1234567890123456789) # => 1.07 EB
248
- # number_to_human_size(1234567, precision: 2) # => 1.2 MB
249
- # number_to_human_size(483989, precision: 2) # => 470 KB
250
- # number_to_human_size(1234567, precision: 2, separator: ',') # => 1,2 MB
240
+ # number_to_human_size(123) # => "123 Bytes"
241
+ # number_to_human_size(1234) # => "1.21 KB"
242
+ # number_to_human_size(12345) # => "12.1 KB"
243
+ # number_to_human_size(1234567) # => "1.18 MB"
244
+ # number_to_human_size(1234567890) # => "1.15 GB"
245
+ # number_to_human_size(1234567890123) # => "1.12 TB"
246
+ # number_to_human_size(1234567890123456) # => "1.1 PB"
247
+ # number_to_human_size(1234567890123456789) # => "1.07 EB"
248
+ # number_to_human_size(1234567, precision: 2) # => "1.2 MB"
249
+ # number_to_human_size(483989, precision: 2) # => "470 KB"
250
+ # number_to_human_size(1234567, precision: 2, separator: ',') # => "1,2 MB"
251
251
  # number_to_human_size(1234567890123, precision: 5) # => "1.1228 TB"
252
252
  # number_to_human_size(524288000, precision: 5) # => "500 MB"
253
253
  def number_to_human_size(number, options = {})
@@ -66,12 +66,20 @@ module ActiveSupport
66
66
  alias :assert_not_respond_to :refute_respond_to
67
67
  alias :assert_not_same :refute_same
68
68
 
69
- # Reveals the intention that the block should not raise any exception.
69
+
70
+ # Assertion that the block should not raise an exception.
71
+ #
72
+ # Passes if evaluated code in the yielded block raises no exception.
70
73
  #
71
74
  # assert_nothing_raised do
72
- # ...
75
+ # perform_service(param: 'no_exception')
73
76
  # end
74
77
  def assert_nothing_raised(*args)
78
+ if args.present?
79
+ ActiveSupport::Deprecation.warn(
80
+ "Passing arguments to assert_nothing_raised " \
81
+ "is deprecated and will be removed in Rails 5.1.")
82
+ end
75
83
  yield
76
84
  end
77
85
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta2
4
+ version: 5.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -24,26 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.7'
27
- - !ruby/object:Gem::Dependency
28
- name: json
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.7'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 1.7.7
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '1.7'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 1.7.7
47
27
  - !ruby/object:Gem::Dependency
48
28
  name: tzinfo
49
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,20 +66,6 @@ dependencies:
86
66
  - - "~>"
87
67
  - !ruby/object:Gem::Version
88
68
  version: '1.0'
89
- - !ruby/object:Gem::Dependency
90
- name: method_source
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :runtime
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
69
  description: A toolkit of support libraries and Ruby core extensions extracted from
104
70
  the Rails framework. Rich support for multibyte strings, internationalization, time
105
71
  zones, and testing.
@@ -280,6 +246,7 @@ files:
280
246
  - lib/active_support/log_subscriber/test_helper.rb
281
247
  - lib/active_support/logger.rb
282
248
  - lib/active_support/logger_silence.rb
249
+ - lib/active_support/logger_thread_safe_level.rb
283
250
  - lib/active_support/message_encryptor.rb
284
251
  - lib/active_support/message_verifier.rb
285
252
  - lib/active_support/multibyte.rb
@@ -356,10 +323,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
323
  version: 1.3.1
357
324
  requirements: []
358
325
  rubyforge_project:
359
- rubygems_version: 2.5.2
326
+ rubygems_version: 2.5.1
360
327
  signing_key:
361
328
  specification_version: 4
362
329
  summary: A toolkit of support libraries and Ruby core extensions extracted from the
363
330
  Rails framework.
364
331
  test_files: []
365
- has_rdoc: