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
@@ -12,7 +12,7 @@ module ActiveSupport
12
12
  private
13
13
 
14
14
  def parts
15
- left, right = number.to_s.split('.'.freeze)
15
+ left, right = number.to_s.split(".".freeze)
16
16
  left.gsub!(delimiter_pattern) do |digit_to_delimit|
17
17
  "#{digit_to_delimit}#{options[:delimiter]}"
18
18
  end
@@ -22,7 +22,6 @@ module ActiveSupport
22
22
  def delimiter_pattern
23
23
  options.fetch(:delimiter_pattern, DEFAULT_DELIMITER_REGEX)
24
24
  end
25
-
26
25
  end
27
26
  end
28
27
  end
@@ -18,29 +18,29 @@ module ActiveSupport
18
18
 
19
19
  units = opts[:units]
20
20
  exponent = calculate_exponent(units)
21
- @number = number / (10 ** exponent)
21
+ @number = number / (10**exponent)
22
22
 
23
23
  until (rounded_number = NumberToRoundedConverter.convert(number, options)) != NumberToRoundedConverter.convert(1000, options)
24
24
  @number = number / 1000.0
25
25
  exponent += 3
26
26
  end
27
27
  unit = determine_unit(units, exponent)
28
- format.gsub('%n'.freeze, rounded_number).gsub('%u'.freeze, unit).strip
28
+ format.gsub("%n".freeze, rounded_number).gsub("%u".freeze, unit).strip
29
29
  end
30
30
 
31
31
  private
32
32
 
33
33
  def format
34
- options[:format] || translate_in_locale('human.decimal_units.format')
34
+ options[:format] || translate_in_locale("human.decimal_units.format")
35
35
  end
36
36
 
37
37
  def determine_unit(units, exponent)
38
38
  exp = DECIMAL_UNITS[exponent]
39
39
  case units
40
40
  when Hash
41
- units[exp] || ''
41
+ units[exp] || ""
42
42
  when String, Symbol
43
- I18n.translate("#{units}.#{exp}", :locale => options[:locale], :count => number.to_i)
43
+ I18n.translate("#{units}.#{exp}", locale: options[:locale], count: number.to_i)
44
44
  else
45
45
  translate_in_locale("human.decimal_units.units.#{exp}", count: number.to_i)
46
46
  end
@@ -56,7 +56,7 @@ module ActiveSupport
56
56
  when Hash
57
57
  units
58
58
  when String, Symbol
59
- I18n.translate(units.to_s, :locale => options[:locale], :raise => true)
59
+ I18n.translate(units.to_s, locale: options[:locale], raise: true)
60
60
  when nil
61
61
  translate_in_locale("human.decimal_units.units", raise: true)
62
62
  else
@@ -7,10 +7,6 @@ module ActiveSupport
7
7
  self.validate_float = true
8
8
 
9
9
  def convert
10
- if opts.key?(:prefix)
11
- ActiveSupport::Deprecation.warn('The :prefix option of `number_to_human_size` is deprecated and will be removed in Rails 5.1 with no replacement.')
12
- end
13
-
14
10
  @number = Float(number)
15
11
 
16
12
  # for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
@@ -21,24 +17,24 @@ module ActiveSupport
21
17
  if smaller_than_base?
22
18
  number_to_format = number.to_i.to_s
23
19
  else
24
- human_size = number / (base ** exponent)
20
+ human_size = number / (base**exponent)
25
21
  number_to_format = NumberToRoundedConverter.convert(human_size, options)
26
22
  end
27
- conversion_format.gsub('%n'.freeze, number_to_format).gsub('%u'.freeze, unit)
23
+ conversion_format.gsub("%n".freeze, number_to_format).gsub("%u".freeze, unit)
28
24
  end
29
25
 
30
26
  private
31
27
 
32
28
  def conversion_format
33
- translate_number_value_with_default('human.storage_units.format', :locale => options[:locale], :raise => true)
29
+ translate_number_value_with_default("human.storage_units.format", locale: options[:locale], raise: true)
34
30
  end
35
31
 
36
32
  def unit
37
- translate_number_value_with_default(storage_unit_key, :locale => options[:locale], :count => number.to_i, :raise => true)
33
+ translate_number_value_with_default(storage_unit_key, locale: options[:locale], count: number.to_i, raise: true)
38
34
  end
39
35
 
40
36
  def storage_unit_key
41
- key_end = smaller_than_base? ? 'byte' : STORAGE_UNITS[exponent]
37
+ key_end = smaller_than_base? ? "byte" : STORAGE_UNITS[exponent]
42
38
  "human.storage_units.units.#{key_end}"
43
39
  end
44
40
 
@@ -54,9 +50,8 @@ module ActiveSupport
54
50
  end
55
51
 
56
52
  def base
