CHANGELOG.md 12.1 KB
Newer Older
1
## Rails 4.0.0 (unreleased) ##
2

3 4 5 6 7 8 9 10 11
*   Prevent `Callbacks#set_callback` from setting the same callback twice.

        before_save :foo, :bar, :foo

    will at first call `bar`, then `foo`. `foo` will no more be called
    twice.

    *Dmitriy Kiriyenko*

12
*   Add ActiveSupport::Logger#silence that works the same as the old Logger#silence extension.
13 14 15

    *DHH*

16
*   Remove surrogate unicode character encoding from `ActiveSupport::JSON.encode`
17
    The encoding scheme was broken for unicode characters outside the basic multilingual plane;
18 19
    since json is assumed to be `UTF-8`, and we already force the encoding to `UTF-8`,
    simply pass through the un-encoded characters.
20 21

    *Brett Carter*
S
Steve Klabnik 已提交
22

23 24 25 26 27 28 29
*   Deprecate `Time.time_with_date_fallback`, `Time.utc_time` and `Time.local_time`.
    These methods were added to handle the limited range of Ruby's native Time
    implementation. Those limitations no longer apply so we are deprecating them in 4.0
    and they will be removed in 4.1.

    *Andrew White*

30 31
*   Deprecate `Date#to_time_in_current_zone` and add `Date#in_time_zone`. *Andrew White*

A
Andrew White 已提交
32 33
*   Add `String#in_time_zone` method to convert a string to an ActiveSupport::TimeWithZone. *Andrew White*

34 35 36 37 38 39
*   Deprecate `ActiveSupport::BasicObject` in favor of `ActiveSupport::ProxyObject`.
    This class is used for proxy classes. It avoids confusion with Ruby's BasicObject
    class.

    *Francesco Rodriguez*

