activesupport 5.0.7.2 → 5.1.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 (210) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +215 -820
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/active_support.rb +8 -4
  6. data/lib/active_support/all.rb +3 -3
  7. data/lib/active_support/array_inquirer.rb +7 -5
  8. data/lib/active_support/backtrace_cleaner.rb +4 -4
  9. data/lib/active_support/benchmarkable.rb +3 -3
  10. data/lib/active_support/builder.rb +1 -1
  11. data/lib/active_support/cache.rb +42 -49
  12. data/lib/active_support/cache/file_store.rb +12 -21
  13. data/lib/active_support/cache/mem_cache_store.rb +30 -40
  14. data/lib/active_support/cache/memory_store.rb +11 -13
  15. data/lib/active_support/cache/null_store.rb +4 -4
  16. data/lib/active_support/cache/strategy/local_cache.rb +16 -25
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +8 -9
  18. data/lib/active_support/callbacks.rb +647 -584
  19. data/lib/active_support/concurrency/share_lock.rb +20 -21
  20. data/lib/active_support/configurable.rb +5 -5
  21. data/lib/active_support/core_ext.rb +1 -2
  22. data/lib/active_support/core_ext/array.rb +7 -7
  23. data/lib/active_support/core_ext/array/access.rb +1 -1
  24. data/lib/active_support/core_ext/array/conversions.rb +15 -15
  25. data/lib/active_support/core_ext/array/grouping.rb +1 -1
  26. data/lib/active_support/core_ext/array/inquiry.rb +1 -1
  27. data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
  28. data/lib/active_support/core_ext/benchmark.rb +1 -1
  29. data/lib/active_support/core_ext/big_decimal.rb +1 -1
  30. data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
  31. data/lib/active_support/core_ext/class.rb +2 -2
  32. data/lib/active_support/core_ext/class/attribute.rb +5 -5
  33. data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
  34. data/lib/active_support/core_ext/class/subclasses.rb +18 -4
  35. data/lib/active_support/core_ext/date.rb +5 -5
  36. data/lib/active_support/core_ext/date/acts_like.rb +1 -1
  37. data/lib/active_support/core_ext/date/blank.rb +1 -1
  38. data/lib/active_support/core_ext/date/calculations.rb +8 -8
  39. data/lib/active_support/core_ext/date/conversions.rb +12 -12
  40. data/lib/active_support/core_ext/date/zones.rb +2 -2
  41. data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
  42. data/lib/active_support/core_ext/date_and_time/compatibility.rb +9 -1
  43. data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
  44. data/lib/active_support/core_ext/date_time.rb +5 -5
  45. data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
  46. data/lib/active_support/core_ext/date_time/blank.rb +1 -1
  47. data/lib/active_support/core_ext/date_time/calculations.rb +9 -9
  48. data/lib/active_support/core_ext/date_time/compatibility.rb +2 -13
  49. data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
  50. data/lib/active_support/core_ext/digest/uuid.rb +4 -4
  51. data/lib/active_support/core_ext/enumerable.rb +46 -57
  52. data/lib/active_support/core_ext/file.rb +1 -1
  53. data/lib/active_support/core_ext/file/atomic.rb +4 -4
  54. data/lib/active_support/core_ext/hash.rb +9 -9
  55. data/lib/active_support/core_ext/hash/compact.rb +12 -9
  56. data/lib/active_support/core_ext/hash/conversions.rb +36 -37
  57. data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
  58. data/lib/active_support/core_ext/hash/keys.rb +8 -8
  59. data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
  60. data/lib/active_support/core_ext/hash/slice.rb +4 -4
  61. data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
  62. data/lib/active_support/core_ext/integer.rb +3 -3
  63. data/lib/active_support/core_ext/integer/inflections.rb +1 -1
  64. data/lib/active_support/core_ext/integer/time.rb +2 -2
  65. data/lib/active_support/core_ext/kernel.rb +4 -4
  66. data/lib/active_support/core_ext/kernel/concern.rb +1 -1
  67. data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
  68. data/lib/active_support/core_ext/load_error.rb +1 -18
  69. data/lib/active_support/core_ext/marshal.rb +2 -2
  70. data/lib/active_support/core_ext/module.rb +11 -12
  71. data/lib/active_support/core_ext/module/aliasing.rb +3 -48
  72. data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
  73. data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -5
  74. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +20 -13
  75. data/lib/active_support/core_ext/module/concerning.rb +1 -1
  76. data/lib/active_support/core_ext/module/delegation.rb +82 -16
  77. data/lib/active_support/core_ext/module/introspection.rb +3 -11
  78. data/lib/active_support/core_ext/module/reachable.rb +2 -2
  79. data/lib/active_support/core_ext/numeric.rb +4 -4
  80. data/lib/active_support/core_ext/numeric/conversions.rb +3 -9
  81. data/lib/active_support/core_ext/numeric/inquiry.rb +21 -21
  82. data/lib/active_support/core_ext/numeric/time.rb +5 -5
  83. data/lib/active_support/core_ext/object.rb +12 -12
  84. data/lib/active_support/core_ext/object/blank.rb +3 -1
  85. data/lib/active_support/core_ext/object/conversions.rb +4 -4
  86. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  87. data/lib/active_support/core_ext/object/duplicable.rb +24 -4
  88. data/lib/active_support/core_ext/object/inclusion.rb +1 -1
  89. data/lib/active_support/core_ext/object/json.rb +26 -12
  90. data/lib/active_support/core_ext/object/to_param.rb +1 -1
  91. data/lib/active_support/core_ext/object/to_query.rb +4 -4
  92. data/lib/active_support/core_ext/object/try.rb +1 -1
  93. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  94. data/lib/active_support/core_ext/range.rb +4 -4
  95. data/lib/active_support/core_ext/range/conversions.rb +1 -1
  96. data/lib/active_support/core_ext/regexp.rb +4 -0
  97. data/lib/active_support/core_ext/securerandom.rb +3 -3
  98. data/lib/active_support/core_ext/string.rb +13 -13
  99. data/lib/active_support/core_ext/string/access.rb +6 -6
  100. data/lib/active_support/core_ext/string/conversions.rb +2 -2
  101. data/lib/active_support/core_ext/string/filters.rb +3 -3
  102. data/lib/active_support/core_ext/string/indent.rb +4 -4
  103. data/lib/active_support/core_ext/string/inflections.rb +10 -14
  104. data/lib/active_support/core_ext/string/inquiry.rb +1 -1
  105. data/lib/active_support/core_ext/string/multibyte.rb +1 -1
  106. data/lib/active_support/core_ext/string/output_safety.rb +19 -20
  107. data/lib/active_support/core_ext/string/strip.rb +1 -1
  108. data/lib/active_support/core_ext/string/zones.rb +2 -2
  109. data/lib/active_support/core_ext/time.rb +5 -5
  110. data/lib/active_support/core_ext/time/acts_like.rb +1 -1
  111. data/lib/active_support/core_ext/time/calculations.rb +23 -29
  112. data/lib/active_support/core_ext/time/compatibility.rb +1 -10
  113. data/lib/active_support/core_ext/time/conversions.rb +12 -12
  114. data/lib/active_support/core_ext/time/zones.rb +3 -3
  115. data/lib/active_support/core_ext/uri.rb +2 -2
  116. data/lib/active_support/dependencies.rb +45 -47
  117. data/lib/active_support/dependencies/interlock.rb +1 -1
  118. data/lib/active_support/deprecation.rb +8 -8
  119. data/lib/active_support/deprecation/behaviors.rb +3 -3
  120. data/lib/active_support/deprecation/instance_delegator.rb +2 -2
  121. data/lib/active_support/deprecation/method_wrappers.rb +3 -3
  122. data/lib/active_support/deprecation/proxy_wrappers.rb +6 -4
  123. data/lib/active_support/deprecation/reporting.rb +7 -7
  124. data/lib/active_support/duration.rb +30 -26
  125. data/lib/active_support/duration/iso8601_parser.rb +66 -65
  126. data/lib/active_support/duration/iso8601_serializer.rb +11 -9
  127. data/lib/active_support/evented_file_update_checker.rb +59 -60
  128. data/lib/active_support/execution_wrapper.rb +3 -3
  129. data/lib/active_support/executor.rb +1 -1
  130. data/lib/active_support/file_update_checker.rb +54 -50
  131. data/lib/active_support/gem_version.rb +3 -3
  132. data/lib/active_support/gzip.rb +5 -5
  133. data/lib/active_support/hash_with_indifferent_access.rb +10 -20
  134. data/lib/active_support/i18n.rb +5 -5
  135. data/lib/active_support/i18n_railtie.rb +11 -10
  136. data/lib/active_support/inflections.rb +11 -11
  137. data/lib/active_support/inflector.rb +5 -5
  138. data/lib/active_support/inflector/inflections.rb +11 -9
  139. data/lib/active_support/inflector/methods.rb +51 -50
  140. data/lib/active_support/inflector/transliterate.rb +8 -11
  141. data/lib/active_support/json.rb +2 -2
  142. data/lib/active_support/json/decoding.rb +3 -3
  143. data/lib/active_support/json/encoding.rb +8 -7
  144. data/lib/active_support/key_generator.rb +17 -17
  145. data/lib/active_support/lazy_load_hooks.rb +12 -30
  146. data/lib/active_support/log_subscriber.rb +5 -5
  147. data/lib/active_support/log_subscriber/test_helper.rb +9 -9
  148. data/lib/active_support/logger.rb +3 -3
  149. data/lib/active_support/logger_silence.rb +3 -3
  150. data/lib/active_support/logger_thread_safe_level.rb +1 -1
  151. data/lib/active_support/message_encryptor.rb +72 -35
  152. data/lib/active_support/message_verifier.rb +7 -7
  153. data/lib/active_support/multibyte.rb +2 -2
  154. data/lib/active_support/multibyte/chars.rb +23 -21
  155. data/lib/active_support/multibyte/unicode.rb +68 -89
  156. data/lib/active_support/notifications.rb +5 -5
  157. data/lib/active_support/notifications/fanout.rb +3 -3
  158. data/lib/active_support/notifications/instrumenter.rb +5 -5
  159. data/lib/active_support/number_helper.rb +4 -4
  160. data/lib/active_support/number_helper/number_converter.rb +11 -11
  161. data/lib/active_support/number_helper/number_to_currency_converter.rb +3 -3
  162. data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -2
  163. data/lib/active_support/number_helper/number_to_human_converter.rb +6 -6
  164. data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -11
  165. data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
  166. data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -3
  167. data/lib/active_support/number_helper/number_to_rounded_converter.rb +6 -6
  168. data/lib/active_support/option_merger.rb +1 -1
  169. data/lib/active_support/ordered_hash.rb +3 -3
  170. data/lib/active_support/ordered_options.rb +6 -4
  171. data/lib/active_support/per_thread_registry.rb +5 -5
  172. data/lib/active_support/rails.rb +12 -6
  173. data/lib/active_support/railtie.rb +3 -3
  174. data/lib/active_support/reloader.rb +1 -1
  175. data/lib/active_support/rescuable.rb +8 -14
  176. data/lib/active_support/security_utils.rb +1 -1
  177. data/lib/active_support/string_inquirer.rb +8 -2
  178. data/lib/active_support/subscriber.rb +9 -5
  179. data/lib/active_support/tagged_logging.rb +4 -4
  180. data/lib/active_support/test_case.rb +12 -29
  181. data/lib/active_support/testing/assertions.rb +100 -2
  182. data/lib/active_support/testing/autorun.rb +6 -2
  183. data/lib/active_support/testing/constant_lookup.rb +0 -1
  184. data/lib/active_support/testing/declarative.rb +1 -1
  185. data/lib/active_support/testing/deprecation.rb +3 -2
  186. data/lib/active_support/testing/isolation.rb +13 -22
  187. data/lib/active_support/testing/method_call_assertions.rb +1 -1
  188. data/lib/active_support/testing/setup_and_teardown.rb +2 -2
  189. data/lib/active_support/testing/stream.rb +28 -28
  190. data/lib/active_support/testing/tagged_logging.rb +1 -1
  191. data/lib/active_support/testing/time_helpers.rb +45 -12
  192. data/lib/active_support/time.rb +12 -12
  193. data/lib/active_support/time_with_zone.rb +16 -26
  194. data/lib/active_support/values/time_zone.rb +40 -46
  195. data/lib/active_support/values/unicode_tables.dat +0 -0
  196. data/lib/active_support/version.rb +1 -1
  197. data/lib/active_support/xml_mini.rb +34 -36
  198. data/lib/active_support/xml_mini/jdom.rb +112 -112
  199. data/lib/active_support/xml_mini/libxml.rb +15 -12
  200. data/lib/active_support/xml_mini/libxmlsax.rb +17 -15
  201. data/lib/active_support/xml_mini/nokogiri.rb +13 -11
  202. data/lib/active_support/xml_mini/nokogirisax.rb +15 -14
  203. data/lib/active_support/xml_mini/rexml.rb +9 -9
  204. metadata +8 -19
  205. data/lib/active_support/concurrency/latch.rb +0 -26
  206. data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
  207. data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
  208. data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
  209. data/lib/active_support/core_ext/struct.rb +0 -3
  210. data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -1,11 +1,11 @@
