activesupport 4.1.16 → 4.2.0.beta1

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.

Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +140 -714
  3. data/README.rdoc +7 -2
  4. data/lib/active_support/backtrace_cleaner.rb +4 -4
  5. data/lib/active_support/cache.rb +18 -20
  6. data/lib/active_support/cache/file_store.rb +5 -0
  7. data/lib/active_support/cache/strategy/local_cache.rb +5 -4
  8. data/lib/active_support/cache/strategy/local_cache_middleware.rb +5 -0
  9. data/lib/active_support/callbacks.rb +92 -140
  10. data/lib/active_support/concern.rb +9 -1
  11. data/lib/active_support/core_ext/array/access.rb +5 -1
  12. data/lib/active_support/core_ext/array/grouping.rb +5 -0
  13. data/lib/active_support/core_ext/class/delegating_attributes.rb +4 -0
  14. data/lib/active_support/core_ext/date_time/calculations.rb +11 -1
  15. data/lib/active_support/core_ext/date_time/conversions.rb +2 -2
  16. data/lib/active_support/core_ext/digest/uuid.rb +51 -0
  17. data/lib/active_support/core_ext/hash.rb +1 -0
  18. data/lib/active_support/core_ext/hash/conversions.rb +2 -3
  19. data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -1
  20. data/lib/active_support/core_ext/hash/keys.rb +10 -6
  21. data/lib/active_support/core_ext/hash/transform_values.rb +23 -0
  22. data/lib/active_support/core_ext/kernel.rb +3 -2
  23. data/lib/active_support/core_ext/kernel/concern.rb +10 -0
  24. data/lib/active_support/core_ext/kernel/reporting.rb +14 -0
  25. data/lib/active_support/core_ext/load_error.rb +4 -1
  26. data/lib/active_support/core_ext/module/delegation.rb +13 -25
  27. data/lib/active_support/core_ext/numeric/time.rb +1 -19
  28. data/lib/active_support/core_ext/object.rb +1 -0
  29. data/lib/active_support/core_ext/object/duplicable.rb +4 -11
  30. data/lib/active_support/core_ext/object/itself.rb +12 -0
  31. data/lib/active_support/core_ext/object/json.rb +1 -1
  32. data/lib/active_support/core_ext/object/to_query.rb +2 -1
  33. data/lib/active_support/core_ext/object/with_options.rb +15 -2
  34. data/lib/active_support/core_ext/string/access.rb +4 -4
  35. data/lib/active_support/core_ext/string/filters.rb +25 -1
  36. data/lib/active_support/core_ext/string/inflections.rb +3 -1
  37. data/lib/active_support/core_ext/string/output_safety.rb +29 -19
  38. data/lib/active_support/core_ext/thread.rb +7 -0
  39. data/lib/active_support/core_ext/time/conversions.rb +1 -1
  40. data/lib/active_support/core_ext/time/zones.rb +0 -1
  41. data/lib/active_support/dependencies.rb +5 -4
  42. data/lib/active_support/duration.rb +2 -3
  43. data/lib/active_support/gem_version.rb +3 -3
  44. data/lib/active_support/hash_with_indifferent_access.rb +13 -5
  45. data/lib/active_support/i18n_railtie.rb +1 -7
  46. data/lib/active_support/inflector/inflections.rb +1 -1
  47. data/lib/active_support/inflector/methods.rb +39 -15
  48. data/lib/active_support/json/encoding.rb +0 -4
  49. data/lib/active_support/logger.rb +0 -14
  50. data/lib/active_support/logger_silence.rb +3 -24
  51. data/lib/active_support/message_encryptor.rb +2 -1
  52. data/lib/active_support/multibyte/unicode.rb +5 -3
  53. data/lib/active_support/notifications.rb +7 -2
  54. data/lib/active_support/notifications/fanout.rb +11 -6
  55. data/lib/active_support/number_helper.rb +7 -8
  56. data/lib/active_support/number_helper/number_to_rounded_converter.rb +2 -2
  57. data/lib/active_support/test_case.rb +3 -13
  58. data/lib/active_support/testing/assertions.rb +1 -1
  59. data/lib/active_support/testing/declarative.rb +1 -25
  60. data/lib/active_support/testing/isolation.rb +16 -6
  61. data/lib/active_support/testing/tagged_logging.rb +1 -1
  62. data/lib/active_support/testing/time_helpers.rb +5 -1
  63. data/lib/active_support/time.rb +0 -2
  64. data/lib/active_support/time_with_zone.rb +14 -3
  65. data/lib/active_support/values/time_zone.rb +76 -75
  66. data/lib/active_support/xml_mini.rb +0 -3
  67. data/lib/active_support/xml_mini/jdom.rb +5 -6
  68. data/lib/active_support/xml_mini/rexml.rb +5 -6
  69. metadata +17 -16
  70. data/lib/active_support/core_ext/object/to_json.rb +0 -5
  71. data/lib/active_support/file_watcher.rb +0 -36
  72. data/lib/active_support/security_utils.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec024b769e4e6e2947e4a484e72a27dc8b985df6
4
- data.tar.gz: 11ec2e7e3cac30d1e49b113048210cf2c3b41705
3
+ metadata.gz: 87eea925ef4fa58abf42432943f13b713de57b3e
4
+ data.tar.gz: abc0910fb0e3f30c1c972713ebf60b02ef68cf32
5
5
  SHA512:
