CHANGELOG.md 11.8 KB
Newer Older
1
*   Deprecate `.halt_callback_chains_on_return_false`.
2 3 4

    *Rafael Mendonça França*

5 6 7 8
*   Remove deprecated behavior that halts callbacks when the return is false.

    *Rafael Mendonça França*

9 10 11 12 13
*   Deprecate passing string to `:if` and `:unless` conditional options
    on `set_callback` and `skip_callback`.

    *Ryuta Kamizono*

14 15 16 17
*   Raise `ArgumentError` when passing string to define callback.

    *Ryuta Kamizono*

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
*   Updated Unicode version to 9.0.0

    Now we can handle new emojis such like "👩‍👩‍👧‍👦" ("\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}").

    version 8.0.0

        "👩‍👩‍👧‍👦".mb_chars.grapheme_length # => 4
        "👩‍👩‍👧‍👦".mb_chars.reverse # => "👦👧‍👩‍👩‍"

    version 9.0.0

        "👩‍👩‍👧‍👦".mb_chars.grapheme_length # => 1
        "👩‍👩‍👧‍👦".mb_chars.reverse # => "👩‍👩‍👧‍👦"

    *Fumiaki MATSUSHIMA*

34 35 36 37 38
*   Changed `ActiveSupport::Inflector#transliterate` to raise `ArgumentError` when it receives
    anything except a string.

    *Kevin McPhillips*

39 40
*   Fixed bugs that `StringInquirer#respond_to_missing?` and
    `ArrayInquirer#respond_to_missing?` do not fallback to `super`.
41 42 43

    *Akira Matsuda*

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
*   Fix inconsistent results when parsing large durations and constructing durations from code

        ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true

    Duration parsing made independent from any moment of time:
    Fixed length in seconds is assigned to each duration part during parsing.

    Changed duration of months and years in seconds to more accurate and logical:

     1. The value of 365.2425 days in Gregorian year is more accurate
        as it accounts for every 400th non-leap year.

     2. Month's length is bound to year's duration, which makes
        sensible comparisons like `12.months == 1.year` to be `true`
        and nonsensical ones like `30.days == 1.month` to be `false`.

    Calculations on times and dates with durations shouldn't be affected as
    duration's numeric value isn't used in calculations, only parts are used.

    Methods on `Numeric` like `2.days` now use these predefined durations
    to avoid duplicating of duration constants through the codebase and
    eliminate creation of intermediate durations.

    *Andrey Novikov, Andrew White*

U
utilum 已提交
69 70 71 72 73
*   Change return value of `Rational#duplicable?`, `ComplexClass#duplicable?`
    to false.

    *utilum*

74 75 76 77 78 79
*   Change return value of `NilClass#duplicable?`, `FalseClass#duplicable?`,
    `TrueClass#duplicable?`, `Symbol#duplicable?` and `Numeric#duplicable?`
    to true with Ruby 2.4+. These classes can dup with Ruby 2.4+.

    *Yuji Yaginuma*

80
*   Remove deprecated class `ActiveSupport::Concurrency::Latch`.
81 82 83

    *Andrew White*

84
*   Remove deprecated separator argument from `parameterize`.
85 86 87

    *Andrew White*

88
*   Remove deprecated method `Numeric#to_formatted_s`.
89 90 91

    *Andrew White*

92
*   Remove deprecated method `alias_method_chain`.
93 94 95

    *Andrew White*

96
*   Remove deprecated constant `MissingSourceFile`.
97 98 99

    *Andrew White*

100
*   Remove deprecated methods `Module.qualified_const_defined?`,
101
    `Module.qualified_const_get` and `Module.qualified_const_set`.
102 103 104

    *Andrew White*

105
*   Remove deprecated `:prefix` option from `number_to_human_size`.
A
Andrew White 已提交
106 107 108

    *Andrew White*

109
*   Remove deprecated method `ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default`.
A
Andrew White 已提交
110 111 112

    *Andrew White*

113
*   Remove deprecated file `active_support/core_ext/time/marshal.rb`.
A
Andrew White 已提交
114 115 116

    *Andrew White*

117
*   Remove deprecated file `active_support/core_ext/struct.rb`.
A
Andrew White 已提交
118 119 120

    *Andrew White*

121
*   Remove deprecated file `active_support/core_ext/module/method_transplanting.rb`.
A
Andrew White 已提交
122 123 124

    *Andrew White*

125
*   Remove deprecated method `Module.local_constants`.
A
Andrew White 已提交
126 127 128

    *Andrew White*