1
- require 'active_support/xml_mini'
2
- require 'active_support/time'
3
- require 'active_support/core_ext/object/blank'
4
- require 'active_support/core_ext/object/to_param'
5
- require 'active_support/core_ext/object/to_query'
6
- require 'active_support/core_ext/array/wrap'
7
- require 'active_support/core_ext/hash/reverse_merge'
8
- require 'active_support/core_ext/string/inflections'
1
+ require "active_support/xml_mini"
2
+ require "active_support/time"
3
+ require "active_support/core_ext/object/blank"
4
+ require "active_support/core_ext/object/to_param"
5
+ require "active_support/core_ext/object/to_query"
6
+ require "active_support/core_ext/array/wrap"
7
+ require "active_support/core_ext/hash/reverse_merge"
8
+ require "active_support/core_ext/string/inflections"
9
9
 
10
10
  class Hash
11
11
  # Returns a string containing an XML representation of its receiver:
@@ -71,11 +71,11 @@ class Hash
71
71
  # configure your own builder with the <tt>:builder</tt> option. The method also accepts
72
72
  # options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
73
73
  def to_xml(options = {})
74
- require 'active_support/builder' unless defined?(Builder)
74
+ require "active_support/builder" unless defined?(Builder)
75
75
 
76
76
  options = options.dup