6
- metadata.gz: 72c8a816c5b1055a4c4a74c2cc7caea772fcb7f562fa180f802b7ae7bdc7bc86037c51315c9d4ad6ea4055243109b5b396fb8b36dd7876a7e10dea30c5d63bea
7
- data.tar.gz: 6f45694d23465df6ab4404348f5877c4a83cdaa6b2c0093cd43b89ea6000776f588aee21e285a0ad4ad06405cddf0bd80b54230d963b5516716400e29b2b54be
6
+ metadata.gz: d39d5653f9c06f2359a45acbe3048145fd1119eb8bb93528a619b99e5d500f63c88702a65833df05ac6463b25252ef51053a8add2b175d87aa88fe318c15f7b3
7
+ data.tar.gz: f8dbbb8ae2ee61e328f63332e393287eda7e14a1d6bd80a051e2c6808b7687c3757db369a5ace7476a5e7a182f90ad8302951290342061a2642c6c01764ac41b
@@ -1,132 +1,112 @@
1
- ## Rails 4.1.16 (July 12, 2016) ##
2
-
3
- * No changes.
4
-
5
-
6
- ## Rails 4.1.15 (March 07, 2016) ##
7
-
8
- * No changes.
9
-
10
-
11
- ## Rails 4.1.14.2 (February 26, 2016) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 4.1.14.1 (January 25, 2015) ##
17
-
18
- * No changes.
19
-
20
-
21
- ## Rails 4.1.14 (November 12, 2015) ##
22
-
23
- * No changes.
24
-
25
-
26
- ## Rails 4.1.13 (August 24, 2015) ##
27
-
28
- * No changes.
29
-
30
-
31
- ## Rails 4.1.12 (June 25, 2015) ##
32
-
33
- * No changes.
34
-
1
+ * Fix rounding errors with #travel_to by resetting the usec on any passed time to zero, so we only travel
2
+ with per-second precision, not anything deeper than that.
3
+
4
+ *DHH*
35
5
 
36
- ## Rails 4.1.11 (June 16, 2015) ##
6
+ * Fix ActiveSupport::TestCase not to order users' test cases by default.
7
+ If this change breaks your tests because your tests are order dependent, you need to explicitly call
8
+ ActiveSupport::TestCase.my_tests_are_order_dependent! at the top of your tests.
37
9
 
38
- * Fix XSS vulnerability in `ActiveSupport::JSON.encode` method.
10
+ *Akira Matsuda*
39
11
 
40
- CVE-2015-3226.
12
+ * Fix DateTime comparison with DateTime::Infinity object.
41
13
 
42
14
  *Rafael Mendonça França*
43
15
 
44
- * Fix denial of service vulnerability in the XML processing.
16
+ * Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
45
17
 
46
- CVE-2015-3227.
18
+ Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at)
47
19
 
48
- *Aaron Patterson*
20
+ *DHH*
49
21
 
22
+ * `Object#with_options` executes block in merging option context when
23
+ explicit receiver in not passed.
50
24
 
51
- ## Rails 4.1.10 (March 19, 2015) ##
25
+ *Pavel Pravosud*
52
26
 
53
- * Fixed a roundtrip problem with AS::SafeBuffer where primitive-like strings
54
- will be dumped as primitives:
27
+ * Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
28
+ `active_support/core_ext/object/json` without requiring `active_support/json`.
55
29
 
56
- Before:
30
+ Fixes #16131.
57
31
 
58
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
59
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
60
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
61
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
62
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
32
+ *Godfrey Chan*
63
33
 
64
- After:
34
+ * Make `Hash#with_indifferent_access` copy the default proc too.
65
35
 
66
- YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
67
- YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
68
- YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
69
- YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
70
- YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
36
+ *arthurnn*, *Xanders*
71
37
 
72
- *Godfrey Chan*
38
+ * Add `String#truncate_words` to truncate a string by a number of words.
73
39
 
74
- * Replace fixed `:en` with `I18n.default_locale` in `Duration#inspect`.
40
+ *Mohamed Osama*
75
41
 
76
- *Dominik Masur*
42
+ * Deprecate `capture` and `quietly`.
77
43
 
78
- * Add missing time zone definitions for Russian Federation and sync them
79
- with `zone.tab` file from tzdata version 2014j (latest).
44
+ These methods are not thread safe and may cause issues when used in threaded environments.
45
+ To avoid problems we are deprecating them.
80
46
 
81
- *Andrey Novikov*
47
+ *Tom Meier*
82
48
 
49
+ * `DateTime#to_f` now preserves the fractional seconds instead of always
50
+ rounding to `.0`.
83
51
 
84
- ## Rails 4.1.9 (January 6, 2015) ##
52
+ Fixes #15994.
85
53
 
86
- * No changes.
54
+ *John Paul Ashenfelter*
87
55
 
56
+ * Add `Hash#transform_values` to simplify a common pattern where the values of a
57
+ hash must change, but the keys are left the same.
88
58
 
89
- ## Rails 4.1.8 (November 16, 2014) ##
59
+ *Sean Griffin*
90
60
 
91
- * `Method` objects now report themselves as not `duplicable?`. This allows
92
- hashes and arrays containing `Method` objects to be `deep_dup`ed.
61
+ * Always instrument `ActiveSupport::Cache`.
93
62
 