129
*   Remove deprecated file `active_support/core_ext/kernel/debugger.rb`.
A
Andrew White 已提交
130 131 132

    *Andrew White*

133
*   Remove deprecated method `ActiveSupport::Cache::Store#namespaced_key`.
A
Andrew White 已提交
134 135 136

    *Andrew White*

137
*   Remove deprecated method `ActiveSupport::Cache::Strategy::LocalCache::LocalStore#set_cache_value`.
A
Andrew White 已提交
138 139 140

    *Andrew White*

141
*   Remove deprecated method `ActiveSupport::Cache::MemCacheStore#escape_key`.
A
Andrew White 已提交
142 143 144

    *Andrew White*

145
*   Remove deprecated method `ActiveSupport::Cache::FileStore#key_file_path`.
A
Andrew White 已提交
146 147 148

    *Andrew White*

149
*   Ensure duration parsing is consistent across DST changes.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

    Previously `ActiveSupport::Duration.parse` used `Time.current` and
    `Time#advance` to calculate the number of seconds in the duration
    from an arbitrary collection of parts. However as `advance` tries to
    be consistent across DST boundaries this meant that either the
    duration was shorter or longer depending on the time of year.

    This was fixed by using an absolute reference point in UTC which
    isn't subject to DST transitions. An arbitrary date of Jan 1st, 2000
    was chosen for no other reason that it seemed appropriate.

    Additionally, duration parsing should now be marginally faster as we
    are no longer creating instances of `ActiveSupport::TimeWithZone`
    every time we parse a duration string.

    Fixes #26941.

    *Andrew White*

169 170 171 172 173
*   Use `Hash#compact` and `Hash#compact!` from Ruby 2.4. Old Ruby versions
    will continue to get these methods from Active Support as before.

    *Prathamesh Sonpatki*

174 175 176 177 178 179 180
*   Fix `ActiveSupport::TimeZone#strptime`.
    Support for timestamps in format of seconds (%s) and milliseconds (%Q).

    Fixes #26840.

    *Lev Denisov*

181 182 183 184 185 186
*   Fix `DateAndTime::Calculations#copy_time_to`. Copy `nsec` instead of `usec`.

    Jumping forward or backward between weeks now preserves nanosecond digits.

    *Josua Schmid*

187 188 189 190 191 192 193 194 195 196
*   Fix `ActiveSupport::TimeWithZone#in` across DST boundaries.

    Previously calls to `in` were being sent to the non-DST aware
    method `Time#since` via `method_missing`. It is now aliased to
    the DST aware `ActiveSupport::TimeWithZone#+` which handles
    transitions across DST boundaries, e.g:

        Time.zone = "US/Eastern"

        t = Time.zone.local(2016,11,6,1)
197
        # => Sun, 06 Nov 2016 01:00:00 EDT -05:00
198 199

        t.in(1.hour)
200
        # => Sun, 06 Nov 2016 01:00:00 EST -05:00
201 202 203 204 205

    Fixes #26580.

    *Thomas Balthazar*

206 207 208 209 210 211
*   Remove unused parameter `options = nil` for `#clear` of
    `ActiveSupport::Cache::Strategy::LocalCache::LocalStore` and
    `ActiveSupport::Cache::Strategy::LocalCache`.

    *Yosuke Kabuto*

212
*   Fix `thread_mattr_accessor` subclass no longer overwrites parent.
213

214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
    Assigning a value to a subclass using `thread_mattr_accessor` no
    longer changes the value of the parent class. This brings the
    behavior inline with the documentation.

    Given:

        class Account
          thread_mattr_accessor :user
        end

        class Customer < Account
        end

        Account.user = "DHH"
        Customer.user = "Rafael"

    Before:

        Account.user  # => "Rafael"

    After:

        Account.user  # => "DHH"
237 238 239

    *Shinichi Maeshima*

240 241 242 243 244 245 246 247
*   Since weeks are no longer converted to days, add `:weeks` to the list of
    parts that `ActiveSupport::TimeWithZone` will recognize as possibly being
    of variable duration to take account of DST transitions.

    Fixes #26039.

    *Andrew White*

X
Xavier Noria 已提交
248
*   Defines `Regexp.match?` for Ruby versions prior to 2.4. The predicate
249
    has the same interface, but it does not have the performance boost. Its
X
Xavier Noria 已提交
250 251 252 253
    purpose is to be able to write 2.4 compatible code.

    *Xavier Noria*

V
Vipul A M 已提交
254
*   Allow `MessageEncryptor` to take advantage of authenticated encryption modes.
255 256

    AEAD modes like `aes-256-gcm` provide both confidentiality and data