77
77
  options[:indent] ||= 2
78
- options[:root] ||= 'hash'
78
+ options[:root] ||= "hash"
79
79
  options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent])
80
80
 
81
81
  builder = options[:builder]
@@ -159,36 +159,36 @@ module ActiveSupport
159
159
  private
160
160
  def normalize_keys(params)
161
161
  case params
162
- when Hash
163
- Hash[params.map { |k,v| [k.to_s.tr('-', '_'), normalize_keys(v)] } ]
164
- when Array
165
- params.map { |v| normalize_keys(v) }
162
+ when Hash
163
+ Hash[params.map { |k, v| [k.to_s.tr("-", "_"), normalize_keys(v)] } ]
164
+ when Array
165
+ params.map { |v| normalize_keys(v) }
166
166
  else
167
- params
167
+ params
168
168
  end
169
169
  end
170
170
 
171
171
  def deep_to_h(value)
172
172
  case value
173
- when Hash
174
- process_hash(value)
175
- when Array
176
- process_array(value)
177
- when String
178
- value
173
+ when Hash
174
+ process_hash(value)
175
+ when Array
176
+ process_array(value)
177
+ when String
178
+ value
179
179
  else
180
- raise "can't typecast #{value.class.name} - #{value.inspect}"
180
+ raise "can't typecast #{value.class.name} - #{value.inspect}"
181
181
  end