94
- *Peter Jaros*
63
+ Since `ActiveSupport::Notifications` only instrument items when there
64
+ are subscriber we don't need to disable instrumentation.
95
65
 
66
+ *Peter Wagenet*
96
67
 
97
- ## Rails 4.1.7.1 (November 19, 2014) ##
68
+ * Make the `apply_inflections` method case-insensitive when checking
69
+ whether a word is uncountable or not.
98
70
 
99
- * No changes.
71
+ *Robin Dupret*
100
72
 
73
+ * Make Dependencies pass a name to NameError error.
101
74
 
102
- ## Rails 4.1.7 (October 29, 2014) ##
75
+ *arthurnn*
103
76
 
104
- * No changes.
77
+ * Fixed `ActiveSupport::Cache::FileStore` exploding with long paths.
105
78
 
79
+ *Adam Panzer / Michael Grosser*
106
80
 
107
- ## Rails 4.1.6 (September 11, 2014) ##
81
+ * Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
82
+ when working with objects with a nanosecond component.
108
83
 
109
- * Fix DateTime comparison with DateTime::Infinity object.
84
+ `ActiveSupport::TimeWithZone#-` should return the same result as if we were
85
+ using `Time#-`:
110
86
 
111
- *Rafael Mendonça França*
87
+ Time.now.end_of_day - Time.now.beginning_of_day #=> 86399.999999999
112
88
 
113
- * Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
114
- `active_support/core_ext/object/json` without requiring `active_support/json`.
89
+ Before:
115
90
 
116
- Fixes #16131.
91
+ Time.zone.now.end_of_day.nsec #=> 999999999
92
+ Time.zone.now.end_of_day - Time.zone.now.beginning_of_day #=> 86400.0
117
93
 
118
- *Godfrey Chan*
94
+ After:
119
95
 
120
- * Make Dependencies pass a name to NameError error.
96
+ Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
97
+ #=> 86399.999999999
121
98
 
122
- *arthurnn*, *Yuki Nishijima*
99
+ *Gordon Chan*
123
100
 
124
101
  * Fixed precision error in NumberHelper when using Rationals.
125
102
 
126
- before:
103
+ Before:
104
+
127
105
  ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
128
106
  #=> "330.00"
129
- after:
107
+
108
+ After:
109
+
130
110
  ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
131
111
  #=> "333.33"
132
112
 
@@ -134,23 +114,32 @@
134
114
 
135
115
  *Juanjo Bazán*
136
116
 
117
+ * Removed deprecated `Numeric#ago` and friends
137
118
 
138
- ## Rails 4.1.5 (August 18, 2014) ##
119
+ Replacements:
139
120
 
140
- * No changes.
121
+ 5.ago => 5.seconds.ago
122
+ 5.until => 5.seconds.until
123
+ 5.since => 5.seconds.since
124
+ 5.from_now => 5.seconds.from_now
141
125
 
126
+ See #12389 for the history and rationale behind this.
142
127
 
143
- ## Rails 4.1.4 (July 2, 2014) ##
128
+ *Godfrey Chan*
144
129
 
145
- * No changes.
130
+ * DateTime `advance` now supports partial days.
146
131
 
132
+ Before:
147
133
 
148
- ## Rails 4.1.3 (July 2, 2014) ##
134
+ DateTime.now.advance(days: 1, hours: 12)
149
135
 
150
- * No changes.
136
+ After:
137
+
138
+ DateTime.now.advance(days: 1.5)
151
139
 
140
+ Fixes #12005.
152
141
 
153
- ## Rails 4.1.2 (June 26, 2014) ##
142
+ *Shay Davidson*
154
143
 
155
144
  * `Hash#deep_transform_keys` and `Hash#deep_transform_keys!` now transform hashes
156
145
  in nested arrays. This change also applies to `Hash#deep_stringify_keys`,
@@ -159,20 +148,48 @@
159
148
 
160
149
  *OZAWA Sakuro*
161
150
 
151
+ * Fixed confusing `DelegationError` in `Module#delegate`.
152
+
153
+ See #15186.
154
+
155
+ *Vladimir Yarotsky*
156
+
162
157
  * Fixed `ActiveSupport::Subscriber` so that no duplicate subscriber is created
163
158
  when a subscriber method is redefined.
164
159
 
165
160
  *Dennis Schön*
166
161
 
162
+ * Remove deprecated string based terminators for `ActiveSupport::Callbacks`.
163
+
164
+ *Eileen M. Uchitelle*
165
+
167
166
  * Fixed an issue when using
168
167
  `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
169
168
  convert a value that is an `ActiveSupport::SafeBuffer` introduced
170
169
  in 2da9d67.
171
170
 
172
- For more info see #15064.
171
+ See #15064.
173
172
 
174
173
  *Mark J. Titorenko*
175
174
 
175
+ * `TimeZone#parse` defaults the day of the month to '1' if any other date
176
+ components are specified. This is more consistent with the behavior of
177
+ `Time#parse`.
178
+
179
+ *Ulysse Carion*
180
+
181
+ * `humanize` strips leading underscores, if any.
182
+
183
+ Before:
184
+
185
+ '_id'.humanize # => ""
186
+
187
+ After:
188
+
189
+ '_id'.humanize # => "Id"
190
+
191
+ *Xavier Noria*
192
+
176
193
  * Fixed backward compatibility isues introduced in 326e652.