40 41 42 43 44
*   Patched Marshal#load to work with constant autoloading.
    Fixes autoloading with cache stores that relay on Marshal(MemCacheStore and FileStore). [fixes #8167]

    *Uriel Katz*

45 46
*   Make `Time.zone.parse` to work with JavaScript format date strings. *Andrew White*

47 48 49 50 51 52 53 54 55
*   Add `DateTime#seconds_until_end_of_day` and `Time#seconds_until_end_of_day`
    as a complement for `seconds_from_midnight`; useful when setting expiration
    times for caches, e.g.:

        <% cache('dashboard', expires_in: Date.current.seconds_until_end_of_day) do %>
          ...

    *Olek Janiszewski*

56 57
*   No longer proxy ActiveSupport::Multibyte#class. *Steve Klabnik*

58 59
*   Deprecate `ActiveSupport::TestCase#pending` method, use `skip` from MiniTest instead. *Carlos Antonio da Silva*

60 61 62 63 64 65 66 67 68 69 70 71 72
*   `XmlMini.with_backend` now may be safely used with threads:

        Thread.new do
          XmlMini.with_backend("REXML") { rexml_power }
        end
        Thread.new do
          XmlMini.with_backend("LibXML") { libxml_power }
        end

    Each thread will use it's own backend.

    *Nikita Afanasenko*

73
*   Dependencies no longer trigger Kernel#autoload in remove_constant [fixes #8213]. *Xavier Noria*
74

75 76
*   Simplify mocha integration and remove monkey-patches, bumping mocha to 0.13.0. *James Mead*

77 78 79 80 81
*   `#as_json` isolates options when encoding a hash.
    Fix #8182

    *Yves Senn*

S
Steve Klabnik 已提交
82 83
*   Deprecate Hash#diff in favor of MiniTest's #diff. *Steve Klabnik*

84
*   Kernel#capture can catch output from subprocesses *Dmitry Vorotilin*
85

86 87 88 89
*   `to_xml` conversions now use builder's `tag!` method instead of explicit invocation of `method_missing`.

    *Nikita Afanasenko*

90 91
*   Fixed timezone mapping of the Solomon Islands. *Steve Klabnik*

92 93 94 95 96
*   Make callstack attribute optional in
    ActiveSupport::Deprecation::Reporting methods `warn` and `deprecation_warning`

    *Alexey Gaziev*

97 98
*   Implement HashWithIndifferentAccess#replace so key? works correctly. *David Graham*

99 100
*   Handle the possible Permission Denied errors atomic.rb might trigger due to its chown and chmod calls. *Daniele Sluijters*

101
*   Hash#extract! returns only those keys that present in the receiver.
102

103
        {a: 1, b: 2}.extract!(:a, :x) # => {:a => 1}
104 105 106

    *Mikhail Dieterle*

107
*   Hash#extract! returns the same subclass, that the receiver is. I.e.
108 109 110 111
    HashWithIndifferentAccess#extract! returns HashWithIndifferentAccess instance.

    *Mikhail Dieterle*

112 113
*   Optimize ActiveSupport::Cache::Entry to reduce memory and processing overhead. *Brian Durand*

114 115 116 117 118 119 120
*   Tests tag the Rails log with the current test class and test case:

        [SessionsControllerTest] [test_0002_sign in] Processing by SessionsController#create as HTML
        [SessionsControllerTest] [test_0002_sign in] ...

    *Jeremy Kemper*

121
*   Add `logger.push_tags` and `.pop_tags` to complement logger.tagged:
122 123 124 125 126 127 128 129 130 131 132 133 134

        class Job
          def before
            Rails.logger.push_tags :jobs, self.class.name
          end

          def after
            Rails.logger.pop_tags 2
          end
        end

    *Jeremy Kemper*

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
*   Allow delegation to the class using the `:class` keyword, replacing
    `self.class` usage:

        class User
          def self.hello
           "world"
          end

          delegate :hello, to: :class
        end

    *Marc-Andre Lafortune*

*   `Date.beginning_of_week` thread local and `beginning_of_week` application
    config option added (default is Monday).

    *Innokenty Mikhailov*
152

153 154 155 156 157 158 159 160 161 162 163 164 165
*   An optional block can be passed to `config_accessor` to set its default value

        class User
          include ActiveSupport::Configurable
          config_accessor :hair_colors do
            [:brown, :black, :blonde, :red]
          end
        end

        User.hair_colors # => [:brown, :black, :blonde, :red]

    *Larry Lv*

166
*   ActiveSupport::Benchmarkable#silence has been deprecated due to its lack of
167 168 169 170 171 172
    thread safety. It will be removed without replacement in Rails 4.1.

    *Steve Klabnik*

*   An optional block can be passed to `Hash#deep_merge`. The block will be invoked
    for each duplicated key and used to resolve the conflict.
173

174
    *Pranas Kiziela*
175

176 177 178 179 180
*   ActiveSupport::Deprecation is now a class. It is possible to create an instance
    of deprecator. Backwards compatibility has been preserved.

    You can choose which instance of the deprecator will be used.

181
        deprecate :method_name, deprecator: deprecator_instance
182 183 184

    You can use ActiveSupport::Deprecation in your gem.

185 186
        require 'active_support/deprecation'
        require 'active_support/core_ext/module/deprecation'
187

188 189 190 191
        class MyGem
          def self.deprecator
            ActiveSupport::Deprecation.new('2.0', 'MyGem')
          end
192

193 194
          def old_method
          end
195

196 197
          def new_method
          end
198

199
          deprecate old_method: :new_method, deprecator: deprecator
200
        end
201

202 203
        MyGem.new.old_method
        # => DEPRECATION WARNING: old_method is deprecated and will be removed from MyGem 2.0 (use new_method instead). (called from <main> at file.rb:18)
204 205 206

    *Piotr Niełacny & Robert Pankowecki*

207 208
*   `ERB::Util.html_escape` encodes single quote as `#39`. Decimal form has better support in old browsers. *Kalys Osmonov*

209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
*   `ActiveSupport::Callbacks`: deprecate monkey patch of object callbacks.
    Using the #filter method like this:

        before_filter MyFilter.new

        class MyFilter
          def filter(controller)
          end
        end

    Is now deprecated with recommendation to use the corresponding filter type
    (`#before`, `#after` or `#around`):

        before_filter MyFilter.new

        class MyFilter
          def before(controller)
          end
        end

    *Bogdan Gusiev*

231 232 233 234 235 236
*   An optional block can be passed to `HashWithIndifferentAccess#update` and `#merge`.
    The block will be invoked for each duplicated key, and used to resolve the conflict,
    thus replicating the behaviour of the corresponding methods on the `Hash` class.

    *Leo Cassarani*

237 238 239 240 241 242
*   Remove `j` alias for `ERB::Util#json_escape`.
    The `j` alias is already used for `ActionView::Helpers::JavaScriptHelper#escape_javascript`
    and both modules are included in the view context that would confuse the developers.

    *Akira Matsuda*

243 244 245 246
*   Replace deprecated `memcache-client` gem with `dalli` in ActiveSupport::Cache::MemCacheStore

    *Guillermo Iguaran*

247 248 249 250 251
*   Add default values to all `ActiveSupport::NumberHelper` methods, to avoid
    errors with empty locales or missing values.

    *Carlos Antonio da Silva*

252 253
*   `ActiveSupport::JSON::Variable` is deprecated. Define your own `#as_json` and
    `#encode_json` methods for custom JSON string literals.
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269

    *Erich Menge*

*   Add String#indent. *fxn & Ace Suares*

*   Inflections can now be defined per locale. `singularize` and `pluralize`
    accept locale as an extra argument.

    *David Celis*

*   `Object#try` will now return nil instead of raise a NoMethodError if the
    receiving object does not implement the method, but you can still get the
    old behavior by using the new `Object#try!`.

    *DHH*

M
Mark Turner 已提交
270
*   `ERB::Util.html_escape` now escapes single quotes. *Santiago Pastorino*
271

272
*   `Time#change` now works with time values with offsets other than UTC or the local time zone. *Andrew White*
273

274
*   `ActiveSupport::Callbacks`: deprecate usage of filter object with `#before` and `#after` methods as `around` callback. *Bogdan Gusiev*
275

276
*   Add `Time#prev_quarter` and `Time#next_quarter` short-hands for `months_ago(3)` and `months_since(3)`. *SungHee Kang*
277

278 279
*   Remove obsolete and unused `require_association` method from dependencies. *fxn*

280 281 282 283 284 285 286 287 288 289 290 291
*   Add `:instance_accessor` option for `config_accessor`.

        class User
          include ActiveSupport::Configurable
          config_accessor :allowed_access, instance_accessor: false
        end

        User.new.allowed_access = true # => NoMethodError
        User.new.allowed_access        # => NoMethodError

    *Francesco Rodriguez*

292 293
*   ActionView::Helpers::NumberHelper methods have been moved to ActiveSupport::NumberHelper and are now available via
    Numeric#to_s.  Numeric#to_s now accepts the formatting  options :phone, :currency, :percentage, :delimited,
294 295
    :rounded, :human, and :human_size. *Andrew Mutz*

296
*   Add `Hash#transform_keys`, `Hash#transform_keys!`, `Hash#deep_transform_keys`, and `Hash#deep_transform_keys!`. *Mark McSpadden*
297

298
*   Changed xml type `datetime` to `dateTime` (with upper case letter `T`). *Angelo Capilleri*
299

300 301
*   Add `:instance_accessor` option for `class_attribute`. *Alexey Vakhov*

302 303
*   `constantize` now looks in the ancestor chain. *Marc-Andre Lafortune & Andrew White*

304 305 306 307
*   Adds `Hash#deep_stringify_keys` and `Hash#deep_stringify_keys!` to convert all keys from a +Hash+ instance into strings *Lucas Húngaro*

*   Adds `Hash#deep_symbolize_keys` and `Hash#deep_symbolize_keys!` to convert all keys from a +Hash+ instance into symbols *Lucas Húngaro*

308
*   `Object#try` can't call private methods. *Vasiliy Ermolovich*
309

310 311
*   `AS::Callbacks#run_callbacks` remove `key` argument. *Francesco Rodriguez*

312
*   `deep_dup` works more expectedly now and duplicates also values in +Hash+ instances and elements in +Array+ instances. *Alexey Gaziev*
313

314
*   Inflector no longer applies ice -> ouse to words like slice, police, ets *Wes Morgan*
J
José Valim 已提交
315

316
*   Add `ActiveSupport::Deprecations.behavior = :silence` to completely ignore Rails runtime deprecations *twinturbo*
317

318
*   Make Module#delegate stop using `send` - can no longer delegate to private methods. *dasch*
D
Daniel Schierbeck 已提交
319

320
*   AS::Callbacks: deprecate `:rescuable` option. *Bogdan Gusiev*
321

322
*   Adds Integer#ordinal to get the ordinal suffix string of an integer. *Tim Gildea*
323

324
*   AS::Callbacks: `:per_key` option is no longer supported
325

326
*   `AS::Callbacks#define_callbacks`: add `:skip_after_callbacks_if_terminated` option.
327

328
*   Add html_escape_once to ERB::Util, and delegate escape_once tag helper to it. *Carlos Antonio da Silva*
329

330 331
*   Deprecates the compatibility method Module#local_constant_names,
    use Module#local_constants instead (which returns symbols). *fxn*
332

333 334
*   Deletes the compatibility method Module#method_names,
    use Module#methods from now on (which returns symbols). *fxn*
335

336 337
*   Deletes the compatibility method Module#instance_method_names,
    use Module#instance_methods from now on (which returns symbols). *fxn*
338

339 340
*   BufferedLogger is deprecated.  Use ActiveSupport::Logger, or the logger
    from Ruby stdlib.
341

342
*   Unicode database updated to 6.1.0.
343

344 345
*   Adds `encode_big_decimal_as_string` option to force JSON serialization of BigDecimals as numeric instead
    of wrapping them in strings for safety.
346

347 348
*   Remove deprecated ActiveSupport::JSON::Variable. *Erich Menge*

349 350
*   Optimize log subscribers to check log level before doing any processing. *Brian Durand*

X
Xavier Noria 已提交
351
Please check [3-2-stable](https://github.com/rails/rails/blob/3-2-stable/activesupport/CHANGELOG.md) for previous changes.