182
182
  end
183
183
 
184
184
  def process_hash(value)
185
- if value.include?('type') && !value['type'].is_a?(Hash) && @disallowed_types.include?(value['type'])
186
- raise DisallowedType, value['type']
185
+ if value.include?("type") && !value["type"].is_a?(Hash) && @disallowed_types.include?(value["type"])
186
+ raise DisallowedType, value["type"]
187
187
  end
188
188
 
189
189
  if become_array?(value)
190
- _, entries = Array.wrap(value.detect { |k,v| not v.is_a?(String) })
191
- if entries.nil? || value['__content__'].try(:empty?)
190
+ _, entries = Array.wrap(value.detect { |k, v| not v.is_a?(String) })
191
+ if entries.nil? || value["__content__"].try(:empty?)
192
192
  []
193
193
  else
194
194
  case entries
@@ -204,28 +204,28 @@ module ActiveSupport
204
204
  process_content(value)
205
205
 
206
206
  elsif become_empty_string?(value)
207
- ''
207
+ ""
208
208
  elsif become_hash?(value)
209
- xml_value = Hash[value.map { |k,v| [k, deep_to_h(v)] }]
209
+ xml_value = Hash[value.map { |k, v| [k, deep_to_h(v)] }]
210
210
 
211
211
  # Turn { files: { file: #<StringIO> } } into { files: #<StringIO> } so it is compatible with
