activesupport 4.2.0.beta1 → 4.2.0.beta2
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 +4 -4
- data/CHANGELOG.md +100 -29
- data/lib/active_support.rb +10 -0
- data/lib/active_support/concern.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +9 -1
- data/lib/active_support/core_ext/object/duplicable.rb +10 -0
- data/lib/active_support/core_ext/object/itself.rb +5 -2
- data/lib/active_support/core_ext/object/try.rb +10 -1
- data/lib/active_support/core_ext/string/filters.rb +1 -1
- data/lib/active_support/core_ext/string/inflections.rb +1 -0
- data/lib/active_support/core_ext/time/calculations.rb +14 -6
- data/lib/active_support/deprecation.rb +1 -1
- data/lib/active_support/duration.rb +16 -2
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/inflector/methods.rb +1 -1
- data/lib/active_support/message_verifier.rb +1 -0
- data/lib/active_support/multibyte/unicode.rb +0 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +2 -2
- data/lib/active_support/test_case.rb +29 -0
- data/lib/active_support/testing/constant_lookup.rb +1 -5
- data/lib/active_support/values/time_zone.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6855c98b53b4f198dd4f49a962702e8430f2f350
|
4
|
+
data.tar.gz: bd5e7919ad2fa36d651dfaf9dc44ac90e06c2c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d641ebd16a416b3edc15bb2cb0dc66fe60f791a97657c63ad7bcb84c936a2014341fb47d26ec3cbe972bb72e64613cb45b691dc9167bd96067b233497490ae56
|
7
|
+
data.tar.gz: 5eeaa5cc8751d5d4070bc957cb02a426816fee1b793f756573099a432b62772447918a544d745a7128e05d1d4823e5244763f56af2addf0234d2e142817392e9
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,84 @@
|
|
1
|
-
*
|
2
|
-
|
3
|
-
|
1
|
+
* Delegation now works with ruby reserved words passed to `:to` option.
|
2
|
+
|
3
|
+
Fixes #16956.
|
4
|
+
|
5
|
+
*Agis Anastasopoulos*
|
6
|
+
|
7
|
+
* Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`.
|
8
|
+
|
9
|
+
Currently, the following returns `false`, contrary to expectation:
|
10
|
+
|
11
|
+
1.minute.eql?(1.minute)
|
12
|
+
|
13
|
+
Adding method `#eql?` will make this behave like expected. Method `#eql?` is
|
14
|
+
just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their
|
15
|
+
parts may be different though.
|
16
|
+
|
17
|
+
1.minute.eql?(60.seconds) # => true
|
18
|
+
1.minute.eql?(60) # => false
|
19
|
+
|
20
|
+
*Joost Lubach*
|
21
|
+
|
22
|
+
* Time#change can now change nanoseconds (:nsec) as a higher-precision
|
23
|
+
alternative to microseconds (:usec).
|
24
|
+
|
25
|
+
*Agis Anastasooulos*
|
26
|
+
|
27
|
+
* `MessageVerifier.new` raises an appropriate exception if the secret is `nil`.
|
28
|
+
This prevents `MessageVerifier#generate` from raising a cryptic error later on.
|
29
|
+
|
30
|
+
*Kostiantyn Kahanskyi*
|
31
|
+
|
32
|
+
* Introduced new configuration option `active_support.test_order` for
|
33
|
+
specifying the order in which test cases are executed. This option currently defaults
|
34
|
+
to `:sorted` but will be changed to `:random` in Rails 5.0.
|
35
|
+
|
36
|
+
*Akira Matsuda*, *Godfrey Chan*
|
37
|
+
|
38
|
+
* Fixed a bug in Inflector#underscore where acroynms in nested constant names
|
39
|
+
are incorrectly parsed as camelCase.
|
40
|
+
|
41
|
+
Fixes #8015.
|
42
|
+
|
43
|
+
*Fred Wu*, *Matthew Draper*
|
44
|
+
|
45
|
+
* Make Time#change throw an exception if the :usec option is out of range and
|
46
|
+
the time has an offset other than UTC or local.
|
47
|
+
|
48
|
+
*Agis Anastasopoulos*
|
49
|
+
|
50
|
+
* `Method` objects now report themselves as not `duplicable?`. This allows
|
51
|
+
hashes and arrays containing `Method` objects to be `deep_dup`ed.
|
52
|
+
|
53
|
+
*Peter Jaros*
|
54
|
+
|
55
|
+
* `determine_constant_from_test_name` does no longer shadow `NameError`s
|
56
|
+
which happens during constant autoloading.
|
57
|
+
|
58
|
+
Fixes #9933.
|
59
|
+
|
60
|
+
*Guo Xiang Tan*
|
61
|
+
|
62
|
+
* Added instance_eval version to Object#try, so you can do this:
|
63
|
+
|
64
|
+
person.try { name.first }
|
65
|
+
|
66
|
+
instead of:
|
67
|
+
|
68
|
+
person.try { |person| person.name.first }
|
69
|
+
|
4
70
|
*DHH*
|
5
71
|
|
6
|
-
* Fix ActiveSupport::
|
7
|
-
|
8
|
-
|
72
|
+
* Fix the `ActiveSupport::Duration#instance_of?` method to return the right
|
73
|
+
value with the class itself since it was previously delegated to the
|
74
|
+
internal value.
|
75
|
+
|
76
|
+
*Robin Dupret*
|
9
77
|
|
10
|
-
|
78
|
+
* Fix rounding errors with #travel_to by resetting the usec on any passed time to zero, so we only travel
|
79
|
+
with per-second precision, not anything deeper than that.
|
80
|
+
|
81
|
+
*DHH*
|
11
82
|
|
12
83
|
* Fix DateTime comparison with DateTime::Infinity object.
|
13
84
|
|
@@ -60,8 +131,8 @@
|
|
60
131
|
|
61
132
|
* Always instrument `ActiveSupport::Cache`.
|
62
133
|
|
63
|
-
Since `ActiveSupport::Notifications` only
|
64
|
-
are
|
134
|
+
Since `ActiveSupport::Notifications` only instruments items when there
|
135
|
+
are attached subscribers, we don't need to disable instrumentation.
|
65
136
|
|
66
137
|
*Peter Wagenet*
|
67
138
|
|
@@ -84,17 +155,17 @@
|
|
84
155
|
`ActiveSupport::TimeWithZone#-` should return the same result as if we were
|
85
156
|
using `Time#-`:
|
86
157
|
|
87
|
-
Time.now.end_of_day - Time.now.beginning_of_day
|
158
|
+
Time.now.end_of_day - Time.now.beginning_of_day # => 86399.999999999
|
88
159
|
|
89
160
|
Before:
|
90
161
|
|
91
|
-
Time.zone.now.end_of_day.nsec
|
92
|
-
Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
|
162
|
+
Time.zone.now.end_of_day.nsec # => 999999999
|
163
|
+
Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0
|
93
164
|
|
94
165
|
After:
|
95
166
|
|
96
167
|
Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
|
97
|
-
|
168
|
+
# => 86399.999999999
|
98
169
|
|
99
170
|
*Gordon Chan*
|
100
171
|
|
@@ -103,12 +174,12 @@
|
|
103
174
|
Before:
|
104
175
|
|
105
176
|
ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
|
106
|
-
|
177
|
+
# => "330.00"
|
107
178
|
|
108
179
|
After:
|
109
180
|
|
110
181
|
ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
|
111
|
-
|
182
|
+
# => "333.33"
|
112
183
|
|
113
184
|
See #15379.
|
114
185
|
|
@@ -190,9 +261,9 @@
|
|
190
261
|
|
191
262
|
*Xavier Noria*
|
192
263
|
|
193
|
-
* Fixed backward compatibility
|
264
|
+
* Fixed backward compatibility issues introduced in 326e652.
|
194
265
|
|
195
|
-
Empty Hash or Array should not present in serialization result.
|
266
|
+
Empty Hash or Array should not be present in serialization result.
|
196
267
|
|
197
268
|
{a: []}.to_query # => ""
|
198
269
|
{a: {}}.to_query # => ""
|
@@ -211,20 +282,20 @@
|
|
211
282
|
|
212
283
|
This fixes the current situation of:
|
213
284
|
|
214
|
-
1.second.eql?(1.second)
|
285
|
+
1.second.eql?(1.second) # => false
|
215
286
|
|
216
287
|
`eql?` also requires that the other object is an `ActiveSupport::Duration`.
|
217
288
|
This requirement makes `ActiveSupport::Duration`'s behavior consistent with
|
218
289
|
the behavior of Ruby's numeric types:
|
219
290
|
|
220
|
-
1.eql?(1.0)
|
221
|
-
1.0.eql?(1)
|
291
|
+
1.eql?(1.0) # => false
|
292
|
+
1.0.eql?(1) # => false
|
222
293
|
|
223
|
-
1.second.eql?(1)
|
224
|
-
1.eql?(1.second)
|
294
|
+
1.second.eql?(1) # => false (was true)
|
295
|
+
1.eql?(1.second) # => false
|
225
296
|
|
226
297
|
{ 1 => "foo", 1.0 => "bar" }
|
227
|
-
|
298
|
+
# => { 1 => "foo", 1.0 => "bar" }
|
228
299
|
|
229
300
|
{ 1 => "foo", 1.second => "bar" }
|
230
301
|
# now => { 1 => "foo", 1.second => "bar" }
|
@@ -232,11 +303,11 @@
|
|
232
303
|
|
233
304
|
And though the behavior of these hasn't changed, for reference:
|
234
305
|
|
235
|
-
1 == 1.0
|
236
|
-
1.0 == 1
|
306
|
+
1 == 1.0 # => true
|
307
|
+
1.0 == 1 # => true
|
237
308
|
|
238
|
-
1 == 1.second
|
239
|
-
1.second == 1
|
309
|
+
1 == 1.second # => true
|
310
|
+
1.second == 1 # => true
|
240
311
|
|
241
312
|
*Emily Dobervich*
|
242
313
|
|
@@ -246,8 +317,8 @@
|
|
246
317
|
|
247
318
|
*Pavel Pravosud*
|
248
319
|
|
249
|
-
* `HashWithIndifferentAccess` better respects `#to_hash` on objects it
|
250
|
-
|
320
|
+
* `HashWithIndifferentAccess` better respects `#to_hash` on objects it
|
321
|
+
recieves. In particular, `.new`, `#update`, `#merge`, `#replace` all accept
|
251
322
|
objects which respond to `#to_hash`, even if those objects are not Hashes
|
252
323
|
directly.
|
253
324
|
|
data/lib/active_support.rb
CHANGED
@@ -70,6 +70,16 @@ module ActiveSupport
|
|
70
70
|
|
71
71
|
NumberHelper.eager_load!
|
72
72
|
end
|
73
|
+
|
74
|
+
@@test_order = nil
|
75
|
+
|
76
|
+
def self.test_order=(new_order)
|
77
|
+
@@test_order = new_order
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.test_order
|
81
|
+
@@test_order
|
82
|
+
end
|
73
83
|
end
|
74
84
|
|
75
85
|
autoload :I18n, "active_support/i18n"
|
@@ -95,7 +95,7 @@ module ActiveSupport
|
|
95
95
|
# end
|
96
96
|
#
|
97
97
|
# class Host
|
98
|
-
# include Bar # works, Bar takes care
|
98
|
+
# include Bar # It works, now Bar takes care of its dependencies
|
99
99
|
# end
|
100
100
|
module Concern
|
101
101
|
class MultipleIncludedBlocks < StandardError #:nodoc:
|
@@ -1,8 +1,16 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
class Module
|
2
4
|
# Error generated by +delegate+ when a method is called on +nil+ and +allow_nil+
|
3
5
|
# option is not used.
|
4
6
|
class DelegationError < NoMethodError; end
|
5
7
|
|
8
|
+
RUBY_RESERVED_WORDS = Set.new(
|
9
|
+
%w(alias and BEGIN begin break case class def defined? do else elsif END
|
10
|
+
end ensure false for if in module next nil not or redo rescue retry
|
11
|
+
return self super then true undef unless until when while yield)
|
12
|
+
).freeze
|
13
|
+
|
6
14
|
# Provides a +delegate+ class method to easily expose contained objects'
|
7
15
|
# public methods as your own.
|
8
16
|
#
|
@@ -163,7 +171,7 @@ class Module
|
|
163
171
|
line = line.to_i
|
164
172
|
|
165
173
|
to = to.to_s
|
166
|
-
to =
|
174
|
+
to = "self.#{to}" if RUBY_RESERVED_WORDS.include?(to)
|
167
175
|
|
168
176
|
methods.each do |method|
|
169
177
|
# Attribute writer methods only accept one argument. Makes sure []=
|
@@ -91,3 +91,13 @@ class BigDecimal
|
|
91
91
|
# can't dup, so use superclass implementation
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
95
|
+
class Method
|
96
|
+
# Methods are not duplicable:
|
97
|
+
#
|
98
|
+
# method(:puts).duplicable? # => false
|
99
|
+
# method(:puts).dup # => TypeError: allocator undefined for Method
|
100
|
+
def duplicable?
|
101
|
+
false
|
102
|
+
end
|
103
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
class Object
|
2
|
-
|
3
|
-
|
2
|
+
# TODO: Remove this file when we drop support for Ruby < 2.2
|
3
|
+
unless respond_to?(:itself)
|
4
|
+
# Returns the object itself.
|
5
|
+
#
|
6
|
+
# Useful for chaining methods, such as Active Record scopes:
|
4
7
|
#
|
5
8
|
# Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at)
|
6
9
|
#
|
@@ -33,6 +33,11 @@ class Object
|
|
33
33
|
# ...
|
34
34
|
# end
|
35
35
|
#
|
36
|
+
# You can also call try with a block without accepting an argument, and the block
|
37
|
+
# will be instance_eval'ed instead:
|
38
|
+
#
|
39
|
+
# @person.try { upcase.truncate(50) }
|
40
|
+
#
|
36
41
|
# Please also note that +try+ is defined on +Object+, therefore it won't work
|
37
42
|
# with instances of classes that do not have +Object+ among their ancestors,
|
38
43
|
# like direct subclasses of +BasicObject+. For example, using +try+ with
|
@@ -40,7 +45,11 @@ class Object
|
|
40
45
|
# delegator itself.
|
41
46
|
def try(*a, &b)
|
42
47
|
if a.empty? && block_given?
|
43
|
-
|
48
|
+
if b.arity.zero?
|
49
|
+
instance_eval(&b)
|
50
|
+
else
|
51
|
+
yield self
|
52
|
+
end
|
44
53
|
else
|
45
54
|
public_send(*a, &b) if respond_to?(a.first)
|
46
55
|
end
|
@@ -3,7 +3,7 @@ class String
|
|
3
3
|
# the string, and then changing remaining consecutive whitespace
|
4
4
|
# groups into one space each.
|
5
5
|
#
|
6
|
-
# Note that it handles both ASCII and Unicode whitespace
|
6
|
+
# Note that it handles both ASCII and Unicode whitespace.
|
7
7
|
#
|
8
8
|
# %{ Multi-line
|
9
9
|
# string }.squish # => "Multi-line string"
|
@@ -199,6 +199,7 @@ class String
|
|
199
199
|
# 'employee_salary'.humanize # => "Employee salary"
|
200
200
|
# 'author_id'.humanize # => "Author"
|
201
201
|
# 'author_id'.humanize(capitalize: false) # => "author"
|
202
|
+
# '_id'.humanize # => "Id"
|
202
203
|
def humanize(options = {})
|
203
204
|
ActiveSupport::Inflector.humanize(self, options)
|
204
205
|
end
|
@@ -64,11 +64,12 @@ class Time
|
|
64
64
|
|
65
65
|
# Returns a new Time where one or more of the elements have been changed according
|
66
66
|
# to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
|
67
|
-
# <tt>:sec</tt>, <tt>:usec</tt>) reset cascadingly, so if only
|
68
|
-
# then minute, sec, and
|
69
|
-
# sec and
|
70
|
-
# keys: <tt>:year</tt>, <tt>:month</tt>,
|
71
|
-
# <tt>:sec</tt>, <tt>:usec</tt
|
67
|
+
# <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only
|
68
|
+
# the hour is passed, then minute, sec, usec and nsec is set to 0. If the hour
|
69
|
+
# and minute is passed, then sec, usec and nsec is set to 0. The +options+
|
70
|
+
# parameter takes a hash with any of these keys: <tt>:year</tt>, <tt>:month</tt>,
|
71
|
+
# <tt>:day</tt>, <tt>:hour</tt>, <tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>
|
72
|
+
# <tt>:nsec</tt>. Path either <tt>:usec</tt> or <tt>:nsec</tt>, not both.
|
72
73
|
#
|
73
74
|
# Time.new(2012, 8, 29, 22, 35, 0).change(day: 1) # => Time.new(2012, 8, 1, 22, 35, 0)
|
74
75
|
# Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, day: 1) # => Time.new(1981, 8, 1, 22, 35, 0)
|
@@ -80,13 +81,20 @@ class Time
|
|
80
81
|
new_hour = options.fetch(:hour, hour)
|
81
82
|
new_min = options.fetch(:min, options[:hour] ? 0 : min)
|
82
83
|
new_sec = options.fetch(:sec, (options[:hour] || options[:min]) ? 0 : sec)
|
83
|
-
|
84
|
+
|
85
|
+
if new_nsec = options[:nsec]
|
86
|
+
raise ArgumentError, "Can't change both :nsec and :usec at the same time: #{options.inspect}" if options[:usec]
|
87
|
+
new_usec = Rational(new_nsec, 1000)
|
88
|
+
else
|
89
|
+
new_usec = options.fetch(:usec, (options[:hour] || options[:min] || options[:sec]) ? 0 : Rational(nsec, 1000))
|
90
|
+
end
|
84
91
|
|
85
92
|
if utc?
|
86
93
|
::Time.utc(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
|
87
94
|
elsif zone
|
88
95
|
::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
|
89
96
|
else
|
97
|
+
raise ArgumentError, 'argument out of range' if new_usec > 999999
|
90
98
|
::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec + (new_usec.to_r / 1000000), utc_offset)
|
91
99
|
end
|
92
100
|
end
|
@@ -32,7 +32,7 @@ module ActiveSupport
|
|
32
32
|
# and the second is a library name
|
33
33
|
#
|
34
34
|
# ActiveSupport::Deprecation.new('2.0', 'MyLibrary')
|
35
|
-
def initialize(deprecation_horizon = '
|
35
|
+
def initialize(deprecation_horizon = '5.0', gem_name = 'Rails')
|
36
36
|
self.gem_name = gem_name
|
37
37
|
self.deprecation_horizon = deprecation_horizon
|
38
38
|
# By default, warnings are not silenced and debugging is off.
|
@@ -7,7 +7,7 @@ module ActiveSupport
|
|
7
7
|
# Time#advance, respectively. It mainly supports the methods on Numeric.
|
8
8
|
#
|
9
9
|
# 1.month.ago # equivalent to Time.now.advance(months: -1)
|
10
|
-
class Duration
|
10
|
+
class Duration
|
11
11
|
attr_accessor :value, :parts
|
12
12
|
|
13
13
|
def initialize(value, parts) #:nodoc:
|
@@ -39,6 +39,10 @@ module ActiveSupport
|
|
39
39
|
end
|
40
40
|
alias :kind_of? :is_a?
|
41
41
|
|
42
|
+
def instance_of?(klass) # :nodoc:
|
43
|
+
Duration == klass || value.instance_of?(klass)
|
44
|
+
end
|
45
|
+
|
42
46
|
# Returns +true+ if +other+ is also a Duration instance with the
|
43
47
|
# same +value+, or if <tt>other == value</tt>.
|
44
48
|
def ==(other)
|
@@ -49,8 +53,14 @@ module ActiveSupport
|
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
56
|
+
def to_s
|
57
|
+
@value.to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns +true+ if +other+ is also a Duration instance, which has the
|
61
|
+
# same parts as this one.
|
52
62
|
def eql?(other)
|
53
|
-
|
63
|
+
Duration === other && other.value.eql?(value)
|
54
64
|
end
|
55
65
|
|
56
66
|
def self.===(other) #:nodoc:
|
@@ -85,6 +95,10 @@ module ActiveSupport
|
|
85
95
|
to_i
|
86
96
|
end
|
87
97
|
|
98
|
+
def respond_to_missing?(method, include_private=false) #:nodoc
|
99
|
+
@value.respond_to?(method, include_private)
|
100
|
+
end
|
101
|
+
|
88
102
|
protected
|
89
103
|
|
90
104
|
def sum(sign, time = ::Time.current) #:nodoc:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ActiveSupport
|
2
|
-
# Returns the version of the currently loaded
|
2
|
+
# Returns the version of the currently loaded Active Support as a <tt>Gem::Version</tt>
|
3
3
|
def self.gem_version
|
4
4
|
Gem::Version.new VERSION::STRING
|
5
5
|
end
|
@@ -8,7 +8,7 @@ module ActiveSupport
|
|
8
8
|
MAJOR = 4
|
9
9
|
MINOR = 2
|
10
10
|
TINY = 0
|
11
|
-
PRE = "
|
11
|
+
PRE = "beta2"
|
12
12
|
|
13
13
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
14
14
|
end
|
@@ -91,7 +91,7 @@ module ActiveSupport
|
|
91
91
|
def underscore(camel_cased_word)
|
92
92
|
return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
|
93
93
|
word = camel_cased_word.to_s.gsub('::', '/')
|
94
|
-
word.gsub!(/(?:([A-Za-z\d])
|
94
|
+
word.gsub!(/(?:([A-Za-z\d])|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
|
95
95
|
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
|
96
96
|
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
97
97
|
word.tr!("-", "_")
|
@@ -27,6 +27,7 @@ module ActiveSupport
|
|
27
27
|
class InvalidSignature < StandardError; end
|
28
28
|
|
29
29
|
def initialize(secret, options = {})
|
30
|
+
raise ArgumentError, 'Secret should not be nil.' unless secret
|
30
31
|
@secret = secret
|
31
32
|
@digest = options[:digest] || 'SHA1'
|
32
33
|
@serializer = options[:serializer] || Marshal
|
@@ -42,7 +42,6 @@ module ActiveSupport
|
|
42
42
|
0x0085, # White_Space # Cc <control-0085>
|
43
43
|
0x00A0, # White_Space # Zs NO-BREAK SPACE
|
44
44
|
0x1680, # White_Space # Zs OGHAM SPACE MARK
|
45
|
-
0x180E, # White_Space # Zs MONGOLIAN VOWEL SEPARATOR
|
46
45
|
(0x2000..0x200A).to_a, # White_Space # Zs [11] EN QUAD..HAIR SPACE
|
47
46
|
0x2028, # White_Space # Zl LINE SEPARATOR
|
48
47
|
0x2029, # White_Space # Zp PARAGRAPH SEPARATOR
|
@@ -33,7 +33,7 @@ module ActiveSupport
|
|
33
33
|
a, b = s.split('.', 2)
|
34
34
|
a + '.' + b[0, precision]
|
35
35
|
else
|
36
|
-
"%
|
36
|
+
"%00.#{precision}f" % rounded_number
|
37
37
|
end
|
38
38
|
|
39
39
|
delimited_number = NumberToDelimitedConverter.convert(formatted_string, options)
|
@@ -59,7 +59,7 @@ module ActiveSupport
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def digit_count(number)
|
62
|
-
(Math.log10(absolute_number(number)) + 1).floor
|
62
|
+
number.zero? ? 1 : (Math.log10(absolute_number(number)) + 1).floor
|
63
63
|
end
|
64
64
|
|
65
65
|
def strip_insignificant_zeros
|
@@ -16,6 +16,35 @@ module ActiveSupport
|
|
16
16
|
Assertion = Minitest::Assertion
|
17
17
|
|
18
18
|
class << self
|
19
|
+
def test_order=(new_order)
|
20
|
+
ActiveSupport.test_order = new_order
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_order
|
24
|
+
test_order = ActiveSupport.test_order
|
25
|
+
|
26
|
+
if test_order.nil?
|
27
|
+
ActiveSupport::Deprecation.warn "You did not specify a value for the " \
|
28
|
+
"configuration option 'active_support.test_order'. In Rails 5.0, " \
|
29
|
+
"the default value of this option will change from `:sorted` to " \
|
30
|
+
"`:random`.\n" \
|
31
|
+
"To disable this warning and keep the current behavior, you can add " \
|
32
|
+
"the following line to your `config/environments/test.rb`:\n" \
|
33
|
+
"\n" \
|
34
|
+
" Rails.application.configure do\n" \
|
35
|
+
" config.active_support.test_order = :sorted\n" \
|
36
|
+
" end\n" \
|
37
|
+
"\n" \
|
38
|
+
"Alternatively, you can opt into the future behavior by setting this " \
|
39
|
+
"option to `:random`."
|
40
|
+
|
41
|
+
test_order = :sorted
|
42
|
+
self.test_order = test_order
|
43
|
+
end
|
44
|
+
|
45
|
+
test_order
|
46
|
+
end
|
47
|
+
|
19
48
|
alias :my_tests_are_order_dependent! :i_suck_and_my_tests_are_order_dependent!
|
20
49
|
end
|
21
50
|
|
@@ -36,12 +36,8 @@ module ActiveSupport
|
|
36
36
|
while names.size > 0 do
|
37
37
|
names.last.sub!(/Test$/, "")
|
38
38
|
begin
|
39
|
-
constant = names.join("::").
|
39
|
+
constant = names.join("::").safe_constantize
|
40
40
|
break(constant) if yield(constant)
|
41
|
-
rescue NoMethodError # subclass of NameError
|
42
|
-
raise
|
43
|
-
rescue NameError
|
44
|
-
# Constant wasn't found, move on
|
45
41
|
ensure
|
46
42
|
names.pop
|
47
43
|
end
|
@@ -276,8 +276,8 @@ module ActiveSupport
|
|
276
276
|
if @utc_offset
|
277
277
|
@utc_offset
|
278
278
|
else
|
279
|
-
@current_period ||= tzinfo.
|
280
|
-
@current_period.
|
279
|
+
@current_period ||= tzinfo.current_period if tzinfo
|
280
|
+
@current_period.utc_offset if @current_period
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
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: 4.2.0.
|
4
|
+
version: 4.2.0.beta2
|
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: 2014-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|