57
- opts[:prefix] == :si ? 1000 : 1024
53
+ 1024
58
54
  end
59
55
  end
60
56
  end
61
57
  end
62
-
@@ -5,7 +5,7 @@ module ActiveSupport
5
5
 
6
6
  def convert
7
7
  rounded_number = NumberToRoundedConverter.convert(number, options)
8
- options[:format].gsub('%n'.freeze, rounded_number)
8
+ options[:format].gsub("%n".freeze, rounded_number)
9
9
  end
10
10
  end
11
11
  end
@@ -2,7 +2,7 @@ module ActiveSupport
2
2
  module NumberHelper
3
3
  class NumberToPhoneConverter < NumberConverter #:nodoc:
4
4
  def convert
5
- str = country_code(opts[:country_code])
5
+ str = country_code(opts[:country_code])
6
6
  str << convert_to_phone_number(number.to_s.strip)
7
7
  str << phone_ext(opts[:extension])
8
8
  end
@@ -51,8 +51,6 @@ module ActiveSupport
51
51
  def regexp_pattern(default_pattern)
52
52
  opts.fetch :pattern, default_pattern
53
53
  end
54
-
55
54
  end
56
55
  end
57
56
  end
58
-
@@ -29,10 +29,10 @@ module ActiveSupport
29
29
 
30
30
  formatted_string =
31
31
  if BigDecimal === rounded_number && rounded_number.finite?
32
- s = rounded_number.to_s('F')
33
- s << '0'.freeze * precision
34
- a, b = s.split('.'.freeze, 2)
35
- a << '.'.freeze
32
+ s = rounded_number.to_s("F")
33
+ s << "0".freeze * precision
34
+ a, b = s.split(".".freeze, 2)
35
+ a << ".".freeze
36
36
  a << b[0, precision]
37
37
  else
38
38
  "%00.#{precision}f" % rounded_number
@@ -52,7 +52,7 @@ module ActiveSupport
52
52
  [1, 0]
53
53
  else
54
54
  digits = digit_count(number)
55
- multiplier = 10 ** (digits - precision)
55
+ multiplier = 10**(digits - precision)
56
56
  rounded_number = calculate_rounded_number(multiplier)
57
57
  digits = digit_count(rounded_number) # After rounding, the number of digits may have changed
58
58
  [digits, rounded_number]
@@ -74,7 +74,7 @@ module ActiveSupport
74
74
  def format_number(number)
75
75
  if strip_insignificant_zeros
76
76
  escaped_separator = Regexp.escape(options[:separator])