177
194
 
178
195
  Empty Hash or Array should not present in serialization result.
@@ -183,6 +200,12 @@
183
200
  For more info see #14948.
184
201
 
185
202
  *Bogdan Gusiev*
203
+
204
+ * Add `Digest::UUID::uuid_v3` and `Digest::UUID::uuid_v5` to support stable
205
+ UUID fixtures on PostgreSQL.
206
+
207
+ *Roderick van Domburg*
208
+
186
209
  * Fixed `ActiveSupport::Duration#eql?` so that `1.second.eql?(1.second)` is
187
210
  true.
188
211
 
@@ -224,649 +247,52 @@
224
247
  *Pavel Pravosud*
225
248
 
226
249
  * `HashWithIndifferentAccess` better respects `#to_hash` on objects it's
227
- given. In particular `#update`, `#merge`, `#replace` all accept objects
228
- which respond to `#to_hash`, even if those objects are not Hashes directly.
229
-
230
- Currently, if `HashWithIndifferentAccess.new` is given a non-Hash (even if
231
- it responds to `#to_hash`) that object is treated as the default value,
232
- rather than the initial keys and value. Changing that could break existing
233
- code, so it will be updated in the next minor version.
250
+ given. In particular, `.new`, `#update`, `#merge`, `#replace` all accept
251
+ objects which respond to `#to_hash`, even if those objects are not Hashes
252
+ directly.
234
253
 
235
254
  *Peter Jaros*
236
255
 
256
+ * Deprecate `Class#superclass_delegating_accessor`, use `Class#class_attribute` instead.
237
257
 
238
- ## Rails 4.1.1 (May 6, 2014) ##
239
-
240
- * No changes.
241
-
242
-
243
- ## Rails 4.1.0 (April 8, 2014) ##
244
-
245
- * Added `Object#presence_in` to simplify value whitelisting.
246
-
247
- Before:
248
-
249
- params[:bucket_type].in?(%w( project calendar )) ? params[:bucket_type] : nil
250
-
251
- After:
252
-
253
- params[:bucket_type].presence_in %w( project calendar )
254
-
255
- *DHH*
256
-
257
- * Time helpers honor the application time zone when passed a date.
258
-
259
- *Xavier Noria*
258
+ *Akshay Vishnoi*
260
259
 
261
- * Fix the implementation of Multibyte::Unicode.tidy_bytes for JRuby
260
+ * Ensure classes which `include Enumerable` get `#to_json` in addition to
261
+ `#as_json`.
262
262
 
263
- The existing implementation caused JRuby to raise the error:
264
- `Encoding::ConverterNotFoundError: code converter not found (UTF-8 to UTF8-MAC)`
263
+ *Sammy Larbi*
265
264
 
266
- *Justin Coyne*
267
-
268
- * Fix `to_param` behavior when there are nested empty hashes.
269
-
270
- Before:
271
-
272
- params = {c: 3, d: {}}.to_param # => "&c=3"
273
-
274
- After:
275
-
276
- params = {c: 3, d: {}}.to_param # => "c=3&d="
277
-
278
- Fixes #13892.
279
-
280
- *Hincu Petru*
281
-
282
- * Deprecate custom `BigDecimal` serialization.
283
-
284
- Deprecate the custom `BigDecimal` serialization that is included when requiring
285
- `active_support/all`. Let Ruby handle YAML serialization for `BigDecimal`
286
- instead.
287
-
288
- Fixes #12467.
289
-
290
- *David Celis*
291
-
292
- * Fix parsing bugs in `XmlMini`
293
-
294
- Symbols or boolean parsing would raise an error for non string values (e.g.
295
- integers). Decimal parsing would fail due to a missing requirement.
296
-
297
- *Birkir A. Barkarson*
298
-
299
- * Maintain the current timezone when calling `wrap_with_time_zone`
300
-
301
- Extend the solution from the fix for #12163 to the general case where `Time`
302
- methods are wrapped with a time zone.
303
-
304
- Fixes #12596.
305
-
306
- *Andrew White*
307
-
308
- * Remove behavior that automatically remove the Date/Time stubs, added by `travel`
309
- and `travel_to` methods, after each test case.
310
-
311
- Now users have to use the `travel_back` or the block version of `travel` and
312
- `travel_to` methods to clean the stubs.
313
-
314
- *Rafael Mendonça França*
315
-
316
- * Add `travel_back` to remove stubs from `travel` and `travel_to`.
317
-
318
- *Rafael Mendonça França*
319
-
320
- * Remove the deprecation about the `#filter` method.
321
-
322
- Filter objects should now rely on method corresponding to the filter type
323
- (e.g. `#before`).
324
-
325
- *Aaron Patterson*
326
-
327
- * Add `ActiveSupport::JSON::Encoding.time_precision` as a way to configure the
328
- precision of encoded time values:
329
-
330
- Time.utc(2000, 1, 1).as_json # => "2000-01-01T00:00:00.000Z"
331
- ActiveSupport::JSON::Encoding.time_precision = 0
332
- Time.utc(2000, 1, 1).as_json # => "2000-01-01T00:00:00Z"
265
+ * Change the signature of `fetch_multi` to return a hash rather than an
266
+ array. This makes it consistent with the output of `read_multi`.
333
267
 
