activesupport 4.2.11.3 → 5.0.7.2
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 +678 -348
- data/MIT-LICENSE +2 -2
- data/README.rdoc +2 -3
- data/lib/active_support/array_inquirer.rb +44 -0
- data/lib/active_support/backtrace_cleaner.rb +1 -1
- data/lib/active_support/benchmarkable.rb +1 -1
- data/lib/active_support/cache/file_store.rb +36 -22
- data/lib/active_support/cache/mem_cache_store.rb +63 -54
- data/lib/active_support/cache/memory_store.rb +16 -21
- data/lib/active_support/cache/null_store.rb +1 -4
- data/lib/active_support/cache/strategy/local_cache.rb +31 -20
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +4 -4
- data/lib/active_support/cache.rb +71 -87
- data/lib/active_support/callbacks.rb +109 -113
- data/lib/active_support/concern.rb +1 -1
- data/lib/active_support/concurrency/latch.rb +11 -12
- data/lib/active_support/concurrency/share_lock.rb +226 -0
- data/lib/active_support/configurable.rb +1 -0
- data/lib/active_support/core_ext/array/access.rb +27 -1
- data/lib/active_support/core_ext/array/conversions.rb +6 -4
- data/lib/active_support/core_ext/array/grouping.rb +9 -18
- data/lib/active_support/core_ext/array/inquiry.rb +17 -0
- data/lib/active_support/core_ext/array/wrap.rb +5 -4
- data/lib/active_support/core_ext/array.rb +1 -0
- data/lib/active_support/core_ext/big_decimal/conversions.rb +8 -10
- data/lib/active_support/core_ext/class/attribute.rb +10 -9
- data/lib/active_support/core_ext/class/subclasses.rb +3 -2
- data/lib/active_support/core_ext/class.rb +0 -1
- data/lib/active_support/core_ext/date/blank.rb +12 -0
- data/lib/active_support/core_ext/date/calculations.rb +1 -1
- data/lib/active_support/core_ext/date/conversions.rb +7 -6
- data/lib/active_support/core_ext/date.rb +1 -1
- data/lib/active_support/core_ext/date_and_time/calculations.rb +100 -27
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +0 -1
- data/lib/active_support/core_ext/date_and_time/zones.rb +3 -4
- data/lib/active_support/core_ext/date_time/blank.rb +12 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +14 -8
- data/lib/active_support/core_ext/date_time/conversions.rb +2 -0
- data/lib/active_support/core_ext/date_time.rb +1 -1
- data/lib/active_support/core_ext/enumerable.rb +75 -25
- data/lib/active_support/core_ext/file/atomic.rb +30 -25
- data/lib/active_support/core_ext/hash/conversions.rb +22 -2
- data/lib/active_support/core_ext/hash/deep_merge.rb +1 -1
- data/lib/active_support/core_ext/hash/except.rb +9 -8
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -1
- data/lib/active_support/core_ext/hash/keys.rb +25 -21
- data/lib/active_support/core_ext/hash/slice.rb +1 -1
- data/lib/active_support/core_ext/hash/transform_values.rb +11 -5
- data/lib/active_support/core_ext/integer/time.rb +2 -2
- data/lib/active_support/core_ext/kernel/concern.rb +2 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +3 -10
- data/lib/active_support/core_ext/kernel/reporting.rb +2 -84
- data/lib/active_support/core_ext/kernel.rb +0 -1
- data/lib/active_support/core_ext/load_error.rb +5 -2
- data/lib/active_support/core_ext/marshal.rb +7 -9
- data/lib/active_support/core_ext/module/aliasing.rb +6 -1
- data/lib/active_support/core_ext/module/anonymous.rb +10 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -5
- data/lib/active_support/core_ext/module/attribute_accessors.rb +15 -15
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +141 -0
- data/lib/active_support/core_ext/module/concerning.rb +4 -4
- data/lib/active_support/core_ext/module/delegation.rb +11 -20
- data/lib/active_support/core_ext/module/deprecation.rb +2 -2
- data/lib/active_support/core_ext/module/introspection.rb +8 -2
- data/lib/active_support/core_ext/module/method_transplanting.rb +3 -13
- data/lib/active_support/core_ext/module/qualified_const.rb +30 -12
- data/lib/active_support/core_ext/module/remove_method.rb +23 -0
- data/lib/active_support/core_ext/module.rb +1 -0
- data/lib/active_support/core_ext/name_error.rb +15 -2
- data/lib/active_support/core_ext/numeric/bytes.rb +20 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +78 -77
- data/lib/active_support/core_ext/numeric/inquiry.rb +26 -0
- data/lib/active_support/core_ext/numeric/time.rb +26 -6
- data/lib/active_support/core_ext/numeric.rb +1 -0
- data/lib/active_support/core_ext/object/blank.rb +15 -3
- data/lib/active_support/core_ext/object/deep_dup.rb +10 -3
- data/lib/active_support/core_ext/object/duplicable.rb +7 -12
- data/lib/active_support/core_ext/object/inclusion.rb +2 -2
- data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +15 -7
- data/lib/active_support/core_ext/object/to_query.rb +1 -1
- data/lib/active_support/core_ext/object/try.rb +67 -21
- data/lib/active_support/core_ext/object/with_options.rb +1 -1
- data/lib/active_support/core_ext/object.rb +0 -1
- data/lib/active_support/core_ext/range/conversions.rb +18 -6
- data/lib/active_support/core_ext/range/each.rb +16 -18
- data/lib/active_support/core_ext/range/include_range.rb +20 -20
- data/lib/active_support/core_ext/securerandom.rb +23 -0
- data/lib/active_support/core_ext/string/behavior.rb +1 -1
- data/lib/active_support/core_ext/string/conversions.rb +3 -2
- data/lib/active_support/core_ext/string/filters.rb +1 -2
- data/lib/active_support/core_ext/string/inflections.rb +32 -5
- data/lib/active_support/core_ext/string/multibyte.rb +11 -7
- data/lib/active_support/core_ext/string/output_safety.rb +12 -14
- data/lib/active_support/core_ext/string/strip.rb +3 -6
- data/lib/active_support/core_ext/struct.rb +3 -6
- data/lib/active_support/core_ext/time/calculations.rb +18 -9
- data/lib/active_support/core_ext/time/conversions.rb +4 -2
- data/lib/active_support/core_ext/time/marshal.rb +2 -29
- data/lib/active_support/core_ext/time/zones.rb +36 -4
- data/lib/active_support/core_ext/time.rb +0 -1
- data/lib/active_support/core_ext/uri.rb +1 -3
- data/lib/active_support/core_ext.rb +2 -1
- data/lib/active_support/dependencies/interlock.rb +55 -0
- data/lib/active_support/dependencies.rb +88 -95
- data/lib/active_support/deprecation/behaviors.rb +15 -1
- data/lib/active_support/deprecation/instance_delegator.rb +13 -0
- data/lib/active_support/deprecation/method_wrappers.rb +42 -16
- data/lib/active_support/deprecation/proxy_wrappers.rb +47 -24
- data/lib/active_support/deprecation/reporting.rb +23 -5
- data/lib/active_support/deprecation.rb +1 -1
- data/lib/active_support/duration/iso8601_parser.rb +122 -0
- data/lib/active_support/duration/iso8601_serializer.rb +51 -0
- data/lib/active_support/duration.rb +90 -15
- data/lib/active_support/evented_file_update_checker.rb +199 -0
- data/lib/active_support/execution_wrapper.rb +126 -0
- data/lib/active_support/executor.rb +6 -0
- data/lib/active_support/file_update_checker.rb +23 -3
- data/lib/active_support/gem_version.rb +5 -5
- data/lib/active_support/gzip.rb +1 -1
- data/lib/active_support/hash_with_indifferent_access.rb +40 -11
- data/lib/active_support/i18n_railtie.rb +25 -4
- data/lib/active_support/inflector/inflections.rb +36 -5
- data/lib/active_support/inflector/methods.rb +97 -90
- data/lib/active_support/inflector/transliterate.rb +36 -21
- data/lib/active_support/json/decoding.rb +11 -10
- data/lib/active_support/json/encoding.rb +1 -51
- data/lib/active_support/key_generator.rb +7 -9
- data/lib/active_support/lazy_load_hooks.rb +46 -18
- data/lib/active_support/locale/en.yml +2 -0
- data/lib/active_support/log_subscriber/test_helper.rb +3 -3
- data/lib/active_support/log_subscriber.rb +1 -1
- data/lib/active_support/logger.rb +3 -4
- data/lib/active_support/logger_silence.rb +2 -1
- data/lib/active_support/logger_thread_safe_level.rb +2 -3
- data/lib/active_support/message_encryptor.rb +7 -7
- data/lib/active_support/message_verifier.rb +70 -8
- data/lib/active_support/multibyte/chars.rb +12 -3
- data/lib/active_support/multibyte/unicode.rb +44 -21
- data/lib/active_support/notifications/fanout.rb +5 -5
- data/lib/active_support/notifications/instrumenter.rb +20 -2
- data/lib/active_support/notifications.rb +2 -2
- data/lib/active_support/number_helper/number_to_currency_converter.rb +7 -9
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +8 -3
- data/lib/active_support/number_helper/number_to_human_converter.rb +6 -4
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -2
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +11 -2
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +30 -25
- data/lib/active_support/number_helper.rb +90 -67
- data/lib/active_support/ordered_hash.rb +1 -1
- data/lib/active_support/ordered_options.rb +15 -1
- data/lib/active_support/per_thread_registry.rb +3 -0
- data/lib/active_support/rails.rb +2 -2
- data/lib/active_support/railtie.rb +6 -1
- data/lib/active_support/reloader.rb +129 -0
- data/lib/active_support/rescuable.rb +101 -47
- data/lib/active_support/string_inquirer.rb +1 -1
- data/lib/active_support/subscriber.rb +5 -10
- data/lib/active_support/tagged_logging.rb +8 -7
- data/lib/active_support/test_case.rb +17 -29
- data/lib/active_support/testing/assertions.rb +15 -13
- data/lib/active_support/testing/deprecation.rb +9 -8
- data/lib/active_support/testing/file_fixtures.rb +34 -0
- data/lib/active_support/testing/isolation.rb +22 -8
- data/lib/active_support/testing/method_call_assertions.rb +41 -0
- data/lib/active_support/testing/stream.rb +42 -0
- data/lib/active_support/testing/time_helpers.rb +3 -1
- data/lib/active_support/time_with_zone.rb +123 -33
- data/lib/active_support/values/time_zone.rb +101 -47
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/xml_mini/jdom.rb +1 -1
- data/lib/active_support/xml_mini/libxml.rb +2 -2
- data/lib/active_support/xml_mini/nokogiri.rb +2 -2
- data/lib/active_support.rb +11 -6
- metadata +36 -17
- data/lib/active_support/core_ext/big_decimal/yaml_conversions.rb +0 -16
- data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -45
- data/lib/active_support/core_ext/date_time/zones.rb +0 -6
- data/lib/active_support/core_ext/object/itself.rb +0 -15
- data/lib/active_support/core_ext/thread.rb +0 -86
data/CHANGELOG.md
CHANGED
@@ -1,29 +1,77 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 5.0.7.2 (March 11, 2019) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails
|
6
|
+
## Rails 5.0.7.1 (November 27, 2018) ##
|
7
7
|
|
8
8
|
* No changes.
|
9
9
|
|
10
10
|
|
11
|
-
## Rails
|
11
|
+
## Rails 5.0.7 (March 29, 2018) ##
|
12
|
+
|
13
|
+
* Return all mappings for a timezone identifier in `country_zones`
|
14
|
+
|
15
|
+
Some timezones like `Europe/London` have multiple mappings in
|
16
|
+
`ActiveSupport::TimeZone::MAPPING` so return all of them instead
|
17
|
+
of the first one found by using `Hash#value`. e.g:
|
18
|
+
|
19
|
+
# Before
|
20
|
+
ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]
|
21
|
+
|
22
|
+
# After
|
23
|
+
ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]
|
24
|
+
|
25
|
+
Fixes #31668.
|
26
|
+
|
27
|
+
*Andrew White*
|
28
|
+
|
29
|
+
|
30
|
+
## Rails 5.0.6 (September 07, 2017) ##
|
12
31
|
|
13
32
|
* No changes.
|
14
33
|
|
15
34
|
|
16
|
-
## Rails
|
35
|
+
## Rails 5.0.6.rc1 (August 24, 2017) ##
|
17
36
|
|
18
37
|
* No changes.
|
19
38
|
|
20
39
|
|
21
|
-
## Rails
|
40
|
+
## Rails 5.0.5 (July 31, 2017) ##
|
22
41
|
|
23
42
|
* No changes.
|
24
43
|
|
25
44
|
|
26
|
-
## Rails
|
45
|
+
## Rails 5.0.5.rc2 (July 25, 2017) ##
|
46
|
+
|
47
|
+
* No changes.
|
48
|
+
|
49
|
+
|
50
|
+
## Rails 5.0.5.rc1 (July 19, 2017) ##
|
51
|
+
|
52
|
+
* No changes.
|
53
|
+
|
54
|
+
|
55
|
+
## Rails 5.0.4 (June 19, 2017) ##
|
56
|
+
|
57
|
+
* No changes.
|
58
|
+
|
59
|
+
|
60
|
+
## Rails 5.0.3 (May 12, 2017) ##
|
61
|
+
|
62
|
+
* `ActiveSupport::EventedFileUpdateChecker` no longer listens to
|
63
|
+
directories outside of the application directory.
|
64
|
+
|
65
|
+
*radiospiel*
|
66
|
+
|
67
|
+
* Return unmapped timezones from `country_zones`
|
68
|
+
|
69
|
+
If a country doesn't exist in the MAPPINGS hash then create a new
|
70
|
+
`ActiveSupport::Timezone` instance using the supplied timezone id.
|
71
|
+
|
72
|
+
Fixes #28431.
|
73
|
+
|
74
|
+
*Andrew White*
|
27
75
|
|
28
76
|
* Fixed bug in `DateAndTime::Compatibility#to_time` that caused it to
|
29
77
|
raise `RuntimeError: can't modify frozen Time` when called on any frozen `Time`.
|
@@ -32,16 +80,21 @@
|
|
32
80
|
|
33
81
|
*Kevin McPhillips* & *Andrew White*
|
34
82
|
|
35
|
-
*
|
83
|
+
* Fix inconsistent results when parsing large durations and constructing durations from code
|
36
84
|
|
37
|
-
|
38
|
-
consistent with the new `DateTime#localtime` method. When these changes were
|
39
|
-
backported in #27553 this inadvertently changed the return type in a patcn
|
40
|
-
release. Since `DateTime#localtime` was new in Rails 4.2.8 it's okay to
|
41
|
-
restore the return type of `DateTime#utc` but keep `DateTime#localtime` as
|
42
|
-
returning `Time` without breaking backwards compatibility.
|
85
|
+
ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true
|
43
86
|
|
44
|
-
|
87
|
+
Duration parsing made independent from any moment of time:
|
88
|
+
Fixed length in seconds is assigned to each duration part during parsing.
|
89
|
+
|
90
|
+
Methods on `Numeric` like `2.days` now use these predefined durations
|
91
|
+
to avoid duplicating of duration constants through the codebase and
|
92
|
+
eliminate creation of intermediate durations.
|
93
|
+
|
94
|
+
*Andrey Novikov, Andrew White*
|
95
|
+
|
96
|
+
|
97
|
+
## Rails 5.0.2 (March 01, 2017) ##
|
45
98
|
|
46
99
|
* In Core Extensions, make `MarshalWithAutoloading#load` pass through the second, optional
|
47
100
|
argument for `Marshal#load( source [, proc] )`. This way we don't have to do
|
@@ -49,17 +102,170 @@
|
|
49
102
|
|
50
103
|
*Jeff Latz*
|
51
104
|
|
105
|
+
* `ActiveSupport::Gzip.decompress` now checks checksum and length in footer.
|
106
|
+
|
107
|
+
*Dylan Thacker-Smith*
|
108
|
+
|
52
109
|
* Cache `ActiveSupport::TimeWithZone#to_datetime` before freezing.
|
53
110
|
|
54
111
|
*Adam Rice*
|
55
112
|
|
56
|
-
* `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
|
57
|
-
`Time.now` and `Date.today`.
|
58
113
|
|
59
|
-
|
114
|
+
## Rails 5.0.1 (December 21, 2016) ##
|
115
|
+
|
116
|
+
* No changes.
|
117
|
+
|
118
|
+
|
119
|
+
## Rails 5.0.1.rc2 (December 10, 2016) ##
|
120
|
+
|
121
|
+
* No changes.
|
122
|
+
|
123
|
+
|
124
|
+
## Rails 5.0.1.rc1 (December 01, 2016) ##
|
125
|
+
|
126
|
+
* Ensure duration parsing is consistent across DST changes
|
127
|
+
|
128
|
+
Previously `ActiveSupport::Duration.parse` used `Time.current` and
|
129
|
+
`Time#advance` to calculate the number of seconds in the duration
|
130
|
+
from an arbitrary collection of parts. However as `advance` tries to
|
131
|
+
be consistent across DST boundaries this meant that either the
|
132
|
+
duration was shorter or longer depending on the time of year.
|
133
|
+
|
134
|
+
This was fixed by using an absolute reference point in UTC which
|
135
|
+
isn't subject to DST transitions. An arbitrary date of Jan 1st, 2000
|
136
|
+
was chosen for no other reason that it seemed appropriate.
|
137
|
+
|
138
|
+
Additionally, duration parsing should now be marginally faster as we
|
139
|
+
are no longer creating instances of `ActiveSupport::TimeWithZone`
|
140
|
+
every time we parse a duration string.
|
141
|
+
|
142
|
+
Fixes #26941.
|
143
|
+
|
144
|
+
*Andrew White*
|
145
|
+
|
146
|
+
* Fix `DateAndTime::Calculations#copy_time_to`. Copy `nsec` instead of `usec`.
|
147
|
+
|
148
|
+
Jumping forward or backward between weeks now preserves nanosecond digits.
|
60
149
|
|
150
|
+
*Josua Schmid*
|
61
151
|
|
62
|
-
|
152
|
+
* Avoid bumping the class serial when invoking executor.
|
153
|
+
|
154
|
+
*Matthew Draper*
|
155
|
+
|
156
|
+
* Fix `ActiveSupport::TimeWithZone#in` across DST boundaries.
|
157
|
+
|
158
|
+
Previously calls to `in` were being sent to the non-DST aware
|
159
|
+
method `Time#since` via `method_missing`. It is now aliased to
|
160
|
+
the DST aware `ActiveSupport::TimeWithZone#+` which handles
|
161
|
+
transitions across DST boundaries, e.g:
|
162
|
+
|
163
|
+
Time.zone = "US/Eastern"
|
164
|
+
|
165
|
+
t = Time.zone.local(2016,11,6,1)
|
166
|
+
# => Sun, 06 Nov 2016 01:00:00 EDT -05:00
|
167
|
+
|
168
|
+
t.in(1.hour)
|
169
|
+
# => Sun, 06 Nov 2016 01:00:00 EST -05:00
|
170
|
+
|
171
|
+
Fixes #26580.
|
172
|
+
|
173
|
+
*Thomas Balthazar*
|
174
|
+
|
175
|
+
* Fix `thread_mattr_accessor` subclass no longer overwrites parent.
|
176
|
+
|
177
|
+
Assigning a value to a subclass using `thread_mattr_accessor` no
|
178
|
+
longer changes the value of the parent class. This brings the
|
179
|
+
behavior inline with the documentation.
|
180
|
+
|
181
|
+
Given:
|
182
|
+
|
183
|
+
class Account
|
184
|
+
thread_mattr_accessor :user
|
185
|
+
end
|
186
|
+
|
187
|
+
class Customer < Account
|
188
|
+
end
|
189
|
+
|
190
|
+
Account.user = "DHH"
|
191
|
+
Customer.user = "Rafael"
|
192
|
+
|
193
|
+
Before:
|
194
|
+
|
195
|
+
Account.user # => "Rafael"
|
196
|
+
|
197
|
+
After:
|
198
|
+
|
199
|
+
Account.user # => "DHH"
|
200
|
+
|
201
|
+
*Shinichi Maeshima*
|
202
|
+
|
203
|
+
* Since weeks are no longer converted to days, add `:weeks` to the list of
|
204
|
+
parts that `ActiveSupport::TimeWithZone` will recognize as possibly being
|
205
|
+
of variable duration to take account of DST transitions.
|
206
|
+
|
207
|
+
Fixes #26039.
|
208
|
+
|
209
|
+
*Andrew White*
|
210
|
+
|
211
|
+
* Fix `ActiveSupport::TimeZone#strptime`. Now raises `ArgumentError` when the
|
212
|
+
given time doesn't match the format. The error is the same as the one given
|
213
|
+
by Ruby's `Date.strptime`. Previously it raised
|
214
|
+
`NoMethodError: undefined method empty? for nil:NilClass.` due to a bug.
|
215
|
+
|
216
|
+
Fixes #25701.
|
217
|
+
|
218
|
+
*John Gesimondo*
|
219
|
+
|
220
|
+
|
221
|
+
## Rails 5.0.0 (June 30, 2016) ##
|
222
|
+
|
223
|
+
* Support parsing JSON time in ISO8601 local time strings in
|
224
|
+
`ActiveSupport::JSON.decode` when `parse_json_times` is enabled.
|
225
|
+
Strings in the format of `YYYY-MM-DD hh:mm:ss` (without a `Z` at
|
226
|
+
the end) will be parsed in the local timezone (`Time.zone`). In
|
227
|
+
addition, date strings (`YYYY-MM-DD`) are now parsed into `Date`
|
228
|
+
objects.
|
229
|
+
|
230
|
+
*Grzegorz Witek*
|
231
|
+
|
232
|
+
* `Date.to_s` doesn't produce too many spaces. For example, `to_s(:short)`
|
233
|
+
will now produce `01 Feb` instead of ` 1 Feb`.
|
234
|
+
|
235
|
+
Fixes #25251.
|
236
|
+
|
237
|
+
*Sean Griffin*
|
238
|
+
|
239
|
+
* Rescuable: If a handler doesn't match the exception, check for handlers
|
240
|
+
matching the exception's cause.
|
241
|
+
|
242
|
+
*Jeremy Daer*
|
243
|
+
|
244
|
+
* `ActiveSupport::Duration` supports weeks and hours.
|
245
|
+
|
246
|
+
[1.hour.inspect, 1.hour.value, 1.hour.parts]
|
247
|
+
# => ["3600 seconds", 3600, [[:seconds, 3600]]] # Before
|
248
|
+
# => ["1 hour", 3600, [[:hours, 1]]] # After
|
249
|
+
|
250
|
+
[1.week.inspect, 1.week.value, 1.week.parts]
|
251
|
+
# => ["7 days", 604800, [[:days, 7]]] # Before
|
252
|
+
# => ["1 week", 604800, [[:weeks, 1]]] # After
|
253
|
+
|
254
|
+
This brings us into closer conformance with ISO8601 and relieves some
|
255
|
+
astonishment about getting `1.hour.inspect # => 3600 seconds`.
|
256
|
+
|
257
|
+
Compatibility: The duration's `value` remains the same, so apps using
|
258
|
+
durations are oblivious to the new time periods. Apps, libraries, and
|
259
|
+
plugins that work with the internal `parts` hash will need to broaden
|
260
|
+
their time period handling to cover hours & weeks.
|
261
|
+
|
262
|
+
*Andrey Novikov*
|
263
|
+
|
264
|
+
* Time zones: Ensure that the UTC offset reflects DST changes that occurred
|
265
|
+
since the app started. Removes UTC offset caching, reducing performance,
|
266
|
+
but this is still relatively quick and isn't in any hot paths.
|
267
|
+
|
268
|
+
*Alexey Shein*
|
63
269
|
|
64
270
|
* Make `getlocal` and `getutc` always return instances of `Time` for
|
65
271
|
`ActiveSupport::TimeWithZone` and `DateTime`. This eliminates a possible
|
@@ -111,578 +317,702 @@
|
|
111
317
|
|
112
318
|
*Andrew White*
|
113
319
|
|
114
|
-
*
|
320
|
+
* `ActiveSupport::TimeZone.country_zones(country_code)` looks up the
|
321
|
+
country's time zones by its two-letter ISO3166 country code, e.g.
|
322
|
+
|
323
|
+
>> ActiveSupport::TimeZone.country_zones(:jp).map(&:to_s)
|
324
|
+
=> ["(GMT+09:00) Osaka"]
|
115
325
|
|
116
|
-
|
117
|
-
|
118
|
-
of your application at the same time to carry out A/B testing.
|
326
|
+
>> ActiveSupport::TimeZone.country_zones(:uy).map(&:to_s)
|
327
|
+
=> ["(GMT-03:00) Montevideo"]
|
119
328
|
|
120
|
-
|
121
|
-
change in 3aa26cf didn't meet this criteria because the Psych loader
|
122
|
-
checks for the existence of `init_with` before setting the instance
|
123
|
-
variables and the wrapping behavior of `ActiveSupport::TimeWithZone`
|
124
|
-
tries to see if the `Time` instance responds to `init_with` before the
|
125
|
-
`@time` variable is set.
|
329
|
+
*Andrey Novikov*
|
126
330
|
|
127
|
-
|
128
|
-
in 3aa26cf. If the revived instance is then written out to YAML again
|
129
|
-
it will revert to the default Rails 4.2 behavior of converting it to
|
130
|
-
a UTC timestamp string.
|
331
|
+
* `Array#sum` compat with Ruby 2.4's native method.
|
131
332
|
|
132
|
-
|
333
|
+
Ruby 2.4 introduces `Array#sum`, but it only supports numeric elements,
|
334
|
+
breaking our `Enumerable#sum` which supports arbitrary `Object#+`.
|
335
|
+
To fix, override `Array#sum` with our compatible implementation.
|
133
336
|
|
134
|
-
|
337
|
+
Native Ruby 2.4:
|
135
338
|
|
136
|
-
|
339
|
+
%w[ a b ].sum
|
340
|
+
# => TypeError: String can't be coerced into Fixnum
|
137
341
|
|
138
|
-
|
139
|
-
method `Time#since` via `method_missing`. It is now aliased to
|
140
|
-
the DST aware `ActiveSupport::TimeWithZone#since` which handles
|
141
|
-
transitions across DST boundaries, e.g:
|
342
|
+
With `Enumerable#sum` shim:
|
142
343
|
|
143
|
-
|
344
|
+
%w[ a b ].sum
|
345
|
+
# => 'ab'
|
144
346
|
|
145
|
-
|
146
|
-
|
347
|
+
We tried shimming the fast path and falling back to the compatible path
|
348
|
+
if it fails, but that ends up slower even in simple cases due to the cost
|
349
|
+
of exception handling. Our only choice is to override the native `Array#sum`
|
350
|
+
with our `Enumerable#sum`.
|
147
351
|
|
148
|
-
|
149
|
-
# => Sun, 06 Nov 2016 01:00:00 EST -05:00
|
352
|
+
*Jeremy Daer*
|
150
353
|
|
151
|
-
|
354
|
+
* `ActiveSupport::Duration` supports ISO8601 formatting and parsing.
|
152
355
|
|
153
|
-
|
356
|
+
ActiveSupport::Duration.parse('P3Y6M4DT12H30M5S')
|
357
|
+
# => 3 years, 6 months, 4 days, 12 hours, 30 minutes, and 5 seconds
|
154
358
|
|
359
|
+
(3.years + 3.days).iso8601
|
360
|
+
# => "P3Y3D"
|
155
361
|
|
156
|
-
|
362
|
+
Inspired by Arnau Siches' [ISO8601 gem](https://github.com/arnau/ISO8601/)
|
363
|
+
and rewritten by Andrey Novikov with suggestions from Andrew White. Test
|
364
|
+
data from the ISO8601 gem redistributed under MIT license.
|
157
365
|
|
158
|
-
|
159
|
-
properly delegate to all loggers. Silencing now properly suppresses logging
|
160
|
-
to both the log and the console.
|
366
|
+
(Will be used to support the PostgreSQL interval data type.)
|
161
367
|
|
162
|
-
*
|
368
|
+
*Andrey Novikov*, *Arnau Siches*, *Andrew White*
|
163
369
|
|
164
|
-
*
|
165
|
-
|
370
|
+
* `Cache#fetch(key, force: true)` forces a cache miss, so it must be called
|
371
|
+
with a block to provide a new value to cache. Fetching with `force: true`
|
372
|
+
but without a block now raises ArgumentError.
|
166
373
|
|
167
|
-
|
374
|
+
cache.fetch('key', force: true) # => ArgumentError
|
168
375
|
|
169
|
-
*
|
170
|
-
on nil.
|
376
|
+
*Santosh Wadghule*
|
171
377
|
|
172
|
-
|
378
|
+
* Fix behavior of JSON encoding for `Exception`.
|
173
379
|
|
174
|
-
*
|
175
|
-
since the app started. Removes UTC offset caching, reducing performance,
|
176
|
-
but this is still relatively quick and isn't in any hot paths.
|
380
|
+
*namusyaka*
|
177
381
|
|
178
|
-
|
382
|
+
* Make `number_to_phone` format number with regexp pattern.
|
383
|
+
|
384
|
+
number_to_phone(18812345678, pattern: /(\d{3})(\d{4})(\d{4})/)
|
385
|
+
# => 188-1234-5678
|
386
|
+
|
387
|
+
*Pan Gaoyong*
|
388
|
+
|
389
|
+
* Match `String#to_time`'s behaviour to that of ruby's implementation for edge cases.
|
390
|
+
|
391
|
+
`nil` is now returned instead of the current date if the string provided does
|
392
|
+
contain time information, but none that is used to build the `Time` object.
|
393
|
+
|
394
|
+
Fixes #22958.
|
395
|
+
|
396
|
+
*Siim Liiser*
|
397
|
+
|
398
|
+
* Rely on the native DateTime#<=> implementation to handle non-datetime like
|
399
|
+
objects instead of returning `nil` ourselves. This restores the ability
|
400
|
+
of `DateTime` instances to be compared with a `Numeric` that represents an
|
401
|
+
astronomical julian day number.
|
402
|
+
|
403
|
+
Fixes #24228.
|
404
|
+
|
405
|
+
*Andrew White*
|
406
|
+
|
407
|
+
* Add `String#upcase_first` method.
|
408
|
+
|
409
|
+
*Glauco Custódio*, *bogdanvlviv*
|
179
410
|
|
180
411
|
* Prevent `Marshal.load` from looping infinitely when trying to autoload a constant
|
181
412
|
which resolves to a different name.
|
182
413
|
|
183
414
|
*Olek Janiszewski*
|
184
415
|
|
416
|
+
* Deprecate `Module.local_constants`. Please use `Module.constants(false)` instead.
|
185
417
|
|
186
|
-
|
418
|
+
*Yuichiro Kaneko*
|
187
419
|
|
188
|
-
*
|
420
|
+
* Publish `ActiveSupport::Executor` and `ActiveSupport::Reloader` APIs to allow
|
421
|
+
components and libraries to manage, and participate in, the execution of
|
422
|
+
application code, and the application reloading process.
|
189
423
|
|
424
|
+
*Matthew Draper*
|
190
425
|
|
191
|
-
|
426
|
+
* Deprecate arguments on `assert_nothing_raised`.
|
192
427
|
|
193
|
-
|
428
|
+
`assert_nothing_raised` does not assert the arguments that have been passed
|
429
|
+
in (usually a specific exception class) since the method only yields the
|
430
|
+
block. So as not to confuse the users that the arguments have meaning, they
|
431
|
+
are being deprecated.
|
194
432
|
|
433
|
+
*Tara Scherner de la Fuente*
|
195
434
|
|
196
|
-
|
435
|
+
* Make `benchmark('something', silence: true)` actually work.
|
197
436
|
|
198
|
-
*
|
437
|
+
*DHH*
|
199
438
|
|
439
|
+
* Add `#on_weekday?` method to `Date`, `Time`, and `DateTime`.
|
200
440
|
|
201
|
-
|
441
|
+
`#on_weekday?` returns `true` if the receiving date/time does not fall on a Saturday
|
442
|
+
or Sunday.
|
202
443
|
|
203
|
-
*
|
204
|
-
twz = DateTime.now.in_time_zone
|
205
|
-
twz.eql?(twz.dup) => true
|
444
|
+
*Vipul A M*
|
206
445
|
|
207
|
-
|
446
|
+
* Add `Array#second_to_last` and `Array#third_to_last` methods.
|
208
447
|
|
209
|
-
*
|
448
|
+
*Brian Christian*
|
210
449
|
|
211
|
-
*
|
450
|
+
* Fix regression in `Hash#dig` for HashWithIndifferentAccess.
|
212
451
|
|
213
|
-
*
|
452
|
+
*Jon Moss*
|
214
453
|
|
454
|
+
* Change `number_to_currency` behavior for checking negativity.
|
215
455
|
|
216
|
-
|
456
|
+
Used `to_f.negative` instead of using `to_f.phase` for checking negativity
|
457
|
+
of a number in number_to_currency helper.
|
458
|
+
This change works same for all cases except when number is "-0.0".
|
217
459
|
|
218
|
-
|
219
|
-
|
460
|
+
-0.0.to_f.negative? => false
|
461
|
+
-0.0.to_f.phase? => 3.14
|
220
462
|
|
221
|
-
|
463
|
+
This change reverts changes from https://github.com/rails/rails/pull/6512.
|
464
|
+
But it should be acceptable as we could not find any currency which
|
465
|
+
supports negative zeros.
|
222
466
|
|
223
|
-
*
|
467
|
+
*Prathamesh Sonpatki*, *Rafael Mendonça França*
|
224
468
|
|
225
|
-
*
|
226
|
-
`default_proc` is set, which could raise.
|
469
|
+
* Match `HashWithIndifferentAccess#default`'s behaviour with `Hash#default`.
|
227
470
|
|
228
|
-
*
|
471
|
+
*David Cornu*
|
229
472
|
|
230
|
-
*
|
473
|
+
* Adds `:exception_object` key to `ActiveSupport::Notifications::Instrumenter`
|
474
|
+
payload when an exception is raised.
|
231
475
|
|
232
|
-
|
476
|
+
Adds new key/value pair to payload when an exception is raised:
|
477
|
+
e.g. `:exception_object => #<RuntimeError: FAIL>`.
|
233
478
|
|
479
|
+
*Ryan T. Hosford*
|
234
480
|
|
235
|
-
|
481
|
+
* Support extended grapheme clusters and UAX 29.
|
236
482
|
|
237
|
-
*
|
483
|
+
*Adam Roben*
|
238
484
|
|
239
|
-
|
485
|
+
* Add petabyte and exabyte numeric conversion.
|
240
486
|
|
241
|
-
*
|
487
|
+
*Akshay Vishnoi*
|
242
488
|
|
243
|
-
|
489
|
+
* Add thread_m/cattr_accessor/reader/writer suite of methods for declaring class and module variables that live per-thread.
|
490
|
+
This makes it easy to declare per-thread globals that are encapsulated. Note: This is a sharp edge. A wild proliferation
|
491
|
+
of globals is A Bad Thing. But like other sharp tools, when it's right, it's right.
|
244
492
|
|
493
|
+
Here's an example of a simple event tracking system where the object being tracked needs not pass a creator that it
|
494
|
+
doesn't need itself along:
|
245
495
|
|
246
|
-
|
496
|
+
module Current
|
497
|
+
thread_mattr_accessor :account
|
498
|
+
thread_mattr_accessor :user
|
247
499
|
|
248
|
-
|
500
|
+
def self.reset() self.account = self.user = nil end
|
501
|
+
end
|
249
502
|
|
250
|
-
|
503
|
+
class ApplicationController < ActionController::Base
|
504
|
+
before_action :set_current
|
505
|
+
after_action { Current.reset }
|
251
506
|
|
252
|
-
|
507
|
+
private
|
508
|
+
def set_current
|
509
|
+
Current.account = Account.find(params[:account_id])
|
510
|
+
Current.user = Current.account.users.find(params[:user_id])
|
511
|
+
end
|
512
|
+
end
|
253
513
|
|
254
|
-
|
514
|
+
class MessagesController < ApplicationController
|
515
|
+
def create
|
516
|
+
@message = Message.create!(message_params)
|
517
|
+
end
|
518
|
+
end
|
255
519
|
|
256
|
-
|
520
|
+
class Message < ApplicationRecord
|
521
|
+
has_many :events
|
522
|
+
after_create :track_created
|
257
523
|
|
258
|
-
|
524
|
+
private
|
525
|
+
def track_created
|
526
|
+
events.create! origin: self, action: :create
|
527
|
+
end
|
528
|
+
end
|
259
529
|
|
530
|
+
class Event < ApplicationRecord
|
531
|
+
belongs_to :creator, class_name: 'User'
|
532
|
+
before_validation { self.creator ||= Current.user }
|
533
|
+
end
|
260
534
|
|
261
|
-
|
535
|
+
*DHH*
|
262
536
|
|
263
|
-
* Fixed a problem where String#truncate_words would get stuck with a complex
|
264
|
-
string.
|
265
537
|
|
266
|
-
|
538
|
+
* Deprecated `Module#qualified_const_` in favour of the builtin Module#const_
|
539
|
+
methods.
|
267
540
|
|
268
|
-
*
|
269
|
-
will be dumped as primitives:
|
541
|
+
*Genadi Samokovarov*
|
270
542
|
|
271
|
-
|
543
|
+
* Deprecate passing string to define callback.
|
272
544
|
|
273
|
-
|
274
|
-
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
|
275
|
-
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
|
276
|
-
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
|
277
|
-
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
|
545
|
+
*Yuichiro Kaneko*
|
278
546
|
|
279
|
-
|
547
|
+
* `ActiveSupport::Cache::Store#namespaced_key`,
|
548
|
+
`ActiveSupport::Cache::MemCachedStore#escape_key`, and
|
549
|
+
`ActiveSupport::Cache::FileStore#key_file_path`
|
550
|
+
are deprecated and replaced with `normalize_key` that now calls `super`.
|
280
551
|
|
281
|
-
|
282
|
-
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
|
283
|
-
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
|
284
|
-
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
|
285
|
-
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
|
552
|
+
`ActiveSupport::Cache::LocaleCache#set_cache_value` is deprecated and replaced with `write_cache_value`.
|
286
553
|
|
287
|
-
*
|
554
|
+
*Michael Grosser*
|
288
555
|
|
289
|
-
*
|
556
|
+
* Implements an evented file watcher to asynchronously detect changes in the
|
557
|
+
application source code, routes, locales, etc.
|
290
558
|
|
291
|
-
|
559
|
+
This watcher is disabled by default, applications my enable it in the configuration:
|
292
560
|
|
293
|
-
|
294
|
-
|
561
|
+
# config/environments/development.rb
|
562
|
+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
295
563
|
|
296
|
-
|
564
|
+
This feature depends on the [listen](https://github.com/guard/listen) gem:
|
297
565
|
|
566
|
+
group :development do
|
567
|
+
gem 'listen', '~> 3.0.5'
|
568
|
+
end
|
298
569
|
|
299
|
-
|
570
|
+
*Puneet Agarwal* and *Xavier Noria*
|
300
571
|
|
301
|
-
*
|
572
|
+
* Added `Time.days_in_year` to return the number of days in the given year, or the
|
573
|
+
current year if no argument is provided.
|
302
574
|
|
303
|
-
|
575
|
+
*Jon Pascoe*
|
304
576
|
|
305
|
-
|
577
|
+
* Updated `parameterize` to preserve the case of a string, optionally.
|
306
578
|
|
307
|
-
|
579
|
+
Example:
|
308
580
|
|
309
|
-
|
581
|
+
parameterize("Donald E. Knuth", separator: '_') # => "donald_e_knuth"
|
582
|
+
parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth"
|
310
583
|
|
311
|
-
*
|
312
|
-
it also now correctly handles escaped '%' characters placed just before time zone related directives.
|
584
|
+
*Swaathi Kakarla*
|
313
585
|
|
314
|
-
|
586
|
+
* `HashWithIndifferentAccess.new` respects the default value or proc on objects
|
587
|
+
that respond to `#to_hash`. `.new_from_hash_copying_default` simply invokes `.new`.
|
588
|
+
All calls to `.new_from_hash_copying_default` are replaced with `.new`.
|
315
589
|
|
316
|
-
*
|
590
|
+
*Gordon Chan*
|
317
591
|
|
318
|
-
|
592
|
+
* Change Integer#year to return a Fixnum instead of a Float to improve
|
593
|
+
consistency.
|
319
594
|
|
320
|
-
|
595
|
+
Integer#years returned a Float while the rest of the accompanying methods
|
596
|
+
(days, weeks, months, etc.) return a Fixnum.
|
321
597
|
|
322
|
-
|
598
|
+
Before:
|
323
599
|
|
324
|
-
|
600
|
+
1.year # => 31557600.0
|
325
601
|
|
326
|
-
|
602
|
+
After:
|
327
603
|
|
328
|
-
|
604
|
+
1.year # => 31557600
|
329
605
|
|
330
|
-
|
606
|
+
*Konstantinos Rousis*
|
331
607
|
|
332
|
-
|
333
|
-
just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their
|
334
|
-
parts may be different though.
|
608
|
+
* Handle invalid UTF-8 strings when HTML escaping.
|
335
609
|
|
336
|
-
|
337
|
-
|
610
|
+
Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8
|
611
|
+
strings in `ERB::Util.unwrapped_html_escape` and `ERB::Util.html_escape_once`.
|
612
|
+
Prevents user-entered input passed from a querystring into a form field from
|
613
|
+
causing invalid byte sequence errors.
|
338
614
|
|
339
|
-
*
|
615
|
+
*Grey Baker*
|
340
616
|
|
341
|
-
* `
|
342
|
-
|
617
|
+
* Update `ActiveSupport::Multibyte::Chars#slice!` to return `nil` if the
|
618
|
+
arguments are out of bounds, to mirror the behavior of `String#slice!`
|
343
619
|
|
344
|
-
*
|
620
|
+
*Gourav Tiwari*
|
345
621
|
|
346
|
-
* `
|
347
|
-
|
622
|
+
* Fix `number_to_human` so that 999999999 rounds to "1 Billion" instead of
|
623
|
+
"1000 Million".
|
348
624
|
|
349
|
-
*
|
625
|
+
*Max Jacobson*
|
350
626
|
|
351
|
-
*
|
352
|
-
|
353
|
-
to `:sorted` but will be changed to `:random` in Rails 5.0.
|
627
|
+
* Fix `ActiveSupport::Deprecation#deprecate_methods` to report using the
|
628
|
+
current deprecator instance, where applicable.
|
354
629
|
|
355
|
-
*
|
630
|
+
*Brandon Dunne*
|
356
631
|
|
357
|
-
*
|
358
|
-
are incorrectly parsed as camelCase.
|
632
|
+
* `Cache#fetch` instrumentation marks whether it was a `:hit`.
|
359
633
|
|
360
|
-
|
634
|
+
*Robin Clowers*
|
361
635
|
|
362
|
-
|
636
|
+
* `assert_difference` and `assert_no_difference` now returns the result of the
|
637
|
+
yielded block.
|
363
638
|
|
364
|
-
|
365
|
-
the time has an offset other than UTC or local.
|
639
|
+
Example:
|
366
640
|
|
367
|
-
|
641
|
+
post = assert_difference -> { Post.count }, 1 do
|
642
|
+
Post.create
|
643
|
+
end
|
368
644
|
|
369
|
-
*
|
370
|
-
hashes and arrays containing `Method` objects to be `deep_dup`ed.
|
645
|
+
*Lucas Mazza*
|
371
646
|
|
372
|
-
|
647
|
+
* Short-circuit `blank?` on date and time values since they are never blank.
|
373
648
|
|
374
|
-
|
375
|
-
which happens during constant autoloading.
|
649
|
+
Fixes #21657.
|
376
650
|
|
377
|
-
|
651
|
+
*Andrew White*
|
378
652
|
|
379
|
-
|
653
|
+
* Replaced deprecated `ThreadSafe::Cache` with its successor `Concurrent::Map` now that
|
654
|
+
the thread_safe gem has been merged into concurrent-ruby.
|
380
655
|
|
381
|
-
*
|
656
|
+
*Jerry D'Antonio*
|
382
657
|
|
383
|
-
|
658
|
+
* Updated Unicode version to 8.0.0
|
384
659
|
|
385
|
-
|
660
|
+
*Anshul Sharma*
|
386
661
|
|
387
|
-
|
662
|
+
* `number_to_currency` and `number_with_delimiter` now accept custom `delimiter_pattern` option
|
663
|
+
to handle placement of delimiter, to support currency formats like INR
|
388
664
|
|
389
|
-
|
665
|
+
Example:
|
390
666
|
|
391
|
-
|
392
|
-
|
393
|
-
internal value.
|
667
|
+
number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n")
|
668
|
+
# => '₹ 12,30,000.00'
|
394
669
|
|
395
|
-
*
|
670
|
+
*Vipul A M*
|
396
671
|
|
397
|
-
*
|
398
|
-
with per-second precision, not anything deeper than that.
|
672
|
+
* Deprecate `:prefix` option of `number_to_human_size` with no replacement.
|
399
673
|
|
400
|
-
*
|
674
|
+
*Jean Boussier*
|
401
675
|
|
402
|
-
* Fix
|
676
|
+
* Fix `TimeWithZone#eql?` to properly handle `TimeWithZone` created from `DateTime`:
|
677
|
+
twz = DateTime.now.in_time_zone
|
678
|
+
twz.eql?(twz.dup) => true
|
403
679
|
|
404
|
-
|
680
|
+
Fixes #14178.
|
405
681
|
|
406
|
-
*
|
682
|
+
*Roque Pinel*
|
407
683
|
|
408
|
-
|
684
|
+
* ActiveSupport::HashWithIndifferentAccess `select` and `reject` will now return
|
685
|
+
enumerator if called without block.
|
409
686
|
|
410
|
-
|
687
|
+
Fixes #20095.
|
411
688
|
|
412
|
-
*
|
413
|
-
explicit receiver in not passed.
|
689
|
+
*Bernard Potocki*
|
414
690
|
|
415
|
-
|
691
|
+
* Removed `ActiveSupport::Concurrency::Latch`, superseded by `Concurrent::CountDownLatch`
|
692
|
+
from the concurrent-ruby gem.
|
416
693
|
|
417
|
-
*
|
418
|
-
`active_support/core_ext/object/json` without requiring `active_support/json`.
|
694
|
+
*Jerry D'Antonio*
|
419
695
|
|
420
|
-
|
696
|
+
* Fix not calling `#default` on `HashWithIndifferentAccess#to_hash` when only
|
697
|
+
`default_proc` is set, which could raise.
|
421
698
|
|
422
|
-
*
|
699
|
+
*Simon Eskildsen*
|
423
700
|
|
424
|
-
*
|
701
|
+
* Fix setting `default_proc` on `HashWithIndifferentAccess#dup`.
|
425
702
|
|
426
|
-
*
|
703
|
+
*Simon Eskildsen*
|
427
704
|
|
428
|
-
*
|
705
|
+
* Fix a range of values for parameters of the Time#change.
|
429
706
|
|
430
|
-
*
|
707
|
+
*Nikolay Kondratyev*
|
431
708
|
|
432
|
-
*
|
709
|
+
* Add `Enumerable#pluck` to get the same values from arrays as from ActiveRecord
|
710
|
+
associations.
|
433
711
|
|
434
|
-
|
435
|
-
To avoid problems we are deprecating them.
|
712
|
+
Fixes #20339.
|
436
713
|
|
437
|
-
*
|
714
|
+
*Kevin Deisz*
|
438
715
|
|
439
|
-
*
|
440
|
-
|
716
|
+
* Add a bang version to `ActiveSupport::OrderedOptions` get methods which will raise
|
717
|
+
an `KeyError` if the value is `.blank?`.
|
441
718
|
|
442
|
-
|
719
|
+
Before:
|
443
720
|
|
444
|
-
|
721
|
+
if (slack_url = Rails.application.secrets.slack_url).present?
|
722
|
+
# Do something worthwhile
|
723
|
+
else
|
724
|
+
# Raise as important secret password is not specified
|
725
|
+
end
|
445
726
|
|
446
|
-
|
447
|
-
hash must change, but the keys are left the same.
|
727
|
+
After:
|
448
728
|
|
449
|
-
|
729
|
+
slack_url = Rails.application.secrets.slack_url!
|
450
730
|
|
451
|
-
*
|
731
|
+
*Aditya Sanghi*, *Gaurish Sharma*
|
452
732
|
|
453
|
-
|
454
|
-
|
733
|
+
* Remove deprecated `Class#superclass_delegating_accessor`.
|
734
|
+
Use `Class#class_attribute` instead.
|
455
735
|
|
456
|
-
*
|
736
|
+
*Akshay Vishnoi*
|
457
737
|
|
458
|
-
*
|
459
|
-
whether a word is uncountable or not.
|
738
|
+
* Patch `Delegator` to work with `#try`.
|
460
739
|
|
461
|
-
|
740
|
+
Fixes #5790.
|
462
741
|
|
463
|
-
*
|
742
|
+
*Nate Smith*
|
464
743
|
|
465
|
-
|
744
|
+
* Add `Integer#positive?` and `Integer#negative?` query methods
|
745
|
+
in the vein of `Fixnum#zero?`.
|
466
746
|
|
467
|
-
|
747
|
+
This makes it nicer to do things like `bunch_of_numbers.select(&:positive?)`.
|
468
748
|
|
469
|
-
*
|
749
|
+
*DHH*
|
470
750
|
|
471
|
-
*
|
472
|
-
when working with objects with a nanosecond component.
|
751
|
+
* Encoding `ActiveSupport::TimeWithZone` to YAML now preserves the timezone information.
|
473
752
|
|
474
|
-
|
475
|
-
using `Time#-`:
|
753
|
+
Fixes #9183.
|
476
754
|
|
477
|
-
|
755
|
+
*Andrew White*
|
478
756
|
|
479
|
-
|
757
|
+
* Added `ActiveSupport::TimeZone#strptime` to allow parsing times as if
|
758
|
+
from a given timezone.
|
480
759
|
|
481
|
-
|
482
|
-
Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0
|
760
|
+
*Paul A Jungwirth*
|
483
761
|
|
484
|
-
|
762
|
+
* `ActiveSupport::Callbacks#skip_callback` now raises an `ArgumentError` if
|
763
|
+
an unrecognized callback is removed.
|
485
764
|
|
486
|
-
|
487
|
-
# => 86399.999999999
|
765
|
+
*Iain Beeston*
|
488
766
|
|
489
|
-
|
767
|
+
* Added `ActiveSupport::ArrayInquirer` and `Array#inquiry`.
|
490
768
|
|
491
|
-
|
769
|
+
Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its
|
770
|
+
contents:
|
492
771
|
|
493
|
-
|
772
|
+
variants = ActiveSupport::ArrayInquirer.new([:phone, :tablet])
|
494
773
|
|
495
|
-
|
496
|
-
# =>
|
774
|
+
variants.phone? # => true
|
775
|
+
variants.tablet? # => true
|
776
|
+
variants.desktop? # => false
|
497
777
|
|
498
|
-
|
778
|
+
variants.any?(:phone, :tablet) # => true
|
779
|
+
variants.any?(:phone, :desktop) # => true
|
780
|
+
variants.any?(:desktop, :watch) # => false
|
499
781
|
|
500
|
-
|
501
|
-
|
782
|
+
`Array#inquiry` is a shortcut for wrapping the receiving array in an
|
783
|
+
`ArrayInquirer`.
|
502
784
|
|
503
|
-
|
785
|
+
*George Claghorn*
|
504
786
|
|
505
|
-
|
787
|
+
* Deprecate `alias_method_chain` in favour of `Module#prepend` introduced in
|
788
|
+
Ruby 2.0.
|
506
789
|
|
507
|
-
*
|
790
|
+
*Kir Shatrov*
|
508
791
|
|
509
|
-
|
792
|
+
* Added `#without` on `Enumerable` and `Array` to return a copy of an
|
793
|
+
enumerable without the specified elements.
|
510
794
|
|
511
|
-
|
512
|
-
5.until => 5.seconds.until
|
513
|
-
5.since => 5.seconds.since
|
514
|
-
5.from_now => 5.seconds.from_now
|
795
|
+
*Todd Bealmear*
|
515
796
|
|
516
|
-
|
797
|
+
* Fixed a problem where `String#truncate_words` would get stuck with a complex
|
798
|
+
string.
|
517
799
|
|
518
|
-
*
|
800
|
+
*Henrik Nygren*
|
519
801
|
|
520
|
-
*
|
802
|
+
* Fixed a roundtrip problem with `AS::SafeBuffer` where primitive-like strings
|
803
|
+
will be dumped as primitives:
|
521
804
|
|
522
805
|
Before:
|
523
806
|
|
524
|
-
|
807
|
+
YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
|
808
|
+
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
|
809
|
+
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
|
810
|
+
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
|
811
|
+
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
|
525
812
|
|
526
813
|
After:
|
527
814
|
|
528
|
-
|
815
|
+
YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
|
816
|
+
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
|
817
|
+
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
|
818
|
+
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
|
819
|
+
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
|
820
|
+
|
821
|
+
*Godfrey Chan*
|
822
|
+
|
823
|
+
* Enable `number_to_percentage` to keep the number's precision by allowing
|
824
|
+
`:precision` to be `nil`.
|
529
825
|
|
530
|
-
|
826
|
+
*Jack Xu*
|
531
827
|
|
532
|
-
|
828
|
+
* `config_accessor` became a private method, as with Ruby's `attr_accessor`.
|
533
829
|
|
534
|
-
*
|
535
|
-
in nested arrays. This change also applies to `Hash#deep_stringify_keys`,
|
536
|
-
`Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and
|
537
|
-
`Hash#deep_symbolize_keys!`.
|
830
|
+
*Akira Matsuda*
|
538
831
|
|
539
|
-
|
832
|
+
* `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
|
833
|
+
`Time.now` and `Date.today`.
|
540
834
|
|
541
|
-
*
|
835
|
+
*Yuki Nishijima*
|
542
836
|
|
543
|
-
|
837
|
+
* Add `file_fixture` to `ActiveSupport::TestCase`.
|
838
|
+
It provides a simple mechanism to access sample files in your test cases.
|
544
839
|
|
545
|
-
|
840
|
+
By default file fixtures are stored in `test/fixtures/files`. This can be
|
841
|
+
configured per test-case using the `file_fixture_path` class attribute.
|
546
842
|
|
547
|
-
*
|
548
|
-
when a subscriber method is redefined.
|
843
|
+
*Yves Senn*
|
549
844
|
|
550
|
-
|
845
|
+
* Return value of yielded block in `File.atomic_write`.
|
551
846
|
|
552
|
-
*
|
847
|
+
*Ian Ker-Seymer*
|
553
848
|
|
554
|
-
|
849
|
+
* Duplicate frozen array when assigning it to a `HashWithIndifferentAccess` so
|
850
|
+
that it doesn't raise a `RuntimeError` when calling `map!` on it in `convert_value`.
|
555
851
|
|
556
|
-
|
557
|
-
`ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
|
558
|
-
convert a value that is an `ActiveSupport::SafeBuffer` introduced
|
559
|
-
in 2da9d67.
|
852
|
+
Fixes #18550.
|
560
853
|
|
561
|
-
|
854
|
+
*Aditya Kapoor*
|
562
855
|
|
563
|
-
|
856
|
+
* Add missing time zone definitions for Russian Federation and sync them
|
857
|
+
with `zone.tab` file from tzdata version 2014j (latest).
|
564
858
|
|
565
|
-
*
|
566
|
-
components are specified. This is more consistent with the behavior of
|
567
|
-
`Time#parse`.
|
859
|
+
*Andrey Novikov*
|
568
860
|
|
569
|
-
|
861
|
+
* Add `SecureRandom.base58` for generation of random base58 strings.
|
570
862
|
|
571
|
-
*
|
863
|
+
*Matthew Draper*, *Guillermo Iguaran*
|
572
864
|
|
573
|
-
|
865
|
+
* Add `#prev_day` and `#next_day` counterparts to `#yesterday` and
|
866
|
+
`#tomorrow` for `Date`, `Time`, and `DateTime`.
|
574
867
|
|
575
|
-
|
868
|
+
*George Claghorn*
|
576
869
|
|
577
|
-
|
870
|
+
* Add `same_time` option to `#next_week` and `#prev_week` for `Date`, `Time`,
|
871
|
+
and `DateTime`.
|
578
872
|
|
579
|
-
|
873
|
+
*George Claghorn*
|
580
874
|
|
581
|
-
|
875
|
+
* Add `#on_weekend?`, `#next_weekday`, `#prev_weekday` methods to `Date`,
|
876
|
+
`Time`, and `DateTime`.
|
582
877
|
|
583
|
-
|
878
|
+
`#on_weekend?` returns `true` if the receiving date/time falls on a Saturday
|
879
|
+
or Sunday.
|
584
880
|
|
585
|
-
|
881
|
+
`#next_weekday` returns a new date/time representing the next day that does
|
882
|
+
not fall on a Saturday or Sunday.
|
586
883
|
|
587
|
-
|
588
|
-
|
884
|
+
`#prev_weekday` returns a new date/time representing the previous day that
|
885
|
+
does not fall on a Saturday or Sunday.
|
589
886
|
|
590
|
-
|
887
|
+
*George Claghorn*
|
591
888
|
|
592
|
-
|
889
|
+
* Added ability to `TaggedLogging` to allow loggers to be instantiated multiple times
|
890
|
+
so that they don't share tags with each other.
|
593
891
|
|
594
|
-
|
595
|
-
UUID fixtures on PostgreSQL.
|
892
|
+
Rails.logger = Logger.new(STDOUT)
|
596
893
|
|
597
|
-
|
894
|
+
# Before
|
895
|
+
custom_logger = ActiveSupport::TaggedLogging.new(Rails.logger)
|
896
|
+
custom_logger.push_tags "custom_tag"
|
897
|
+
custom_logger.info "test" # => "[custom_tag] [custom_tag] test"
|
898
|
+
Rails.logger.info "test" # => "[custom_tag] [custom_tag] test"
|
598
899
|
|
599
|
-
|
600
|
-
|
900
|
+
# After
|
901
|
+
custom_logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
902
|
+
custom_logger.push_tags "custom_tag"
|
903
|
+
custom_logger.info "test" # => "[custom_tag] test"
|
904
|
+
Rails.logger.info "test" # => "test"
|
601
905
|
|
602
|
-
|
906
|
+
*Alexander Staubo*
|
603
907
|
|
604
|
-
|
908
|
+
* Change the default test order from `:sorted` to `:random`.
|
605
909
|
|
606
|
-
|
607
|
-
This requirement makes `ActiveSupport::Duration`'s behavior consistent with
|
608
|
-
the behavior of Ruby's numeric types:
|
910
|
+
*Rafael Mendonça França*
|
609
911
|
|
610
|
-
|
611
|
-
1.0.eql?(1) # => false
|
912
|
+
* Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`.
|
612
913
|
|
613
|
-
|
614
|
-
1.eql?(1.second) # => false
|
914
|
+
*Rafael Mendonça França*
|
615
915
|
|
616
|
-
|
617
|
-
|
916
|
+
* Remove deprecated methods `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=`
|
917
|
+
and `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string`.
|
618
918
|
|
619
|
-
|
620
|
-
# now => { 1 => "foo", 1.second => "bar" }
|
621
|
-
# was => { 1 => "bar" }
|
919
|
+
*Rafael Mendonça França*
|
622
920
|
|
623
|
-
|
921
|
+
* Remove deprecated `ActiveSupport::SafeBuffer#prepend`.
|
624
922
|
|
625
|
-
|
626
|
-
1.0 == 1 # => true
|
923
|
+
*Rafael Mendonça França*
|
627
924
|
|
628
|
-
|
629
|
-
1.second == 1 # => true
|
925
|
+
* Remove deprecated methods at `Kernel`.
|
630
926
|
|
631
|
-
|
927
|
+
`silence_stderr`, `silence_stream`, `capture` and `quietly`.
|
632
928
|
|
633
|
-
*
|
634
|
-
instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is
|
635
|
-
deprecated.
|
929
|
+
*Rafael Mendonça França*
|
636
930
|
|
637
|
-
|
931
|
+
* Remove deprecated `active_support/core_ext/big_decimal/yaml_conversions`
|
932
|
+
file.
|
638
933
|
|
639
|
-
*
|
640
|
-
receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept
|
641
|
-
objects which respond to `#to_hash`, even if those objects are not hashes
|
642
|
-
directly.
|
934
|
+
*Rafael Mendonça França*
|
643
935
|
|
644
|
-
|
936
|
+
* Remove deprecated methods `ActiveSupport::Cache::Store.instrument` and
|
937
|
+
`ActiveSupport::Cache::Store.instrument=`.
|
645
938
|
|
646
|
-
*
|
939
|
+
*Rafael Mendonça França*
|
647
940
|
|
648
|
-
|
941
|
+
* Change the way in which callback chains can be halted.
|
649
942
|
|
650
|
-
|
651
|
-
|
943
|
+
The preferred method to halt a callback chain from now on is to explicitly
|
944
|
+
`throw(:abort)`.
|
945
|
+
In the past, callbacks could only be halted by explicitly providing a
|
946
|
+
terminator and by having a callback match the conditions of the terminator.
|
652
947
|
|
653
|
-
|
948
|
+
* Add `ActiveSupport.halt_callback_chains_on_return_false`
|
654
949
|
|
655
|
-
|
656
|
-
|
950
|
+
Setting `ActiveSupport.halt_callback_chains_on_return_false`
|
951
|
+
to `true` will let an app support the deprecated way of halting Active Record,
|
952
|
+
and Active Model callback chains by returning `false`.
|
657
953
|
|
658
|
-
|
954
|
+
Setting the value to `false` will tell the app to ignore any `false` value
|
955
|
+
returned by those callbacks, and only halt the chain upon `throw(:abort)`.
|
659
956
|
|
660
|
-
|
661
|
-
|
662
|
-
|
957
|
+
When the configuration option is missing, its value is `true`, so older apps
|
958
|
+
ported to Rails 5.0 will not break (but display a deprecation warning).
|
959
|
+
For new Rails 5.0 apps, its value is set to `false` in an initializer, so
|
960
|
+
these apps will support the new behavior by default.
|
663
961
|
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
962
|
+
*claudiob*, *Roque Pinel*
|
963
|
+
|
964
|
+
* Changes arguments and default value of CallbackChain's `:terminator` option
|
965
|
+
|
966
|
+
Chains of callbacks defined without an explicit `:terminator` option will
|
967
|
+
now be halted as soon as a `before_` callback throws `:abort`.
|
968
|
+
|
969
|
+
Chains of callbacks defined with a `:terminator` option will maintain their
|
970
|
+
existing behavior of halting as soon as a `before_` callback matches the
|
971
|
+
terminator's expectation.
|
972
|
+
|
973
|
+
*claudiob*
|
974
|
+
|
975
|
+
* Deprecate `MissingSourceFile` in favor of `LoadError`.
|
976
|
+
|
977
|
+
`MissingSourceFile` was just an alias to `LoadError` and was not being
|
978
|
+
raised inside the framework.
|
979
|
+
|
980
|
+
*Rafael Mendonça França*
|
669
981
|
|
670
|
-
|
671
|
-
|
672
|
-
|
982
|
+
* Remove `Object#itself` as it is implemented in Ruby 2.2.
|
983
|
+
|
984
|
+
*Cristian Bica*
|
985
|
+
|
986
|
+
* Add support for error dispatcher classes in `ActiveSupport::Rescuable`.
|
987
|
+
Now it acts closer to Ruby's rescue.
|
988
|
+
|
989
|
+
Example:
|
990
|
+
|
991
|
+
class BaseController < ApplicationController
|
992
|
+
module ErrorDispatcher
|
993
|
+
def self.===(other)
|
994
|
+
Exception === other && other.respond_to?(:status)
|
673
995
|
end
|
674
996
|
end
|
675
997
|
|
676
|
-
|
677
|
-
|
998
|
+
rescue_from ErrorDispatcher do |error|
|
999
|
+
render status: error.status, json: { error: error.to_s }
|
678
1000
|
end
|
679
1001
|
end
|
680
1002
|
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
1003
|
+
*Genadi Samokovarov*
|
1004
|
+
|
1005
|
+
* Add `#verified` and `#valid_message?` methods to `ActiveSupport::MessageVerifier`
|
1006
|
+
|
1007
|
+
Previously, the only way to decode a message with `ActiveSupport::MessageVerifier`
|
1008
|
+
was to use `#verify`, which would raise an exception on invalid messages. Now
|
1009
|
+
`#verified` can also be used, which returns `nil` on messages that cannot be
|
1010
|
+
decoded.
|
1011
|
+
|
1012
|
+
Previously, there was no way to check if a message's format was valid without
|
1013
|
+
attempting to decode it. `#valid_message?` is a boolean convenience method that
|
1014
|
+
checks whether the message is valid without actually decoding it.
|
685
1015
|
|
686
|
-
*
|
1016
|
+
*Logan Leger*
|
687
1017
|
|
688
|
-
Please check [4-
|
1018
|
+
Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md) for previous changes.
|