77
- number.sub(/(#{escaped_separator})(\d*[1-9])?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, '')
77
+ number.sub(/(#{escaped_separator})(\d*[1-9])?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, "")
78
78
  else
79
79
  number
80
80
  end
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/hash/deep_merge'
1
+ require "active_support/core_ext/hash/deep_merge"
2
2
 
3
3
  module ActiveSupport
4
4
  class OptionMerger #:nodoc:
@@ -1,7 +1,7 @@
1
- require 'yaml'
1
+ require "yaml"
2
2
 
3
3
  YAML.add_builtin_type("omap") do |type, val|
4
- ActiveSupport::OrderedHash[val.map{ |v| v.to_a.first }]
4
+ ActiveSupport::OrderedHash[val.map { |v| v.to_a.first }]
5
5
  end
6
6
 
7
7
  module ActiveSupport
@@ -25,7 +25,7 @@ module ActiveSupport
25
25
  end
26
26
 
27
27
  def encode_with(coder)
28
- coder.represent_seq '!omap', map { |k,v| { k => v } }
28
+ coder.represent_seq "!omap", map { |k, v| { k => v } }
29
29
  end
30
30
 
31
31
  def select(*args, &block)
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/object/blank"
2
+
1
3
  module ActiveSupport
2
4
  # Usually key value pairs are handled something like this:
3
5
  #
@@ -36,10 +38,10 @@ module ActiveSupport
36
38
 
37
39
  def method_missing(name, *args)
38
40
  name_string = name.to_s
39
- if name_string.chomp!('=')
41
+ if name_string.chomp!("=")
40
42
  self[name_string] = args.first
41
43
  else
42
- bangs = name_string.chomp!('!')
44
+ bangs = name_string.chomp!("!")
43
45
 
44
46
  if bangs
45
47
  fetch(name_string.to_sym).presence || raise(KeyError.new("#{name_string} is blank."))
@@ -66,9 +68,9 @@ module ActiveSupport
66
68
  def initialize(parent = nil)
67
69
  if parent.kind_of?(OrderedOptions)
68
70
  # use the faster _get when dealing with OrderedOptions
69
- super() { |h,k| parent._get(k) }
71
+ super() { |h, k| parent._get(k) }
70
72
  elsif parent
71
- super() { |h,k| parent[k] }
73
+ super() { |h, k| parent[k] }
72
74
  else
73
75
  super()
74
76
  end
@@ -1,7 +1,7 @@
1
- require 'active_support/core_ext/module/delegation'
1
+ require "active_support/core_ext/module/delegation"
2
2
 
3
3
  module ActiveSupport
4
- # NOTE: This approach has been deprecated for end-user code in favor of thread_mattr_accessor and friends.
4
+ # NOTE: This approach has been deprecated for end-user code in favor of {thread_mattr_accessor}[rdoc-ref:Module#thread_mattr_accessor] and friends.
5
5
  # Please use that approach instead.
6
6
  #
7
7
  # This module is used to encapsulate access to thread local variables.
@@ -38,15 +38,15 @@ module ActiveSupport
38
38
  # If the class has an initializer, it must accept no arguments.
39
39
  module PerThreadRegistry
40
40
  def self.extended(object)
41
- object.instance_variable_set '@per_thread_registry_key', object.name.freeze
41
+ object.instance_variable_set "@per_thread_registry_key", object.name.freeze
42
42
  end
43
43
 
44
44
  def instance
45
45
  Thread.current[@per_thread_registry_key] ||= new
46
46
  end
47
47
 
48
- protected
49
- def method_missing(name, *args, &block) # :nodoc:
48
+ private
49
+ def method_missing(name, *args, &block)
50
50
  # Caches the method definition as a singleton method of the receiver.
51
51
  #
52
52
  # By letting #delegate handle it, we avoid an enclosure that'll capture args.
@@ -9,19 +9,25 @@
9
9
  # Rails and can change anytime.
10
10
 
11
11
  # Defines Object#blank? and Object#present?.
12
- require 'active_support/core_ext/object/blank'
12
+ require "active_support/core_ext/object/blank"
13
13
 
14
14
  # Rails own autoload, eager_load, etc.
15
- require 'active_support/dependencies/autoload'
15
+ require "active_support/dependencies/autoload"
16
16
 
17
17
  # Support for ClassMethods and the included macro.
18
- require 'active_support/concern'
18
+ require "active_support/concern"
19
19
 
20
20
  # Defines Class#class_attribute.
21
- require 'active_support/core_ext/class/attribute'
21
+ require "active_support/core_ext/class/attribute"
22
22
 
23
23
  # Defines Module#delegate.
24
- require 'active_support/core_ext/module/delegation'
24
+ require "active_support/core_ext/module/delegation"
25
25
 
26
26
  # Defines ActiveSupport::Deprecation.
27
- require 'active_support/deprecation'
27
+ require "active_support/deprecation"
28
+
29
+ # Defines Regexp#match?.
30
+ #
31
+ # This should be removed when Rails needs Ruby 2.4 or later, and the require
32
+ # added where other Regexp extensions are being used (easy to grep).
33
+ require "active_support/core_ext/regexp"
@@ -21,11 +21,11 @@ module ActiveSupport
21
21
  rescue TZInfo::DataSourceNotFound => e
22
22
  raise e.exception "tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install"
23
23
  end
24
- require 'active_support/core_ext/time/zones'
24
+ require "active_support/core_ext/time/zones"
25
25
  zone_default = Time.find_zone!(app.config.time_zone)
26
26
 
27
27
  unless zone_default
28
- raise 'Value assigned to config.time_zone not recognized. ' \
28
+ raise "Value assigned to config.time_zone not recognized. " \
29
29
  'Run "rake time:zones:all" for a time zone names list.'
30
30
  end
31
31
 
@@ -35,7 +35,7 @@ module ActiveSupport
35
35
  # Sets the default week start
36
36
  # If assigned value is not a valid day symbol (e.g. :sunday, :monday, ...), an exception will be raised.
37
37
  initializer "active_support.initialize_beginning_of_week" do |app|
38
- require 'active_support/core_ext/date/calculations'
38
+ require "active_support/core_ext/date/calculations"
39
39
  beginning_of_week_default = Date.find_beginning_of_week!(app.config.beginning_of_week)
40
40
 
41
41
  Date.beginning_of_week_default = beginning_of_week_default
@@ -1,4 +1,4 @@
1
- require 'active_support/execution_wrapper'
1
+ require "active_support/execution_wrapper"
2
2
 
3
3
  module ActiveSupport
4
4
  #--
@@ -1,6 +1,6 @@
1
- require 'active_support/concern'
2
- require 'active_support/core_ext/class/attribute'
3
- require 'active_support/core_ext/string/inflections'
1
+ require "active_support/concern"
2
+ require "active_support/core_ext/class/attribute"
3
+ require "active_support/core_ext/string/inflections"
4
4
 
5
5
  module ActiveSupport
6
6
  # Rescuable module adds support for easier exception handling.
@@ -36,7 +36,7 @@ module ActiveSupport
36
36
  # render xml: exception, status: 500
37
37
  # end
38
38
  #
39
- # protected
39
+ # private
40
40
  # def deny_access
41
41
  # ...
42
42
  # end
@@ -52,7 +52,7 @@ module ActiveSupport
52
52
  if block_given?
53
53
  with = block
54
54
  else
55
- raise ArgumentError, 'Need a handler. Pass the with: keyword argument or provide a block.'
55
+ raise ArgumentError, "Need a handler. Pass the with: keyword argument or provide a block."
56
56
  end
57
57
  end
58
58
 
@@ -74,7 +74,7 @@ module ActiveSupport
74
74
  #
75
75
  # If no handler matches the exception, check for a handler matching the
76
76
  # (optional) exception.cause. If no handler matches the exception or its
77
- # cause, this returns nil so you can deal with unhandled exceptions.
77
+ # cause, this returns +nil+, so you can deal with unhandled exceptions.
78
78
  # Be sure to re-raise unhandled exceptions if this is what you expect.
79
79
  #
80
80
  # begin
@@ -84,18 +84,12 @@ module ActiveSupport
84
84
  # end
85
85
  #
86
86
  # Returns the exception if it was handled and +nil+ if it was not.
87
- def rescue_with_handler(exception, object: self, visited_exceptions: [])
88
- visited_exceptions << exception
89
-
87
+ def rescue_with_handler(exception, object: self)
90
88
  if handler = handler_for_rescue(exception, object: object)
91
89
  handler.call exception
92
90
  exception
93
91
  elsif exception
94
- if visited_exceptions.include?(exception.cause)
95
- nil
96
- else
97
- rescue_with_handler(exception.cause, object: object, visited_exceptions: visited_exceptions)
98
- end
92
+ rescue_with_handler(exception.cause, object: object)
99
93
  end
100
94
  end
101
95
 
@@ -1,4 +1,4 @@
1
- require 'digest'
1
+ require "digest"
2
2
 
3
3
  module ActiveSupport
4
4
  module SecurityUtils
@@ -8,15 +8,21 @@ module ActiveSupport
8
8
  # you can call this:
9
9
  #
10
10
  # Rails.env.production?
11
+ #
12
+ # == Instantiating a new StringInquirer
13
+ #
14
+ # vehicle = ActiveSupport::StringInquirer.new('car')
15
+ # vehicle.car? # => true
16
+ # vehicle.bike? # => false
11
17
  class StringInquirer < String
12
18
  private
13
19
 
14
20
  def respond_to_missing?(method_name, include_private = false)
15
- method_name[-1] == '?'
21
+ (method_name[-1] == "?") || super
16
22
  end
17
23
 
18
24
  def method_missing(method_name, *arguments)
19
- if method_name[-1] == '?'
25
+ if method_name[-1] == "?"
20
26
  self == method_name[0..-2]
21
27
  else
22
28
  super
@@ -1,4 +1,5 @@
1
- require 'active_support/per_thread_registry'
1
+ require "active_support/per_thread_registry"
2
+ require "active_support/notifications"
2
3
 
3
4
  module ActiveSupport
4
5
  # ActiveSupport::Subscriber is an object set to consume
@@ -23,9 +24,8 @@ module ActiveSupport
23
24
  # the +sql+ method.
24
25
  class Subscriber
25
26
  class << self
26
-
27
27
  # Attach the subscriber to a namespace.
28
- def attach_to(namespace, subscriber=new, notifier=ActiveSupport::Notifications)
28
+ def attach_to(namespace, subscriber = new, notifier = ActiveSupport::Notifications)
29
29
  @namespace = namespace
30
30
  @subscriber = subscriber
31
31
  @notifier = notifier
@@ -52,11 +52,15 @@ module ActiveSupport
52
52
  @@subscribers ||= []
53
53
  end
54
54
 
55
+ # TODO Change this to private once we've dropped Ruby 2.2 support.
56
+ # Workaround for Ruby 2.2 "private attribute?" warning.
55
57
  protected
56
58
 
57
59
  attr_reader :subscriber, :notifier, :namespace
58
60
 
59
- def add_event_subscriber(event)
61
+ private
62
+
63
+ def add_event_subscriber(event) # :doc:
60
64
  return if %w{ start finish }.include?(event.to_s)
61
65
 
62
66
  pattern = "#{event}.#{namespace}"
@@ -91,7 +95,7 @@ module ActiveSupport
91
95
  event.end = finished
92
96
  event.payload.merge!(payload)
93
97
 
94
- method = name.split('.'.freeze).first
98
+ method = name.split(".".freeze).first
95
99
  send(method, event)
96
100
  end
97
101