334
268
  *Parker Selbert*
335
269
 
336
- * Maintain the current timezone when calling `change` during DST overlap
337
-
338
- Currently if a time is changed during DST overlap in the autumn then the method
339
- `period_for_local` will return the DST period. However if the original time is
340
- not DST then this can be surprising and is not what is generally wanted. This
341
- commit changes that behavior to maintain the current period if it's in the list
342
- of periods returned by `periods_for_local`.
343
-
344
- Fixes #12163.
345
-
346
- *Andrew White*
347
-
348
- * Added `Hash#compact` and `Hash#compact!` for removing items with nil value
349
- from hash.
350
-
351
- *Celestino Gomes*
352
-
353
- * Maintain proleptic gregorian in Time#advance
354
-
355
- `Time#advance` uses `Time#to_date` and `Date#advance` to calculate a new date.
356
- The `Date` object returned by `Time#to_date` is constructed with the assumption
357
- that the `Time` object represents a proleptic gregorian date, but it is
358
- configured to observe the default julian calendar reform date (2299161j)
359
- for purposes of calculating month, date and year:
360
-
361
- Time.new(1582, 10, 4).to_date.to_s # => "1582-09-24"
362
- Time.new(1582, 10, 4).to_date.gregorian.to_s # => "1582-10-04"
363
-
364
- This patch ensures that when the intermediate `Date` object is advanced
365
- to yield a new `Date` object, that the `Time` object for return is constructed
366
- with a proleptic gregorian month, date and year.
367
-
368
- *Riley Lynch*
369
-
370
- * `MemCacheStore` should only accept a `Dalli::Client`, or create one.
270
+ * Introduce `Concern#class_methods` as a sleek alternative to clunky
271
+ `module ClassMethods`. Add `Kernel#concern` to define at the toplevel
272
+ without chunky `module Foo; extend ActiveSupport::Concern` boilerplate.
371
273
 
372
- *arthurnn*
373
-
374
- * Don't lazy load the `tzinfo` library as it causes problems on Windows.
375
-
376
- Fixes #13553.
377
-
378
- *Andrew White*
379
-
380
- * Use `remove_possible_method` instead of `remove_method` to avoid
381
- a `NameError` to be thrown on FreeBSD with the `Date` object.
382
-
383
- *Rafael Mendonça França*, *Robin Dupret*
384
-
385
- * `blank?` and `present?` commit to return singletons.
386
-
387
- *Xavier Noria*, *Pavel Pravosud*
388
-
389
- * Fixed Float related error in NumberHelper with large precisions.
390
-
391
- Before:
392
-
393
- ActiveSupport::NumberHelper.number_to_rounded '3.14159', precision: 50
394
- #=> "3.14158999999999988261834005243144929409027099609375"
395
-
396
- After:
397
-
398
- ActiveSupport::NumberHelper.number_to_rounded '3.14159', precision: 50
399
- #=> "3.14159000000000000000000000000000000000000000000000"
400
-
401
- *Kenta Murata*, *Akira Matsuda*
402
-
403
- * Default the new `I18n.enforce_available_locales` config to `true`, meaning
404
- `I18n` will make sure that all locales passed to it must be declared in the
405
- `available_locales` list.
406
-
407
- To disable it add the following configuration to your application:
408
-
409
- config.i18n.enforce_available_locales = false
410
-
411
- This also ensures I18n configuration is properly initialized taking the new
412
- option into account, to avoid their deprecations while booting up the app.
413
-
414
- *Carlos Antonio da Silva*, *Yves Senn*
415
-
416
- * Introduce Module#concerning: a natural, low-ceremony way to separate
417
- responsibilities within a class.
418
-
419
- Imported from https://github.com/37signals/concerning#readme
420
-
421
- class Todo < ActiveRecord::Base
422
- concerning :EventTracking do
423
- included do
424
- has_many :events
425
- end
426
-
427
- def latest_event
428
- ...
429
- end
430
-
431
- private
432
- def some_internal_method
433
- ...
434
- end
274
+ # app/models/concerns/authentication.rb
275
+ concern :Authentication do
276
+ included do
277
+ after_create :generate_private_key
435
278
  end
436
279
 
437
- concerning :Trashable do
438
- def trashed?
439
- ...
440
- end
441
-
442
- def latest_event
443
- super some_option: true
280
+ class_methods do
281
+ def authenticate(credentials)
282
+ # ...
444
283
  end
445
284
  end
446
- end
447
-
448
- is equivalent to defining these modules inline, extending them into
449
- concerns, then mixing them in to the class.
450
-
451
- Inline concerns tame "junk drawer" classes that intersperse many unrelated
452
- class-level declarations, public instance methods, and private
453
- implementation. Coalesce related bits and give them definition.
454
- These are a stepping stone toward future growth & refactoring.
455
-
456
- When to move on from an inline concern:
457
- * Encapsulating state? Extract collaborator object.
458
- * Encompassing more public behavior or implementation? Move to separate file.
459
- * Sharing behavior among classes? Move to separate file.
460
-
461
- *Jeremy Kemper*
462
-
463
- * Fix file descriptor being leaked on each call to `Kernel.silence_stream`.
464
-
465
- *Mario Visic*
466
-
467
- * Added `Date#all_week/month/quarter/year` for generating date ranges.
468
-
469
- *Dmitriy Meremyanin*
470
-
471
- * Add `Time.zone.yesterday` and `Time.zone.tomorrow`. These follow the
472
- behavior of Ruby's `Date.yesterday` and `Date.tomorrow` but return localized
473
- versions, similar to how `Time.zone.today` has returned a localized version
474
- of `Date.today`.
475
-
476
- *Colin Bartlett*
477
285
 