212
212
  # how multipart uploaded files from HTML appear
213
- xml_value['file'].is_a?(StringIO) ? xml_value['file'] : xml_value
213
+ xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value
214
214
  end
215
215
  end
216
216
 
217
217
  def become_content?(value)
218
- value['type'] == 'file' || (value['__content__'] && (value.keys.size == 1 || value['__content__'].present?))
218
+ value["type"] == "file" || (value["__content__"] && (value.keys.size == 1 || value["__content__"].present?))
219
219
  end
220
220
 
221
221
  def become_array?(value)
222
- value['type'] == 'array'
222
+ value["type"] == "array"
223
223
  end
224
224
 
225
225
  def become_empty_string?(value)
226
226
  # { "string" => true }
227
227
  # No tests fail when the second term is removed.
228
- value['type'] == 'string' && value['nil'] != 'true'
228
+ value["type"] == "string" && value["nil"] != "true"
229
229
  end
230
230
 
231
231
  def become_hash?(value)
@@ -234,19 +234,19 @@ module ActiveSupport
234
234
 
235
235
  def nothing?(value)
236
236
  # blank or nil parsed values are represented by nil
237
- value.blank? || value['nil'] == 'true'
237
+ value.blank? || value["nil"] == "true"
238
238
  end
239
239
 
240
240
  def garbage?(value)
241
241
  # If the type is the only element which makes it then
242
242
  # this still makes the value nil, except if type is
243
243
  # an XML node(where type['value'] is a Hash)
244
- value['type'] && !value['type'].is_a?(::Hash) && value.size == 1
244
+ value["type"] && !value["type"].is_a?(::Hash) && value.size == 1
245
245
  end
246
246
 
247
247
  def process_content(value)
248
- content = value['__content__']
249
- if parser = ActiveSupport::XmlMini::PARSING[value['type']]
248
+ content = value["__content__"]
249
+ if parser = ActiveSupport::XmlMini::PARSING[value["type"]]
250
250
  parser.arity == 1 ? parser.call(content) : parser.call(content, value)
251
251
  else
252
252
  content
@@ -257,6 +257,5 @@ module ActiveSupport
257
257
  value.map! { |i| deep_to_h(i) }
258
258
  value.length > 1 ? value : value.first
259
259
  end
260
-
261
260
  end
262
261
  end
@@ -1,7 +1,6 @@
1
- require 'active_support/hash_with_indifferent_access'
1
+ require "active_support/hash_with_indifferent_access"
2
2
 
3
3
  class Hash
4
-
5
4
  # Returns an <tt>ActiveSupport::HashWithIndifferentAccess</tt> out of its receiver:
6
5
  #
7
6
  # { a: 1 }.with_indifferent_access['a'] # => 1
@@ -16,7 +16,7 @@ class Hash
16
16
  result[yield(key)] = self[key]
17
17
  end
18
18
  result
19
- end unless method_defined? :transform_keys
19
+ end
20
20
 
21
21
  # Destructively converts all keys using the +block+ operations.
22
22
  # Same as +transform_keys+ but modifies +self+.
@@ -26,7 +26,7 @@ class Hash
26
26
  self[yield(key)] = delete(key)
27
27
  end
28
28
  self
29
- end unless method_defined? :transform_keys!
29
+ end
30
30
 
31
31
  # Returns a new hash with all keys converted to strings.
32
32
  #
@@ -52,14 +52,14 @@ class Hash
52
52
  # hash.symbolize_keys
53
53
  # # => {:name=>"Rob", :age=>"28"}
54
54
  def symbolize_keys