V
Vipul A M 已提交
257
    authenticity, eliminating the need to use `MessageVerifier` to check if the
258 259 260 261 262
    encrypted data has been tampered with. This speeds up encryption/decryption
    and results in shorter cipher text.

    *Bart de Water*

263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
*   Introduce `assert_changes` and `assert_no_changes`.

    `assert_changes` is a more general `assert_difference` that works with any
    value.

        assert_changes 'Error.current', from: nil, to: 'ERR' do
          expected_bad_operation
        end

    Can be called with strings, to be evaluated in the binding (context) of
    the block given to the assertion, or a lambda.

        assert_changes -> { Error.current }, from: nil, to: 'ERR' do
          expected_bad_operation
        end

    The `from` and `to` arguments are compared with the case operator (`===`).

        assert_changes 'Error.current', from: nil, to: Error do
          expected_bad_operation
        end

    This is pretty useful, if you need to loosely compare a value. For example,
    you need to test a token has been generated and it has that many random
    characters.

        user = User.start_registration
        assert_changes 'user.token', to: /\w{32}/ do
          user.finish_registration
        end

    *Genadi Samokovarov*

296 297 298 299 300 301 302 303 304
*   Fix `ActiveSupport::TimeZone#strptime`. Now raises `ArgumentError` when the
    given time doesn't match the format. The error is the same as the one given
    by Ruby's `Date.strptime`. Previously it raised
    `NoMethodError: undefined method empty? for nil:NilClass.` due to a bug.

    Fixes #25701.

    *John Gesimondo*

X
Xavier Noria 已提交
305
*   `travel/travel_to` travel time helpers, now raise on nested calls,
306
     as this can lead to confusing time stubbing.
307

308
     Instead of:
309

310 311 312 313
         travel_to 2.days.from_now do
           # 2 days from today
           travel_to 3.days.from_now do
             # 5 days from today
314
           end
315 316 317 318
         end

     preferred way to achieve above is:

X
Xavier Noria 已提交
319
         travel 2.days do
320 321
           # 2 days from today
         end
322 323 324 325 326

         travel 5.days do
           # 5 days from today
         end

327 328
     *Vipul A M*

329 330 331 332 333 334
*   Support parsing JSON time in ISO8601 local time strings in
    `ActiveSupport::JSON.decode` when `parse_json_times` is enabled.
    Strings in the format of `YYYY-MM-DD hh:mm:ss` (without a `Z` at
    the end) will be parsed in the local timezone (`Time.zone`). In
    addition, date strings (`YYYY-MM-DD`) are now parsed into `Date`
    objects.
335 336 337

    *Grzegorz Witek*

K
Kevin McPhillips 已提交
338 339 340 341 342 343
*   Fixed `ActiveSupport::Logger.broadcast` so that calls to `#silence` now
    properly delegate to all loggers. Silencing now properly suppresses logging
    to both the log and the console.

    *Kevin McPhillips*

344 345 346 347
*   Remove deprecated arguments in `assert_nothing_raised`.

    *Rafel Mendonça França*

348 349 350 351 352 353 354
*   `Date.to_s` doesn't produce too many spaces. For example, `to_s(:short)`
    will now produce `01 Feb` instead of ` 1 Feb`.

    Fixes #25251.

    *Sean Griffin*

V
Vipul A M 已提交
355
*   Introduce `Module#delegate_missing_to`.
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401

    When building a decorator, a common pattern emerges:

        class Partition
          def initialize(first_event)
            @events = [ first_event ]
          end

          def people
            if @events.first.detail.people.any?
              @events.collect { |e| Array(e.detail.people) }.flatten.uniq
            else
              @events.collect(&:creator).uniq
            end
          end

          private
            def respond_to_missing?(name, include_private = false)
              @events.respond_to?(name, include_private)
            end

            def method_missing(method, *args, &block)
              @events.send(method, *args, &block)
            end
        end

    With `Module#delegate_missing_to`, the above is condensed to:

        class Partition
          delegate_missing_to :@events

          def initialize(first_event)
            @events = [ first_event ]
          end

          def people
            if @events.first.detail.people.any?
              @events.collect { |e| Array(e.detail.people) }.flatten.uniq
            else
              @events.collect(&:creator).uniq
            end
          end
        end

    *Genadi Samokovarov*, *DHH*

402 403 404 405
*   Rescuable: If a handler doesn't match the exception, check for handlers
    matching the exception's cause.

    *Jeremy Daer*
406

407
Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activesupport/CHANGELOG.md) for previous changes.