478
- * Show valid keys when `assert_valid_keys` raises an exception, and show the
479
- wrong value as it was entered.
480
-
481
- *Gonzalo Rodríguez-Baltanás Díaz*
482
-
483
- * Deprecated `Numeric#{ago,until,since,from_now}`, the user is expected to explicitly
484
- convert the value into an AS::Duration, i.e. `5.ago` => `5.seconds.ago`
485
-
486
- This will help to catch subtle bugs like:
487
-
488
- def recent?(days = 3)
489
- self.created_at >= days.ago
490
- end
491
-
492
- The above code would check if the model is created within the last 3 **seconds**.
493
-
494
- In the future, `Numeric#{ago,until,since,from_now}` should be removed completely,
495
- or throw some sort of errors to indicate there are no implicit conversion from
496
- Numeric to AS::Duration.
497
-
498
- *Godfrey Chan*
499
-
500
- * Requires JSON gem version 1.7.7 or above due to a security issue in older versions.
501
-
502
- *Godfrey Chan*
503
-
504
- * Removed the old pure-Ruby JSON encoder and switched to a new encoder based on the built-in JSON
505
- gem.
506
-
507
- Support for encoding `BigDecimal` as a JSON number, as well as defining custom `encode_json`
508
- methods to control the JSON output has been **removed from core**. The new encoder will always
509
- encode BigDecimals as `String`s and ignore any custom `encode_json` methods.
510
-
511
- The old encoder has been extracted into the `activesupport-json_encoder` gem. Installing that
512
- gem will bring back the ability to encode `BigDecimal`s as numbers as well as `encode_json`
513
- support.
514
-
515
- Setting the related configuration `ActiveSupport.encode_big_decimal_as_string` without the
516
- `activesupport-json_encoder` gem installed will raise an error.
517
-
518
- *Godfrey Chan*
519
-
520
- * Add `ActiveSupport::Testing::TimeHelpers#travel` and `#travel_to`. These methods change current
521
- time to the given time or time difference by stubbing `Time.now` and `Date.today` to return the
522
- time or date after the difference calculation, or the time or date that got passed into the
523
- method respectively.
524
-
525
- Example for `#travel`:
526
-
527
- Time.now # => 2013-11-09 15:34:49 -05:00
528
- travel 1.day
529
- Time.now # => 2013-11-10 15:34:49 -05:00
530
- Date.today # => Sun, 10 Nov 2013
531
-
532
- Example for `#travel_to`:
533
-
534
- Time.now # => 2013-11-09 15:34:49 -05:00
535
- travel_to Time.new(2004, 11, 24, 01, 04, 44)
536
- Time.now # => 2004-11-24 01:04:44 -05:00
537
- Date.today # => Wed, 24 Nov 2004
538
-
539
- Both of these methods also accept a block, which will return the current time back to its
540
- original state at the end of the block:
541
-
542
- Time.now # => 2013-11-09 15:34:49 -05:00
543
-
544
- travel 1.day do
545
- User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00
546
- end
547
-
548
- travel_to Time.new(2004, 11, 24, 01, 04, 44) do
549
- User.create.created_at # => Wed, 24 Nov 2004 01:04:44 EST -05:00
550
- end
551
-
552
- Time.now # => 2013-11-09 15:34:49 -05:00
553
-
554
- This module is included in `ActiveSupport::TestCase` automatically.
555
-
556
- *Prem Sichanugrist*, *DHH*
557
-
558
- * Unify `cattr_*` interface: allow to pass a block to `cattr_reader`.
559
-
560
- Example:
561
-
562
- class A
563
- cattr_reader(:defr) { 'default_reader_value' }
564
- end
565
- A.defr # => 'default_reader_value'
566
-
567
- *Alexey Chernenkov*
568
-
569
- * Improved compatibility with the stdlib JSON gem.
570
-
571
- Previously, calling `::JSON.{generate,dump}` sometimes causes unexpected
572
- failures such as intridea/multi_json#86.
573
-
574
- `::JSON.{generate,dump}` now bypasses the ActiveSupport JSON encoder
575
- completely and yields the same result with or without ActiveSupport. This
576
- means that it will **not** call `as_json` and will ignore any options that
577
- the JSON gem does not natively understand. To invoke ActiveSupport's JSON
578
- encoder instead, use `obj.to_json(options)` or
579
- `ActiveSupport::JSON.encode(obj, options)`.
580
-
581
- *Godfrey Chan*
582
-
583
- * Fix Active Support `Time#to_json` and `DateTime#to_json` to return 3 decimal
584
- places worth of fractional seconds, similar to `TimeWithZone`.
585
-
586
- *Ryan Glover*
587
-
588
- * Removed circular reference protection in JSON encoder, deprecated
589
- `ActiveSupport::JSON::Encoding::CircularReferenceError`.
590
-
591
- *Godfrey Chan*, *Sergio Campamá*
592
-
593
- * Add `capitalize` option to `Inflector.humanize`, so strings can be humanized without being capitalized:
594
-
595
- 'employee_salary'.humanize # => "Employee salary"
596
- 'employee_salary'.humanize(capitalize: false) # => "employee salary"
597
-
598
- *claudiob*
599
-
600
- * Fixed `Object#as_json` and `Struct#as_json` not working properly with options. They now take
601
- the same options as `Hash#as_json`:
602
-
603
- struct = Struct.new(:foo, :bar).new
604
- struct.foo = "hello"
605
- struct.bar = "world"
606
- json = struct.as_json(only: [:foo]) # => {foo: "hello"}
607
-
608
- *Sergio Campamá*, *Godfrey Chan*
609
-
610
- * Added `Numeric#in_milliseconds`, like `1.hour.in_milliseconds`, so we can feed them to JavaScript functions like `getTime()`.
611
-
612
- *DHH*
613
-
614
- * Calling `ActiveSupport::JSON.decode` with unsupported options now raises an error.
615
-
616
- *Godfrey Chan*
617
-
618
- * Support `:unless_exist` in `FileStore`.
619
-
620
- *Michael Grosser*
621
-
622
- * Fix `slice!` deleting the default value of the hash.
623
-
624
- *Antonio Santos*
625
-
626
- * `require_dependency` accepts objects that respond to `to_path`, in
627
- particular `Pathname` instances.
628
-
629
- *Benjamin Fleischer*
630
-
631
- * Disable the ability to iterate over Range of AS::TimeWithZone
632
- due to significant performance issues.
633
-
634
- *Bogdan Gusiev*
635
-
636
- * Allow attaching event subscribers to ActiveSupport::Notifications namespaces
637
- before they're defined. Essentially, this means instead of this:
638
-
639
- class JokeSubscriber < ActiveSupport::Subscriber
640
- def sql(event)
641
- puts "A rabbi and a priest walk into a bar..."
642
- end
643
-
644
- # This call needs to happen *after* defining the methods.
645
- attach_to "active_record"
646
- end
647
-
648
- You can do this:
649
-
650
- class JokeSubscriber < ActiveSupport::Subscriber
651
- # This is much easier to read!
652
- attach_to "active_record"
653
-
654
- def sql(event)
655
- puts "A rabbi and a priest walk into a bar..."
286
+ def generate_private_key
287
+ # ...
656
288
  end