55
- transform_keys{ |key| key.to_sym rescue key }
55
+ transform_keys { |key| key.to_sym rescue key }
56
56
  end
57
57
  alias_method :to_options, :symbolize_keys
58
58
 
59
59
  # Destructively converts all keys to symbols, as long as they respond
60
60
  # to +to_sym+. Same as +symbolize_keys+, but modifies +self+.
61
61
  def symbolize_keys!
62
- transform_keys!{ |key| key.to_sym rescue key }
62
+ transform_keys! { |key| key.to_sym rescue key }
63
63
  end
64
64
  alias_method :to_options!, :symbolize_keys!
65
65
 
@@ -128,14 +128,14 @@ class Hash
128
128
  # hash.deep_symbolize_keys
129
129
  # # => {:person=>{:name=>"Rob", :age=>"28"}}
130
130
  def deep_symbolize_keys
131
- deep_transform_keys{ |key| key.to_sym rescue key }
131
+ deep_transform_keys { |key| key.to_sym rescue key }
132
132
  end
133
133
 
134
134
  # Destructively converts all keys to symbols, as long as they respond
135
135
  # to +to_sym+. This includes the keys from the root hash and from all
136
136
  # nested hashes and arrays.
137
137
  def deep_symbolize_keys!
138
- deep_transform_keys!{ |key| key.to_sym rescue key }
138
+ deep_transform_keys! { |key| key.to_sym rescue key }
139
139
  end
140
140
 
141
141
  private
@@ -147,7 +147,7 @@ class Hash
147
147
  result[yield(key)] = _deep_transform_keys_in_object(value, &block)
148
148
  end
149
149
  when Array
150
- object.map {|e| _deep_transform_keys_in_object(e, &block) }
150
+ object.map { |e| _deep_transform_keys_in_object(e, &block) }
151
151
  else
152
152
  object
153
153
  end
@@ -162,7 +162,7 @@ class Hash
162
162
  end
163
163
  object
164
164
  when Array
165
- object.map! {|e| _deep_transform_keys_in_object!(e, &block)}
165
+ object.map! { |e| _deep_transform_keys_in_object!(e, &block) }
166
166
  else
167
167
  object
168
168
  end
@@ -16,7 +16,7 @@ class Hash
16
16
  # Destructive +reverse_merge+.
17
17
  def reverse_merge!(other_hash)
18
18
  # right wins if there is no left
19
- merge!( other_hash ){|key,left,right| left }
19
+ merge!(other_hash) { |key, left, right| left }
20
20
  end
21
21
  alias_method :reverse_update, :reverse_merge!
22
22
  end
@@ -1,11 +1,11 @@
1
1
  class Hash
2
- # Slices a hash to include only the given keys. Returns a hash containing
2
+ # Slices a hash to include only the given keys. Returns a hash containing
3
3
  # the given keys.
4
- #
4
+ #
5
5
  # { a: 1, b: 2, c: 3, d: 4 }.slice(:a, :b)
6
6
  # # => {:a=>1, :b=>2}
7
- #
8
- # This is useful for limiting an options hash to valid keys before
7
+ #
8
+ # This is useful for limiting an options hash to valid keys before
9
9
  # passing to a method:
10
10
  #
11
11
  # def search(criteria = {})
@@ -26,4 +26,5 @@ class Hash
26
26
  self[key] = yield(value)
27
27
  end
28
28
  end unless method_defined? :transform_values!
29
+ # TODO: Remove this file when supporting only Ruby 2.4+.
29
30
  end
@@ -1,3 +1,3 @@
1
- require 'active_support/core_ext/integer/multiple'
2
- require 'active_support/core_ext/integer/inflections'
3
- require 'active_support/core_ext/integer/time'
1
+ require "active_support/core_ext/integer/multiple"
2
+ require "active_support/core_ext/integer/inflections"
3
+ require "active_support/core_ext/integer/time"
@@ -1,4 +1,4 @@
1
- require 'active_support/inflector'
1
+ require "active_support/inflector"
2
2
 
3
3
  class Integer
4
4
  # Ordinalize turns a number into an ordinal string used to denote the
@@ -1,5 +1,5 @@
1
- require 'active_support/duration'
2
- require 'active_support/core_ext/numeric/time'
1
+ require "active_support/duration"
2
+ require "active_support/core_ext/numeric/time"
3
3
 
