activesupport 4.2.0 → 5.0.0
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 +630 -220
- 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.rb +73 -89
- data/lib/active_support/callbacks.rb +195 -155
- data/lib/active_support/concern.rb +2 -2
- data/lib/active_support/concurrency/latch.rb +7 -15
- data/lib/active_support/concurrency/share_lock.rb +186 -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 -4
- 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 +13 -6
- data/lib/active_support/core_ext/date.rb +1 -1
- data/lib/active_support/core_ext/date_and_time/calculations.rb +109 -25
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +18 -0
- 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 +36 -10
- data/lib/active_support/core_ext/date_time/compatibility.rb +5 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +2 -0
- data/lib/active_support/core_ext/date_time.rb +2 -1
- data/lib/active_support/core_ext/enumerable.rb +49 -5
- data/lib/active_support/core_ext/file/atomic.rb +30 -25
- data/lib/active_support/core_ext/hash/conversions.rb +23 -4
- 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 +23 -19
- 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 +1 -16
- 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 -83
- data/lib/active_support/core_ext/kernel.rb +0 -1
- data/lib/active_support/core_ext/load_error.rb +4 -2
- data/lib/active_support/core_ext/marshal.rb +12 -11
- 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 +35 -25
- data/lib/active_support/core_ext/module/deprecation.rb +2 -2
- data/lib/active_support/core_ext/module/introspection.rb +4 -0
- data/lib/active_support/core_ext/module/method_transplanting.rb +3 -11
- 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 +74 -64
- data/lib/active_support/core_ext/numeric/inquiry.rb +26 -0
- data/lib/active_support/core_ext/numeric/time.rb +24 -19
- data/lib/active_support/core_ext/numeric.rb +1 -0
- data/lib/active_support/core_ext/object/blank.rb +17 -5
- data/lib/active_support/core_ext/object/deep_dup.rb +10 -3
- data/lib/active_support/core_ext/object/duplicable.rb +8 -13
- 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 +68 -22
- 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/access.rb +1 -1
- data/lib/active_support/core_ext/string/behavior.rb +1 -1
- data/lib/active_support/core_ext/string/conversions.rb +4 -3
- data/lib/active_support/core_ext/string/filters.rb +5 -5
- 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 +18 -16
- 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 +36 -11
- data/lib/active_support/core_ext/time/compatibility.rb +5 -0
- 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 +1 -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 +51 -0
- data/lib/active_support/dependencies.rb +87 -95
- data/lib/active_support/deprecation/behaviors.rb +16 -2
- 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 +55 -10
- data/lib/active_support/evented_file_update_checker.rb +194 -0
- data/lib/active_support/execution_wrapper.rb +117 -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 +3 -3
- data/lib/active_support/hash_with_indifferent_access.rb +46 -13
- 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 +4 -49
- data/lib/active_support/key_generator.rb +7 -9
- 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 +50 -1
- data/lib/active_support/logger_silence.rb +8 -4
- data/lib/active_support/logger_thread_safe_level.rb +31 -0
- data/lib/active_support/message_encryptor.rb +4 -4
- data/lib/active_support/message_verifier.rb +70 -8
- data/lib/active_support/multibyte/chars.rb +13 -4
- data/lib/active_support/multibyte/unicode.rb +44 -21
- data/lib/active_support/notifications/fanout.rb +6 -6
- 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 +8 -3
- 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 +93 -47
- data/lib/active_support/security_utils.rb +7 -0
- data/lib/active_support/string_inquirer.rb +1 -1
- data/lib/active_support/subscriber.rb +5 -10
- data/lib/active_support/tagged_logging.rb +3 -1
- data/lib/active_support/test_case.rb +15 -29
- data/lib/active_support/testing/assertions.rb +15 -13
- data/lib/active_support/testing/autorun.rb +8 -1
- 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 +13 -10
- data/lib/active_support/time_with_zone.rb +135 -46
- data/lib/active_support/values/time_zone.rb +95 -47
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/xml_mini/jdom.rb +7 -6
- data/lib/active_support/xml_mini/libxml.rb +2 -2
- data/lib/active_support/xml_mini/nokogiri.rb +2 -2
- data/lib/active_support/xml_mini/rexml.rb +7 -8
- data/lib/active_support/xml_mini.rb +22 -14
- data/lib/active_support.rb +20 -6
- metadata +32 -35
- data/lib/active_support/core_ext/big_decimal/yaml_conversions.rb +0 -14
- 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,388 +1,798 @@
|
|
1
|
-
|
1
|
+
## Rails 5.0.0 (June 30, 2016) ##
|
2
2
|
|
3
|
-
|
3
|
+
* Support parsing JSON time in ISO8601 local time strings in
|
4
|
+
`ActiveSupport::JSON.decode` when `parse_json_times` is enabled.
|
5
|
+
Strings in the format of `YYYY-MM-DD hh:mm:ss` (without a `Z` at
|
6
|
+
the end) will be parsed in the local timezone (`Time.zone`). In
|
7
|
+
addition, date strings (`YYYY-MM-DD`) are now parsed into `Date`
|
8
|
+
objects.
|
4
9
|
|
5
|
-
*
|
10
|
+
*Grzegorz Witek*
|
6
11
|
|
7
|
-
* `
|
12
|
+
* `Date.to_s` doesn't produce too many spaces. For example, `to_s(:short)`
|
13
|
+
will now produce `01 Feb` instead of ` 1 Feb`.
|
8
14
|
|
9
|
-
|
15
|
+
Fixes #25251.
|
10
16
|
|
11
|
-
*
|
12
|
-
it also now correctly handles escaped '%' characters placed just before time zone related directives.
|
17
|
+
*Sean Griffin*
|
13
18
|
|
14
|
-
|
19
|
+
* Rescuable: If a handler doesn't match the exception, check for handlers
|
20
|
+
matching the exception's cause.
|
15
21
|
|
16
|
-
*
|
22
|
+
*Jeremy Daer*
|
17
23
|
|
18
|
-
|
24
|
+
* `ActiveSupport::Duration` supports weeks and hours.
|
19
25
|
|
20
|
-
|
26
|
+
[1.hour.inspect, 1.hour.value, 1.hour.parts]
|
27
|
+
# => ["3600 seconds", 3600, [[:seconds, 3600]]] # Before
|
28
|
+
# => ["1 hour", 3600, [[:hours, 1]]] # After
|
21
29
|
|
22
|
-
|
30
|
+
[1.week.inspect, 1.week.value, 1.week.parts]
|
31
|
+
# => ["7 days", 604800, [[:days, 7]]] # Before
|
32
|
+
# => ["1 week", 604800, [[:weeks, 1]]] # After
|
23
33
|
|
24
|
-
|
34
|
+
This brings us into closer conformance with ISO8601 and relieves some
|
35
|
+
astonishment about getting `1.hour.inspect # => 3600 seconds`.
|
25
36
|
|
26
|
-
|
37
|
+
Compatibility: The duration's `value` remains the same, so apps using
|
38
|
+
durations are oblivious to the new time periods. Apps, libraries, and
|
39
|
+
plugins that work with the internal `parts` hash will need to broaden
|
40
|
+
their time period handling to cover hours & weeks.
|
27
41
|
|
28
|
-
|
42
|
+
*Andrey Novikov*
|
29
43
|
|
30
|
-
|
44
|
+
* Time zones: Ensure that the UTC offset reflects DST changes that occurred
|
45
|
+
since the app started. Removes UTC offset caching, reducing performance,
|
46
|
+
but this is still relatively quick and isn't in any hot paths.
|
31
47
|
|
32
|
-
|
33
|
-
just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their
|
34
|
-
parts may be different though.
|
48
|
+
*Alexey Shein*
|
35
49
|
|
36
|
-
|
37
|
-
|
50
|
+
* Make `getlocal` and `getutc` always return instances of `Time` for
|
51
|
+
`ActiveSupport::TimeWithZone` and `DateTime`. This eliminates a possible
|
52
|
+
stack level too deep error in `to_time` where `ActiveSupport::TimeWithZone`
|
53
|
+
was wrapping a `DateTime` instance. As a consequence of this the internal
|
54
|
+
time value in `ActiveSupport::TimeWithZone` is now always an instance of
|
55
|
+
`Time` in the UTC timezone, whether that's as the UTC time directly or
|
56
|
+
a representation of the local time in the timezone. There should be no
|
57
|
+
consequences of this internal change and if there are it's a bug due to
|
58
|
+
leaky abstractions.
|
38
59
|
|
39
|
-
*
|
60
|
+
*Andrew White*
|
40
61
|
|
41
|
-
* `
|
42
|
-
alternative to microseconds (`:usec`).
|
62
|
+
* Add `DateTime#subsec` to return the fraction of a second as a `Rational`.
|
43
63
|
|
44
|
-
*
|
64
|
+
*Andrew White*
|
45
65
|
|
46
|
-
*
|
47
|
-
|
66
|
+
* Add additional aliases for `DateTime#utc` to mirror the ones on
|
67
|
+
`ActiveSupport::TimeWithZone` and `Time`.
|
48
68
|
|
49
|
-
*
|
69
|
+
*Andrew White*
|
50
70
|
|
51
|
-
*
|
52
|
-
|
53
|
-
to `:sorted` but will be changed to `:random` in Rails 5.0.
|
71
|
+
* Add `DateTime#localtime` to return an instance of `Time` in the system's
|
72
|
+
local timezone. Also aliased to `getlocal`.
|
54
73
|
|
55
|
-
*
|
74
|
+
*Andrew White*, *Yuichiro Kaneko*
|
56
75
|
|
57
|
-
*
|
58
|
-
are incorrectly parsed as camelCase.
|
76
|
+
* Add `Time#sec_fraction` to return the fraction of a second as a `Rational`.
|
59
77
|
|
60
|
-
|
78
|
+
*Andrew White*
|
61
79
|
|
62
|
-
|
80
|
+
* Add `ActiveSupport.to_time_preserves_timezone` config option to control
|
81
|
+
how `to_time` handles timezones. In Ruby 2.4+ the behavior will change
|
82
|
+
from converting to the local system timezone, to preserving the timezone
|
83
|
+
of the receiver. This config option defaults to false so that apps made
|
84
|
+
with earlier versions of Rails are not affected when upgrading, e.g:
|
63
85
|
|
64
|
-
|
65
|
-
the time has an offset other than UTC or local.
|
86
|
+
>> ENV['TZ'] = 'US/Eastern'
|
66
87
|
|
67
|
-
|
88
|
+
>> "2016-04-23T10:23:12.000Z".to_time
|
89
|
+
=> "2016-04-23T06:23:12.000-04:00"
|
68
90
|
|
69
|
-
|
70
|
-
hashes and arrays containing `Method` objects to be `deep_dup`ed.
|
91
|
+
>> ActiveSupport.to_time_preserves_timezone = true
|
71
92
|
|
72
|
-
|
93
|
+
>> "2016-04-23T10:23:12.000Z".to_time
|
94
|
+
=> "2016-04-23T10:23:12.000Z"
|
73
95
|
|
74
|
-
|
75
|
-
which happens during constant autoloading.
|
96
|
+
Fixes #24617.
|
76
97
|
|
77
|
-
|
98
|
+
*Andrew White*
|
78
99
|
|
79
|
-
|
100
|
+
* `ActiveSupport::TimeZone.country_zones(country_code)` looks up the
|
101
|
+
country's time zones by its two-letter ISO3166 country code, e.g.
|
80
102
|
|
81
|
-
|
103
|
+
>> ActiveSupport::TimeZone.country_zones(:jp).map(&:to_s)
|
104
|
+
=> ["(GMT+09:00) Osaka"]
|
82
105
|
|
83
|
-
|
106
|
+
>> ActiveSupport::TimeZone.country_zones(:uy).map(&:to_s)
|
107
|
+
=> ["(GMT-03:00) Montevideo"]
|
84
108
|
|
85
|
-
|
109
|
+
*Andrey Novikov*
|
86
110
|
|
87
|
-
|
111
|
+
* `Array#sum` compat with Ruby 2.4's native method.
|
88
112
|
|
89
|
-
|
113
|
+
Ruby 2.4 introduces `Array#sum`, but it only supports numeric elements,
|
114
|
+
breaking our `Enumerable#sum` which supports arbitrary `Object#+`.
|
115
|
+
To fix, override `Array#sum` with our compatible implementation.
|
90
116
|
|
91
|
-
|
92
|
-
value with the class itself since it was previously delegated to the
|
93
|
-
internal value.
|
117
|
+
Native Ruby 2.4:
|
94
118
|
|
95
|
-
|
119
|
+
%w[ a b ].sum
|
120
|
+
# => TypeError: String can't be coerced into Fixnum
|
96
121
|
|
97
|
-
|
98
|
-
with per-second precision, not anything deeper than that.
|
122
|
+
With `Enumerable#sum` shim:
|
99
123
|
|
100
|
-
|
124
|
+
%w[ a b ].sum
|
125
|
+
# => 'ab'
|
101
126
|
|
102
|
-
|
127
|
+
We tried shimming the fast path and falling back to the compatible path
|
128
|
+
if it fails, but that ends up slower even in simple cases due to the cost
|
129
|
+
of exception handling. Our only choice is to override the native `Array#sum`
|
130
|
+
with our `Enumerable#sum`.
|
103
131
|
|
104
|
-
*
|
132
|
+
*Jeremy Daer*
|
133
|
+
|
134
|
+
* `ActiveSupport::Duration` supports ISO8601 formatting and parsing.
|
135
|
+
|
136
|
+
ActiveSupport::Duration.parse('P3Y6M4DT12H30M5S')
|
137
|
+
# => 3 years, 6 months, 4 days, 12 hours, 30 minutes, and 5 seconds
|
138
|
+
|
139
|
+
(3.years + 3.days).iso8601
|
140
|
+
# => "P3Y3D"
|
141
|
+
|
142
|
+
Inspired by Arnau Siches' [ISO8601 gem](https://github.com/arnau/ISO8601/)
|
143
|
+
and rewritten by Andrey Novikov with suggestions from Andrew White. Test
|
144
|
+
data from the ISO8601 gem redistributed under MIT license.
|
145
|
+
|
146
|
+
(Will be used to support the PostgreSQL interval data type.)
|
147
|
+
|
148
|
+
*Andrey Novikov*, *Arnau Siches*, *Andrew White*
|
149
|
+
|
150
|
+
* `Cache#fetch(key, force: true)` forces a cache miss, so it must be called
|
151
|
+
with a block to provide a new value to cache. Fetching with `force: true`
|
152
|
+
but without a block now raises ArgumentError.
|
153
|
+
|
154
|
+
cache.fetch('key', force: true) # => ArgumentError
|
155
|
+
|
156
|
+
*Santosh Wadghule*
|
157
|
+
|
158
|
+
* Fix behavior of JSON encoding for `Exception`.
|
159
|
+
|
160
|
+
*namusyaka*
|
161
|
+
|
162
|
+
* Make `number_to_phone` format number with regexp pattern.
|
163
|
+
|
164
|
+
number_to_phone(18812345678, pattern: /(\d{3})(\d{4})(\d{4})/)
|
165
|
+
# => 188-1234-5678
|
166
|
+
|
167
|
+
*Pan Gaoyong*
|
168
|
+
|
169
|
+
* Match `String#to_time`'s behaviour to that of ruby's implementation for edge cases.
|
170
|
+
|
171
|
+
`nil` is now returned instead of the current date if the string provided does
|
172
|
+
contain time information, but none that is used to build the `Time` object.
|
173
|
+
|
174
|
+
Fixes #22958.
|
175
|
+
|
176
|
+
*Siim Liiser*
|
177
|
+
|
178
|
+
* Rely on the native DateTime#<=> implementation to handle non-datetime like
|
179
|
+
objects instead of returning `nil` ourselves. This restores the ability
|
180
|
+
of `DateTime` instances to be compared with a `Numeric` that represents an
|
181
|
+
astronomical julian day number.
|
105
182
|
|
106
|
-
|
183
|
+
Fixes #24228.
|
107
184
|
|
108
|
-
|
185
|
+
*Andrew White*
|
186
|
+
|
187
|
+
* Add `String#upcase_first` method.
|
188
|
+
|
189
|
+
*Glauco Custódio*, *bogdanvlviv*
|
190
|
+
|
191
|
+
* Prevent `Marshal.load` from looping infinitely when trying to autoload a constant
|
192
|
+
which resolves to a different name.
|
193
|
+
|
194
|
+
*Olek Janiszewski*
|
195
|
+
|
196
|
+
* Deprecate `Module.local_constants`. Please use `Module.constants(false)` instead.
|
197
|
+
|
198
|
+
*Yuichiro Kaneko*
|
199
|
+
|
200
|
+
* Publish `ActiveSupport::Executor` and `ActiveSupport::Reloader` APIs to allow
|
201
|
+
components and libraries to manage, and participate in, the execution of
|
202
|
+
application code, and the application reloading process.
|
203
|
+
|
204
|
+
*Matthew Draper*
|
205
|
+
|
206
|
+
* Deprecate arguments on `assert_nothing_raised`.
|
207
|
+
|
208
|
+
`assert_nothing_raised` does not assert the arguments that have been passed
|
209
|
+
in (usually a specific exception class) since the method only yields the
|
210
|
+
block. So as not to confuse the users that the arguments have meaning, they
|
211
|
+
are being deprecated.
|
212
|
+
|
213
|
+
*Tara Scherner de la Fuente*
|
214
|
+
|
215
|
+
* Make `benchmark('something', silence: true)` actually work.
|
109
216
|
|
110
217
|
*DHH*
|
111
218
|
|
112
|
-
*
|
113
|
-
explicit receiver in not passed.
|
219
|
+
* Add `#on_weekday?` method to `Date`, `Time`, and `DateTime`.
|
114
220
|
|
115
|
-
|
221
|
+
`#on_weekday?` returns `true` if the receiving date/time does not fall on a Saturday
|
222
|
+
or Sunday.
|
116
223
|
|
117
|
-
*
|
118
|
-
`active_support/core_ext/object/json` without requiring `active_support/json`.
|
224
|
+
*Vipul A M*
|
119
225
|
|
120
|
-
|
226
|
+
* Add `Array#second_to_last` and `Array#third_to_last` methods.
|
121
227
|
|
122
|
-
*
|
228
|
+
*Brian Christian*
|
123
229
|
|
124
|
-
*
|
230
|
+
* Fix regression in `Hash#dig` for HashWithIndifferentAccess.
|
125
231
|
|
126
|
-
*
|
232
|
+
*Jon Moss*
|
127
233
|
|
128
|
-
*
|
234
|
+
* Change `number_to_currency` behavior for checking negativity.
|
129
235
|
|
130
|
-
|
236
|
+
Used `to_f.negative` instead of using `to_f.phase` for checking negativity
|
237
|
+
of a number in number_to_currency helper.
|
238
|
+
This change works same for all cases except when number is "-0.0".
|
131
239
|
|
132
|
-
|
240
|
+
-0.0.to_f.negative? => false
|
241
|
+
-0.0.to_f.phase? => 3.14
|
133
242
|
|
134
|
-
|
135
|
-
|
243
|
+
This change reverts changes from https://github.com/rails/rails/pull/6512.
|
244
|
+
But it should be acceptable as we could not find any currency which
|
245
|
+
supports negative zeros.
|
136
246
|
|
137
|
-
*
|
247
|
+
*Prathamesh Sonpatki*, *Rafael Mendonça França*
|
138
248
|
|
139
|
-
* `
|
140
|
-
rounding to `.0`.
|
249
|
+
* Match `HashWithIndifferentAccess#default`'s behaviour with `Hash#default`.
|
141
250
|
|
142
|
-
|
251
|
+
*David Cornu*
|
143
252
|
|
144
|
-
|
253
|
+
* Adds `:exception_object` key to `ActiveSupport::Notifications::Instrumenter`
|
254
|
+
payload when an exception is raised.
|
145
255
|
|
146
|
-
|
147
|
-
|
256
|
+
Adds new key/value pair to payload when an exception is raised:
|
257
|
+
e.g. `:exception_object => #<RuntimeError: FAIL>`.
|
148
258
|
|
149
|
-
*
|
259
|
+
*Ryan T. Hosford*
|
150
260
|
|
151
|
-
*
|
261
|
+
* Support extended grapheme clusters and UAX 29.
|
152
262
|
|
153
|
-
|
154
|
-
are attached subscribers, we don't need to disable instrumentation.
|
263
|
+
*Adam Roben*
|
155
264
|
|
156
|
-
|
265
|
+
* Add petabyte and exabyte numeric conversion.
|
157
266
|
|
158
|
-
*
|
159
|
-
whether a word is uncountable or not.
|
267
|
+
*Akshay Vishnoi*
|
160
268
|
|
161
|
-
|
269
|
+
* Add thread_m/cattr_accessor/reader/writer suite of methods for declaring class and module variables that live per-thread.
|
270
|
+
This makes it easy to declare per-thread globals that are encapsulated. Note: This is a sharp edge. A wild proliferation
|
271
|
+
of globals is A Bad Thing. But like other sharp tools, when it's right, it's right.
|
162
272
|
|
163
|
-
|
273
|
+
Here's an example of a simple event tracking system where the object being tracked needs not pass a creator that it
|
274
|
+
doesn't need itself along:
|
164
275
|
|
165
|
-
|
276
|
+
module Current
|
277
|
+
thread_mattr_accessor :account
|
278
|
+
thread_mattr_accessor :user
|
166
279
|
|
167
|
-
|
280
|
+
def self.reset() self.account = self.user = nil end
|
281
|
+
end
|
168
282
|
|
169
|
-
|
283
|
+
class ApplicationController < ActionController::Base
|
284
|
+
before_action :set_current
|
285
|
+
after_action { Current.reset }
|
170
286
|
|
171
|
-
|
172
|
-
|
287
|
+
private
|
288
|
+
def set_current
|
289
|
+
Current.account = Account.find(params[:account_id])
|
290
|
+
Current.user = Current.account.users.find(params[:user_id])
|
291
|
+
end
|
292
|
+
end
|
173
293
|
|
174
|
-
|
175
|
-
|
294
|
+
class MessagesController < ApplicationController
|
295
|
+
def create
|
296
|
+
@message = Message.create!(message_params)
|
297
|
+
end
|
298
|
+
end
|
176
299
|
|
177
|
-
|
300
|
+
class Message < ApplicationRecord
|
301
|
+
has_many :events
|
302
|
+
after_create :track_created
|
178
303
|
|
179
|
-
|
304
|
+
private
|
305
|
+
def track_created
|
306
|
+
events.create! origin: self, action: :create
|
307
|
+
end
|
308
|
+
end
|
180
309
|
|
181
|
-
|
182
|
-
|
310
|
+
class Event < ApplicationRecord
|
311
|
+
belongs_to :creator, class_name: 'User'
|
312
|
+
before_validation { self.creator ||= Current.user }
|
313
|
+
end
|
183
314
|
|
184
|
-
|
315
|
+
*DHH*
|
316
|
+
|
317
|
+
|
318
|
+
* Deprecated `Module#qualified_const_` in favour of the builtin Module#const_
|
319
|
+
methods.
|
320
|
+
|
321
|
+
*Genadi Samokovarov*
|
322
|
+
|
323
|
+
* Deprecate passing string to define callback.
|
324
|
+
|
325
|
+
*Yuichiro Kaneko*
|
326
|
+
|
327
|
+
* `ActiveSupport::Cache::Store#namespaced_key`,
|
328
|
+
`ActiveSupport::Cache::MemCachedStore#escape_key`, and
|
329
|
+
`ActiveSupport::Cache::FileStore#key_file_path`
|
330
|
+
are deprecated and replaced with `normalize_key` that now calls `super`.
|
331
|
+
|
332
|
+
`ActiveSupport::Cache::LocaleCache#set_cache_value` is deprecated and replaced with `write_cache_value`.
|
333
|
+
|
334
|
+
*Michael Grosser*
|
335
|
+
|
336
|
+
* Implements an evented file watcher to asynchronously detect changes in the
|
337
|
+
application source code, routes, locales, etc.
|
338
|
+
|
339
|
+
This watcher is disabled by default, applications my enable it in the configuration:
|
340
|
+
|
341
|
+
# config/environments/development.rb
|
342
|
+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
343
|
+
|
344
|
+
This feature depends on the [listen](https://github.com/guard/listen) gem:
|
345
|
+
|
346
|
+
group :development do
|
347
|
+
gem 'listen', '~> 3.0.5'
|
348
|
+
end
|
349
|
+
|
350
|
+
*Puneet Agarwal* and *Xavier Noria*
|
351
|
+
|
352
|
+
* Added `Time.days_in_year` to return the number of days in the given year, or the
|
353
|
+
current year if no argument is provided.
|
354
|
+
|
355
|
+
*Jon Pascoe*
|
356
|
+
|
357
|
+
* Updated `parameterize` to preserve the case of a string, optionally.
|
185
358
|
|
186
|
-
|
187
|
-
|
359
|
+
Example:
|
360
|
+
|
361
|
+
parameterize("Donald E. Knuth", separator: '_') # => "donald_e_knuth"
|
362
|
+
parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth"
|
363
|
+
|
364
|
+
*Swaathi Kakarla*
|
365
|
+
|
366
|
+
* `HashWithIndifferentAccess.new` respects the default value or proc on objects
|
367
|
+
that respond to `#to_hash`. `.new_from_hash_copying_default` simply invokes `.new`.
|
368
|
+
All calls to `.new_from_hash_copying_default` are replaced with `.new`.
|
188
369
|
|
189
370
|
*Gordon Chan*
|
190
371
|
|
191
|
-
*
|
372
|
+
* Change Integer#year to return a Fixnum instead of a Float to improve
|
373
|
+
consistency.
|
374
|
+
|
375
|
+
Integer#years returned a Float while the rest of the accompanying methods
|
376
|
+
(days, weeks, months, etc.) return a Fixnum.
|
192
377
|
|
193
378
|
Before:
|
194
379
|
|
195
|
-
|
196
|
-
# => "330.00"
|
380
|
+
1.year # => 31557600.0
|
197
381
|
|
198
382
|
After:
|
199
383
|
|
200
|
-
|
201
|
-
# => "333.33"
|
384
|
+
1.year # => 31557600
|
202
385
|
|
203
|
-
|
386
|
+
*Konstantinos Rousis*
|
204
387
|
|
205
|
-
|
388
|
+
* Handle invalid UTF-8 strings when HTML escaping.
|
206
389
|
|
207
|
-
|
390
|
+
Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8
|
391
|
+
strings in `ERB::Util.unwrapped_html_escape` and `ERB::Util.html_escape_once`.
|
392
|
+
Prevents user-entered input passed from a querystring into a form field from
|
393
|
+
causing invalid byte sequence errors.
|
208
394
|
|
209
|
-
|
395
|
+
*Grey Baker*
|
210
396
|
|
211
|
-
|
212
|
-
|
213
|
-
5.since => 5.seconds.since
|
214
|
-
5.from_now => 5.seconds.from_now
|
397
|
+
* Update `ActiveSupport::Multibyte::Chars#slice!` to return `nil` if the
|
398
|
+
arguments are out of bounds, to mirror the behavior of `String#slice!`
|
215
399
|
|
216
|
-
|
400
|
+
*Gourav Tiwari*
|
217
401
|
|
218
|
-
|
402
|
+
* Fix `number_to_human` so that 999999999 rounds to "1 Billion" instead of
|
403
|
+
"1000 Million".
|
404
|
+
|
405
|
+
*Max Jacobson*
|
406
|
+
|
407
|
+
* Fix `ActiveSupport::Deprecation#deprecate_methods` to report using the
|
408
|
+
current deprecator instance, where applicable.
|
409
|
+
|
410
|
+
*Brandon Dunne*
|
411
|
+
|
412
|
+
* `Cache#fetch` instrumentation marks whether it was a `:hit`.
|
413
|
+
|
414
|
+
*Robin Clowers*
|
415
|
+
|
416
|
+
* `assert_difference` and `assert_no_difference` now returns the result of the
|
417
|
+
yielded block.
|
418
|
+
|
419
|
+
Example:
|
420
|
+
|
421
|
+
post = assert_difference -> { Post.count }, 1 do
|
422
|
+
Post.create
|
423
|
+
end
|
424
|
+
|
425
|
+
*Lucas Mazza*
|
426
|
+
|
427
|
+
* Short-circuit `blank?` on date and time values since they are never blank.
|
428
|
+
|
429
|
+
Fixes #21657.
|
430
|
+
|
431
|
+
*Andrew White*
|
432
|
+
|
433
|
+
* Replaced deprecated `ThreadSafe::Cache` with its successor `Concurrent::Map` now that
|
434
|
+
the thread_safe gem has been merged into concurrent-ruby.
|
435
|
+
|
436
|
+
*Jerry D'Antonio*
|
437
|
+
|
438
|
+
* Updated Unicode version to 8.0.0
|
439
|
+
|
440
|
+
*Anshul Sharma*
|
441
|
+
|
442
|
+
* `number_to_currency` and `number_with_delimiter` now accept custom `delimiter_pattern` option
|
443
|
+
to handle placement of delimiter, to support currency formats like INR
|
219
444
|
|
220
|
-
|
445
|
+
Example:
|
446
|
+
|
447
|
+
number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n")
|
448
|
+
# => '₹ 12,30,000.00'
|
449
|
+
|
450
|
+
*Vipul A M*
|
451
|
+
|
452
|
+
* Deprecate `:prefix` option of `number_to_human_size` with no replacement.
|
453
|
+
|
454
|
+
*Jean Boussier*
|
455
|
+
|
456
|
+
* Fix `TimeWithZone#eql?` to properly handle `TimeWithZone` created from `DateTime`:
|
457
|
+
twz = DateTime.now.in_time_zone
|
458
|
+
twz.eql?(twz.dup) => true
|
459
|
+
|
460
|
+
Fixes #14178.
|
461
|
+
|
462
|
+
*Roque Pinel*
|
463
|
+
|
464
|
+
* ActiveSupport::HashWithIndifferentAccess `select` and `reject` will now return
|
465
|
+
enumerator if called without block.
|
466
|
+
|
467
|
+
Fixes #20095.
|
468
|
+
|
469
|
+
*Bernard Potocki*
|
470
|
+
|
471
|
+
* Removed `ActiveSupport::Concurrency::Latch`, superseded by `Concurrent::CountDownLatch`
|
472
|
+
from the concurrent-ruby gem.
|
473
|
+
|
474
|
+
*Jerry D'Antonio*
|
475
|
+
|
476
|
+
* Fix not calling `#default` on `HashWithIndifferentAccess#to_hash` when only
|
477
|
+
`default_proc` is set, which could raise.
|
478
|
+
|
479
|
+
*Simon Eskildsen*
|
480
|
+
|
481
|
+
* Fix setting `default_proc` on `HashWithIndifferentAccess#dup`.
|
482
|
+
|
483
|
+
*Simon Eskildsen*
|
484
|
+
|
485
|
+
* Fix a range of values for parameters of the Time#change.
|
486
|
+
|
487
|
+
*Nikolay Kondratyev*
|
488
|
+
|
489
|
+
* Add `Enumerable#pluck` to get the same values from arrays as from ActiveRecord
|
490
|
+
associations.
|
491
|
+
|
492
|
+
Fixes #20339.
|
493
|
+
|
494
|
+
*Kevin Deisz*
|
495
|
+
|
496
|
+
* Add a bang version to `ActiveSupport::OrderedOptions` get methods which will raise
|
497
|
+
an `KeyError` if the value is `.blank?`.
|
221
498
|
|
222
499
|
Before:
|
223
500
|
|
224
|
-
|
501
|
+
if (slack_url = Rails.application.secrets.slack_url).present?
|
502
|
+
# Do something worthwhile
|
503
|
+
else
|
504
|
+
# Raise as important secret password is not specified
|
505
|
+
end
|
225
506
|
|
226
507
|
After:
|
227
508
|
|
228
|
-
|
509
|
+
slack_url = Rails.application.secrets.slack_url!
|
510
|
+
|
511
|
+
*Aditya Sanghi*, *Gaurish Sharma*
|
512
|
+
|
513
|
+
* Remove deprecated `Class#superclass_delegating_accessor`.
|
514
|
+
Use `Class#class_attribute` instead.
|
515
|
+
|
516
|
+
*Akshay Vishnoi*
|
517
|
+
|
518
|
+
* Patch `Delegator` to work with `#try`.
|
519
|
+
|
520
|
+
Fixes #5790.
|
521
|
+
|
522
|
+
*Nate Smith*
|
523
|
+
|
524
|
+
* Add `Integer#positive?` and `Integer#negative?` query methods
|
525
|
+
in the vein of `Fixnum#zero?`.
|
526
|
+
|
527
|
+
This makes it nicer to do things like `bunch_of_numbers.select(&:positive?)`.
|
528
|
+
|
529
|
+
*DHH*
|
530
|
+
|
531
|
+
* Encoding `ActiveSupport::TimeWithZone` to YAML now preserves the timezone information.
|
532
|
+
|
533
|
+
Fixes #9183.
|
229
534
|
|
230
|
-
|
535
|
+
*Andrew White*
|
231
536
|
|
232
|
-
|
537
|
+
* Added `ActiveSupport::TimeZone#strptime` to allow parsing times as if
|
538
|
+
from a given timezone.
|
233
539
|
|
234
|
-
*
|
235
|
-
in nested arrays. This change also applies to `Hash#deep_stringify_keys`,
|
236
|
-
`Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and
|
237
|
-
`Hash#deep_symbolize_keys!`.
|
540
|
+
*Paul A Jungwirth*
|
238
541
|
|
239
|
-
|
542
|
+
* `ActiveSupport::Callbacks#skip_callback` now raises an `ArgumentError` if
|
543
|
+
an unrecognized callback is removed.
|
240
544
|
|
241
|
-
*
|
545
|
+
*Iain Beeston*
|
242
546
|
|
243
|
-
|
547
|
+
* Added `ActiveSupport::ArrayInquirer` and `Array#inquiry`.
|
244
548
|
|
245
|
-
|
549
|
+
Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its
|
550
|
+
contents:
|
246
551
|
|
247
|
-
|
248
|
-
when a subscriber method is redefined.
|
552
|
+
variants = ActiveSupport::ArrayInquirer.new([:phone, :tablet])
|
249
553
|
|
250
|
-
|
554
|
+
variants.phone? # => true
|
555
|
+
variants.tablet? # => true
|
556
|
+
variants.desktop? # => false
|
251
557
|
|
252
|
-
|
558
|
+
variants.any?(:phone, :tablet) # => true
|
559
|
+
variants.any?(:phone, :desktop) # => true
|
560
|
+
variants.any?(:desktop, :watch) # => false
|
253
561
|
|
254
|
-
|
562
|
+
`Array#inquiry` is a shortcut for wrapping the receiving array in an
|
563
|
+
`ArrayInquirer`.
|
255
564
|
|
256
|
-
*
|
257
|
-
`ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
|
258
|
-
convert a value that is an `ActiveSupport::SafeBuffer` introduced
|
259
|
-
in 2da9d67.
|
565
|
+
*George Claghorn*
|
260
566
|
|
261
|
-
|
567
|
+
* Deprecate `alias_method_chain` in favour of `Module#prepend` introduced in
|
568
|
+
Ruby 2.0.
|
262
569
|
|
263
|
-
*
|
570
|
+
*Kir Shatrov*
|
264
571
|
|
265
|
-
* `
|
266
|
-
|
267
|
-
`Time#parse`.
|
572
|
+
* Added `#without` on `Enumerable` and `Array` to return a copy of an
|
573
|
+
enumerable without the specified elements.
|
268
574
|
|
269
|
-
*
|
575
|
+
*Todd Bealmear*
|
270
576
|
|
271
|
-
* `
|
577
|
+
* Fixed a problem where `String#truncate_words` would get stuck with a complex
|
578
|
+
string.
|
579
|
+
|
580
|
+
*Henrik Nygren*
|
581
|
+
|
582
|
+
* Fixed a roundtrip problem with `AS::SafeBuffer` where primitive-like strings
|
583
|
+
will be dumped as primitives:
|
272
584
|
|
273
585
|
Before:
|
274
586
|
|
275
|
-
|
587
|
+
YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
|
588
|
+
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
|
589
|
+
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
|
590
|
+
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
|
591
|
+
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
|
276
592
|
|
277
593
|
After:
|
278
594
|
|
279
|
-
|
595
|
+
YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
|
596
|
+
YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
|
597
|
+
YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
|
598
|
+
YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
|
599
|
+
YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
|
280
600
|
|
281
|
-
*
|
601
|
+
*Godfrey Chan*
|
282
602
|
|
283
|
-
*
|
603
|
+
* Enable `number_to_percentage` to keep the number's precision by allowing
|
604
|
+
`:precision` to be `nil`.
|
284
605
|
|
285
|
-
|
606
|
+
*Jack Xu*
|
286
607
|
|
287
|
-
|
288
|
-
{a: {}}.to_query # => ""
|
608
|
+
* `config_accessor` became a private method, as with Ruby's `attr_accessor`.
|
289
609
|
|
290
|
-
|
610
|
+
*Akira Matsuda*
|
291
611
|
|
292
|
-
|
612
|
+
* `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
|
613
|
+
`Time.now` and `Date.today`.
|
293
614
|
|
294
|
-
*
|
295
|
-
UUID fixtures on PostgreSQL.
|
615
|
+
*Yuki Nishijima*
|
296
616
|
|
297
|
-
|
617
|
+
* Add `file_fixture` to `ActiveSupport::TestCase`.
|
618
|
+
It provides a simple mechanism to access sample files in your test cases.
|
298
619
|
|
299
|
-
|
300
|
-
|
620
|
+
By default file fixtures are stored in `test/fixtures/files`. This can be
|
621
|
+
configured per test-case using the `file_fixture_path` class attribute.
|
301
622
|
|
302
|
-
|
623
|
+
*Yves Senn*
|
303
624
|
|
304
|
-
|
625
|
+
* Return value of yielded block in `File.atomic_write`.
|
305
626
|
|
306
|
-
|
307
|
-
This requirement makes `ActiveSupport::Duration`'s behavior consistent with
|
308
|
-
the behavior of Ruby's numeric types:
|
627
|
+
*Ian Ker-Seymer*
|
309
628
|
|
310
|
-
|
311
|
-
|
629
|
+
* Duplicate frozen array when assigning it to a `HashWithIndifferentAccess` so
|
630
|
+
that it doesn't raise a `RuntimeError` when calling `map!` on it in `convert_value`.
|
312
631
|
|
313
|
-
|
314
|
-
1.eql?(1.second) # => false
|
632
|
+
Fixes #18550.
|
315
633
|
|
316
|
-
|
317
|
-
# => { 1 => "foo", 1.0 => "bar" }
|
634
|
+
*Aditya Kapoor*
|
318
635
|
|
319
|
-
|
320
|
-
|
321
|
-
# was => { 1 => "bar" }
|
636
|
+
* Add missing time zone definitions for Russian Federation and sync them
|
637
|
+
with `zone.tab` file from tzdata version 2014j (latest).
|
322
638
|
|
323
|
-
|
639
|
+
*Andrey Novikov*
|
324
640
|
|
325
|
-
|
326
|
-
1.0 == 1 # => true
|
641
|
+
* Add `SecureRandom.base58` for generation of random base58 strings.
|
327
642
|
|
328
|
-
|
329
|
-
1.second == 1 # => true
|
643
|
+
*Matthew Draper*, *Guillermo Iguaran*
|
330
644
|
|
331
|
-
|
645
|
+
* Add `#prev_day` and `#next_day` counterparts to `#yesterday` and
|
646
|
+
`#tomorrow` for `Date`, `Time`, and `DateTime`.
|
332
647
|
|
333
|
-
*
|
334
|
-
instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is
|
335
|
-
deprecated.
|
648
|
+
*George Claghorn*
|
336
649
|
|
337
|
-
|
650
|
+
* Add `same_time` option to `#next_week` and `#prev_week` for `Date`, `Time`,
|
651
|
+
and `DateTime`.
|
338
652
|
|
339
|
-
*
|
340
|
-
receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept
|
341
|
-
objects which respond to `#to_hash`, even if those objects are not hashes
|
342
|
-
directly.
|
653
|
+
*George Claghorn*
|
343
654
|
|
344
|
-
|
655
|
+
* Add `#on_weekend?`, `#next_weekday`, `#prev_weekday` methods to `Date`,
|
656
|
+
`Time`, and `DateTime`.
|
345
657
|
|
346
|
-
|
658
|
+
`#on_weekend?` returns `true` if the receiving date/time falls on a Saturday
|
659
|
+
or Sunday.
|
347
660
|
|
348
|
-
|
661
|
+
`#next_weekday` returns a new date/time representing the next day that does
|
662
|
+
not fall on a Saturday or Sunday.
|
349
663
|
|
350
|
-
|
351
|
-
|
664
|
+
`#prev_weekday` returns a new date/time representing the previous day that
|
665
|
+
does not fall on a Saturday or Sunday.
|
352
666
|
|
353
|
-
*
|
667
|
+
*George Claghorn*
|
354
668
|
|
355
|
-
*
|
356
|
-
|
669
|
+
* Added ability to `TaggedLogging` to allow loggers to be instantiated multiple times
|
670
|
+
so that they don't share tags with each other.
|
357
671
|
|
358
|
-
|
672
|
+
Rails.logger = Logger.new(STDOUT)
|
359
673
|
|
360
|
-
|
361
|
-
|
362
|
-
|
674
|
+
# Before
|
675
|
+
custom_logger = ActiveSupport::TaggedLogging.new(Rails.logger)
|
676
|
+
custom_logger.push_tags "custom_tag"
|
677
|
+
custom_logger.info "test" # => "[custom_tag] [custom_tag] test"
|
678
|
+
Rails.logger.info "test" # => "[custom_tag] [custom_tag] test"
|
363
679
|
|
364
|
-
#
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
680
|
+
# After
|
681
|
+
custom_logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
682
|
+
custom_logger.push_tags "custom_tag"
|
683
|
+
custom_logger.info "test" # => "[custom_tag] test"
|
684
|
+
Rails.logger.info "test" # => "test"
|
685
|
+
|
686
|
+
*Alexander Staubo*
|
369
687
|
|
370
|
-
|
371
|
-
|
372
|
-
|
688
|
+
* Change the default test order from `:sorted` to `:random`.
|
689
|
+
|
690
|
+
*Rafael Mendonça França*
|
691
|
+
|
692
|
+
* Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`.
|
693
|
+
|
694
|
+
*Rafael Mendonça França*
|
695
|
+
|
696
|
+
* Remove deprecated methods `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=`
|
697
|
+
and `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string`.
|
698
|
+
|
699
|
+
*Rafael Mendonça França*
|
700
|
+
|
701
|
+
* Remove deprecated `ActiveSupport::SafeBuffer#prepend`.
|
702
|
+
|
703
|
+
*Rafael Mendonça França*
|
704
|
+
|
705
|
+
* Remove deprecated methods at `Kernel`.
|
706
|
+
|
707
|
+
`silence_stderr`, `silence_stream`, `capture` and `quietly`.
|
708
|
+
|
709
|
+
*Rafael Mendonça França*
|
710
|
+
|
711
|
+
* Remove deprecated `active_support/core_ext/big_decimal/yaml_conversions`
|
712
|
+
file.
|
713
|
+
|
714
|
+
*Rafael Mendonça França*
|
715
|
+
|
716
|
+
* Remove deprecated methods `ActiveSupport::Cache::Store.instrument` and
|
717
|
+
`ActiveSupport::Cache::Store.instrument=`.
|
718
|
+
|
719
|
+
*Rafael Mendonça França*
|
720
|
+
|
721
|
+
* Change the way in which callback chains can be halted.
|
722
|
+
|
723
|
+
The preferred method to halt a callback chain from now on is to explicitly
|
724
|
+
`throw(:abort)`.
|
725
|
+
In the past, callbacks could only be halted by explicitly providing a
|
726
|
+
terminator and by having a callback match the conditions of the terminator.
|
727
|
+
|
728
|
+
* Add `ActiveSupport.halt_callback_chains_on_return_false`
|
729
|
+
|
730
|
+
Setting `ActiveSupport.halt_callback_chains_on_return_false`
|
731
|
+
to `true` will let an app support the deprecated way of halting Active Record,
|
732
|
+
and Active Model callback chains by returning `false`.
|
733
|
+
|
734
|
+
Setting the value to `false` will tell the app to ignore any `false` value
|
735
|
+
returned by those callbacks, and only halt the chain upon `throw(:abort)`.
|
736
|
+
|
737
|
+
When the configuration option is missing, its value is `true`, so older apps
|
738
|
+
ported to Rails 5.0 will not break (but display a deprecation warning).
|
739
|
+
For new Rails 5.0 apps, its value is set to `false` in an initializer, so
|
740
|
+
these apps will support the new behavior by default.
|
741
|
+
|
742
|
+
*claudiob*, *Roque Pinel*
|
743
|
+
|
744
|
+
* Changes arguments and default value of CallbackChain's `:terminator` option
|
745
|
+
|
746
|
+
Chains of callbacks defined without an explicit `:terminator` option will
|
747
|
+
now be halted as soon as a `before_` callback throws `:abort`.
|
748
|
+
|
749
|
+
Chains of callbacks defined with a `:terminator` option will maintain their
|
750
|
+
existing behavior of halting as soon as a `before_` callback matches the
|
751
|
+
terminator's expectation.
|
752
|
+
|
753
|
+
*claudiob*
|
754
|
+
|
755
|
+
* Deprecate `MissingSourceFile` in favor of `LoadError`.
|
756
|
+
|
757
|
+
`MissingSourceFile` was just an alias to `LoadError` and was not being
|
758
|
+
raised inside the framework.
|
759
|
+
|
760
|
+
*Rafael Mendonça França*
|
761
|
+
|
762
|
+
* Remove `Object#itself` as it is implemented in Ruby 2.2.
|
763
|
+
|
764
|
+
*Cristian Bica*
|
765
|
+
|
766
|
+
* Add support for error dispatcher classes in `ActiveSupport::Rescuable`.
|
767
|
+
Now it acts closer to Ruby's rescue.
|
768
|
+
|
769
|
+
Example:
|
770
|
+
|
771
|
+
class BaseController < ApplicationController
|
772
|
+
module ErrorDispatcher
|
773
|
+
def self.===(other)
|
774
|
+
Exception === other && other.respond_to?(:status)
|
373
775
|
end
|
374
776
|
end
|
375
777
|
|
376
|
-
|
377
|
-
|
778
|
+
rescue_from ErrorDispatcher do |error|
|
779
|
+
render status: error.status, json: { error: error.to_s }
|
378
780
|
end
|
379
781
|
end
|
380
782
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
783
|
+
*Genadi Samokovarov*
|
784
|
+
|
785
|
+
* Add `#verified` and `#valid_message?` methods to `ActiveSupport::MessageVerifier`
|
786
|
+
|
787
|
+
Previously, the only way to decode a message with `ActiveSupport::MessageVerifier`
|
788
|
+
was to use `#verify`, which would raise an exception on invalid messages. Now
|
789
|
+
`#verified` can also be used, which returns `nil` on messages that cannot be
|
790
|
+
decoded.
|
791
|
+
|
792
|
+
Previously, there was no way to check if a message's format was valid without
|
793
|
+
attempting to decode it. `#valid_message?` is a boolean convenience method that
|
794
|
+
checks whether the message is valid without actually decoding it.
|
385
795
|
|
386
|
-
*
|
796
|
+
*Logan Leger*
|
387
797
|
|
388
|
-
Please check [4-
|
798
|
+
Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md) for previous changes.
|