657
289
  end
658
290
 
659
- This should make it easier to read and understand these subscribers.
660
-
661
- *Daniel Schierbeck*
662
-
663
- * Add `Date#middle_of_day`, `DateTime#middle_of_day` and `Time#middle_of_day` methods.
664
-
665
- Also added `midday`, `noon`, `at_midday`, `at_noon` and `at_middle_of_day` as aliases.
666
-
667
- *Anatoli Makarevich*
668
-
669
- * Fix ActiveSupport::Cache::FileStore#cleanup to no longer rely on missing each_key method.
670
-
671
- *Murray Steele*
672
-
673
- * Ensure that autoloaded constants in all-caps nestings are marked as
674
- autoloaded.
675
-
676
- *Simon Coffey*
677
-
678
- * Add `String#remove(pattern)` as a short-hand for the common pattern of
679
- `String#gsub(pattern, '')`.
680
-
681
- *DHH*
682
-
683
- * Adds a new deprecation behaviour that raises an exception. Throwing this
684
- line into +config/environments/development.rb+
685
-
686
- ActiveSupport::Deprecation.behavior = :raise
687
-
688
- will cause the application to raise an +ActiveSupport::DeprecationException+
689
- on deprecations.
690
-
691
- Use this for aggressive deprecation cleanups.
692
-
693
- *Xavier Noria*
694
-
695
- * Remove 'cow' => 'kine' irregular inflection from default inflections.
696
-
697
- *Andrew White*
698
-
699
- * Add `DateTime#to_s(:iso8601)` and `Date#to_s(:iso8601)` for consistency.
700
-
701
- *Andrew White*
702
-
703
- * Add `Time#to_s(:iso8601)` for easy conversion of times to the iso8601 format for easy Javascript date parsing.
704
-
705
- *DHH*
706
-
707
- * Improve `ActiveSupport::Cache::MemoryStore` cache size calculation.
708
- The memory used by a key/entry pair is calculated via `#cached_size`:
709
-
710
- def cached_size(key, entry)
711
- key.to_s.bytesize + entry.size + PER_ENTRY_OVERHEAD
712
- end
713
-
714
- The value of `PER_ENTRY_OVERHEAD` is 240 bytes based on an [empirical
715
- estimation](https://gist.github.com/ssimeonov/6047200) for 64-bit MRI on
716
- 1.9.3 and 2.0.
717
-
718
- Fixes #11512.
719
-
720
- *Simeon Simeonov*
721
-
722
- * Only raise `Module::DelegationError` if it's the source of the exception.
723
-
724
- Fixes #10559.
725
-
726
- *Andrew White*
727
-
728
- * Make `Time.at_with_coercion` retain the second fraction and return local time.
729
-
730
- Fixes #11350.
731
-
732
- *Neer Friedman*, *Andrew White*
733
-
734
- * Make `HashWithIndifferentAccess#select` always return the hash, even when
735
- `Hash#select!` returns `nil`, to allow further chaining.
736
-
737
- *Marc Schütz*
738
-
739
- * Remove deprecated `String#encoding_aware?` core extensions (`core_ext/string/encoding`).
740
-
741
- *Arun Agrawal*
742
-
743
- * Remove deprecated `Module#local_constant_names` in favor of `Module#local_constants`.
744
-
745
- *Arun Agrawal*
746
-
747
- * Remove deprecated `DateTime.local_offset` in favor of `DateTime.civil_from_format`.
748
-
749
- *Arun Agrawal*
750
-
751
- * Remove deprecated `Logger` core extensions (`core_ext/logger.rb`).
752
-
753
- *Carlos Antonio da Silva*
754
-
755
- * Remove deprecated `Time#time_with_datetime_fallback`, `Time#utc_time`
756
- and `Time#local_time` in favor of `Time#utc` and `Time#local`.
757
-
758
- *Vipul A M*
759
-
760
- * Remove deprecated `Hash#diff` with no replacement.
761
-
762
- If you're using it to compare hashes for the purpose of testing, please use
763
- MiniTest's `assert_equal` instead.
764
-
765
- *Carlos Antonio da Silva*
766
-
767
- * Remove deprecated `Date#to_time_in_current_zone` in favor of `Date#in_time_zone`.
768
-
769
- *Vipul A M*
770
-
771
- * Remove deprecated `Proc#bind` with no replacement.
772
-
773
- *Carlos Antonio da Silva*
774
-
775
- * Remove deprecated `Array#uniq_by` and `Array#uniq_by!`, use native
776
- `Array#uniq` and `Array#uniq!` instead.
777
-
778
- *Carlos Antonio da Silva*
779
-
780
- * Remove deprecated `ActiveSupport::BasicObject`, use `ActiveSupport::ProxyObject` instead.
781
-
782
- *Carlos Antonio da Silva*
783
-
784
- * Remove deprecated `BufferedLogger`, use `ActiveSupport::Logger` instead.
785
-
786
- *Yves Senn*
787
-
788
- * Remove deprecated `assert_present` and `assert_blank` methods, use `assert
789
- object.blank?` and `assert object.present?` instead.
790
-
791
- *Yves Senn*
792
-
793
- * Fix return value from `BacktraceCleaner#noise` when the cleaner is configured
794
- with multiple silencers.
795
-
796
- Fixes #11030.
797
-
798
- *Mark J. Titorenko*
799
-
800
- * `HashWithIndifferentAccess#select` now returns a `HashWithIndifferentAccess`
801
- instance instead of a `Hash` instance.
802
-
803
- Fixes #10723.
804
-
805
- *Albert Llop*
806
-
807
- * Add `DateTime#usec` and `DateTime#nsec` so that `ActiveSupport::TimeWithZone` keeps
808
- sub-second resolution when wrapping a `DateTime` value.
809
-
810
- Fixes #10855.
811
-
812
- *Andrew White*
813
-
814
- * Fix `ActiveSupport::Dependencies::Loadable#load_dependency` calling
815
- `#blame_file!` on Exceptions that do not have the Blamable mixin
816
-
817
- *Andrew Kreiling*
818
-
819
- * Override `Time.at` to support the passing of Time-like values when called with a single argument.
820
-
821
- *Andrew White*
822
-
823
- * Prevent side effects to hashes inside arrays when
824
- `Hash#with_indifferent_access` is called.
825
-
826
- Fixes #10526.
827
-
828
- *Yves Senn*
829
-
830
- * Removed deprecated `ActiveSupport::JSON::Variable` with no replacement.
831
-
832
- *Toshinori Kajihara*
833
-
834
- * Raise an error when multiple `included` blocks are defined for a Concern.
835
- The old behavior would silently discard previously defined blocks, running
836
- only the last one.
837
-
838
- *Mike Dillon*
839
-
840
- * Replace `multi_json` with `json`.
841
-
842
- Since Rails requires Ruby 1.9 and since Ruby 1.9 includes `json` in the standard library,
843
- `multi_json` is no longer necessary.
844
-
845
- *Erik Michaels-Ober*
846
-
847
- * Added escaping of U+2028 and U+2029 inside the json encoder.
848
- These characters are legal in JSON but break the Javascript interpreter.
849
- After escaping them, the JSON is still legal and can be parsed by Javascript.
850
-
851
- *Mario Caropreso + Viktor Kelemen + zackham*
852
-
853
- * Fix skipping object callbacks using metadata fetched via callback chain
854
- inspection methods (`_*_callbacks`)
855
-
856
- *Sean Walbran*
857
-
858
- * Add a `fetch_multi` method to the cache stores. The method provides
859
- an easy to use API for fetching multiple values from the cache.
860
-
861
- Example:
862
-
863
- # Calculating scores is expensive, so we only do it for posts
864
- # that have been updated. Cache keys are automatically extracted
865
- # from objects that define a #cache_key method.
866
- scores = Rails.cache.fetch_multi(*posts) do |post|
867
- calculate_score(post)
291
+ # app/models/user.rb
292
+ class User < ActiveRecord::Base
293
+ include Authentication
868
294
  end
869
295
 
870
- *Daniel Schierbeck*
296
+ *Jeremy Kemper*
871
297
 
872
- Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activesupport/CHANGELOG.md) for previous changes.
298
+ Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activesupport/CHANGELOG.md) for previous changes.