4
4
  class Integer
5
5
  # Enables the use of time calculations and declarations, like <tt>45.minutes +
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/kernel/agnostics'
2
- require 'active_support/core_ext/kernel/concern'
3
- require 'active_support/core_ext/kernel/reporting'
4
- require 'active_support/core_ext/kernel/singleton_class'
1
+ require "active_support/core_ext/kernel/agnostics"
2
+ require "active_support/core_ext/kernel/concern"
3
+ require "active_support/core_ext/kernel/reporting"
4
+ require "active_support/core_ext/kernel/singleton_class"
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/module/concerning'
1
+ require "active_support/core_ext/module/concerning"
2
2
 
3
3
  module Kernel
4
4
  module_function
@@ -1,7 +1,7 @@
1
1
  module Kernel
2
2
  module_function
3
3
 
4
- # Sets $VERBOSE to nil for the duration of the block and back to its original
4
+ # Sets $VERBOSE to +nil+ for the duration of the block and back to its original
5
5
  # value afterwards.
6
6
  #
7
7
  # silence_warnings do
@@ -1,6 +1,3 @@
1
- require "active_support/deprecation"
2
- require "active_support/deprecation/proxy_wrappers"
3
-
4
1
  class LoadError
5
2
  REGEXPS = [
6
3
  /^no such file to load -- (.+)$/i,
@@ -9,23 +6,9 @@ class LoadError
9
6
  /^cannot load such file -- (.+)$/i,
10
7
  ]
11
8
 
12
- unless method_defined?(:path)
13
- # Returns the path which was unable to be loaded.
14
- def path
15
- @path ||= begin
16
- REGEXPS.find do |regex|
17
- message =~ regex
18
- end
19
- $1
20
- end
21
- end
22
- end
23
-
24
9
  # Returns true if the given path name (except perhaps for the ".rb"
25
10
  # extension) is the missing file which caused the exception to be raised.
26
11
  def is_missing?(location)
27
- location.sub(/\.rb$/, ''.freeze) == path.sub(/\.rb$/, ''.freeze)
12
+ location.sub(/\.rb$/, "".freeze) == path.sub(/\.rb$/, "".freeze)
28
13
  end
29
14
  end
30
-
31
- MissingSourceFile = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('MissingSourceFile', 'LoadError')
@@ -1,7 +1,7 @@
1
1
  module ActiveSupport
2
2
  module MarshalWithAutoloading # :nodoc:
3
- def load(source, proc = nil)
4
- super(source, proc)
3
+ def load(source)
4
+ super(source)
5
5
  rescue ArgumentError, NameError => exc
6
6
  if exc.message.match(%r|undefined class/module (.+?)(?:::)?\z|)
7
7
  # try loading the class/module
@@ -1,12 +1,11 @@
1
- require 'active_support/core_ext/module/aliasing'
2
- require 'active_support/core_ext/module/introspection'
3
- require 'active_support/core_ext/module/anonymous'
4
- require 'active_support/core_ext/module/reachable'
5
- require 'active_support/core_ext/module/attribute_accessors'
6
- require 'active_support/core_ext/module/attribute_accessors_per_thread'
7
- require 'active_support/core_ext/module/attr_internal'
8
- require 'active_support/core_ext/module/concerning'
9
- require 'active_support/core_ext/module/delegation'
10
- require 'active_support/core_ext/module/deprecation'
11
- require 'active_support/core_ext/module/remove_method'
12
- require 'active_support/core_ext/module/qualified_const'
1
+ require "active_support/core_ext/module/aliasing"
2
+ require "active_support/core_ext/module/introspection"
3
+ require "active_support/core_ext/module/anonymous"
4
+ require "active_support/core_ext/module/reachable"
5
+ require "active_support/core_ext/module/attribute_accessors"
6
+ require "active_support/core_ext/module/attribute_accessors_per_thread"
7
+ require "active_support/core_ext/module/attr_internal"
8
+ require "active_support/core_ext/module/concerning"
9
+ require "active_support/core_ext/module/delegation"
10
+ require "active_support/core_ext/module/deprecation"
11
+ require "active_support/core_ext/module/remove_method"
@@ -1,52 +1,4 @@
1
1
  class Module
2
- # NOTE: This method is deprecated. Please use <tt>Module#prepend</tt> that
3
- # comes with Ruby 2.0 or newer instead.
4
- #
5
- # Encapsulates the common pattern of:
6
- #
7
- # alias_method :foo_without_feature, :foo
8
- # alias_method :foo, :foo_with_feature
9
- #
10
- # With this, you simply do:
11
- #
12
- # alias_method_chain :foo, :feature
13
- #
14
- # And both aliases are set up for you.
15
- #
16
- # Query and bang methods (foo?, foo!) keep the same punctuation:
17
- #
18
- # alias_method_chain :foo?, :feature
19
- #
20
- # is equivalent to
21
- #
22
- # alias_method :foo_without_feature?, :foo?
23
- # alias_method :foo?, :foo_with_feature?
24
- #
25
- # so you can safely chain foo, foo?, foo! and/or foo= with the same feature.
26
- def alias_method_chain(target, feature)
27
- ActiveSupport::Deprecation.warn("alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super.")
28
-
29
- # Strip out punctuation on predicates, bang or writer methods since
30
- # e.g. target?_without_feature is not a valid method name.
31
- aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
32
- yield(aliased_target, punctuation) if block_given?
33
-
34
- with_method = "#{aliased_target}_with_#{feature}#{punctuation}"
35
- without_method = "#{aliased_target}_without_#{feature}#{punctuation}"
36
-
37
- alias_method without_method, target
38
- alias_method target, with_method
39
-
40
- case
41
- when public_method_defined?(without_method)
42
- public target
43
- when protected_method_defined?(without_method)
44
- protected target
45
- when private_method_defined?(without_method)
46
- private target
47
- end
48
- end
49
-
50
2
  # Allows you to make aliases for attributes, which includes
51
3
  # getter, setter, and a predicate.
52
4
  #
@@ -65,6 +17,9 @@ class Module
65
17
  # e.subject = "Megastars"
66
18
  # e.title # => "Megastars"
67
19
  def alias_attribute(new_name, old_name)
20
+ # The following reader methods use an explicit `self` receiver in order to
21
+ # support aliases that start with an uppercase letter. Otherwise, they would
22
+ # be resolved as constants instead.
68
23
  module_eval <<-STR, __FILE__, __LINE__ + 1
69
24
  def #{new_name}; self.#{old_name}; end # def subject; self.title; end
70
25
  def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end
@@ -1,12 +1,12 @@
1
1
  class Module
2
2
  # Declares an attribute reader backed by an internally-named instance variable.
3
3
  def attr_internal_reader(*attrs)
4
- attrs.each {|attr_name| attr_internal_define(attr_name, :reader)}
4
+ attrs.each { |attr_name| attr_internal_define(attr_name, :reader) }
5
5
  end
6
6
 
7
7
  # Declares an attribute writer backed by an internally-named instance variable.
8
8
  def attr_internal_writer(*attrs)
9
- attrs.each {|attr_name| attr_internal_define(attr_name, :writer)}
9
+ attrs.each { |attr_name| attr_internal_define(attr_name, :writer) }
10
10
  end
11
11
 
12
12
  # Declares an attribute reader and writer backed by an internally-named instance
@@ -18,7 +18,7 @@ class Module
18
18
  alias_method :attr_internal, :attr_internal_accessor
19
19
 
20
20
  class << self; attr_accessor :attr_internal_naming_format end
21
- self.attr_internal_naming_format = '@_%s'
21
+ self.attr_internal_naming_format = "@_%s"
22
22
 
23
23
  private
24
24
  def attr_internal_ivar_name(attr)
@@ -26,7 +26,7 @@ class Module
26
26
  end
27
27
 
28
28
  def attr_internal_define(attr_name, type)
29
- internal_name = attr_internal_ivar_name(attr_name).sub(/\A@/, '')
29
+ internal_name = attr_internal_ivar_name(attr_name).sub(/\A@/, "")
30
30
  # use native attr_* methods as they are faster on some Ruby implementations
31
31
  send("attr_#{type}", internal_name)
32
32
  attr_name, internal_name = "#{attr_name}=", "#{internal_name}=" if type == :writer