activesupport 5.0.7.2 → 5.1.7

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 (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +464 -694
  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 +41 -48
  12. data/lib/active_support/cache/file_store.rb +11 -20
  13. data/lib/active_support/cache/mem_cache_store.rb +30 -40
  14. data/lib/active_support/cache/memory_store.rb +13 -13
  15. data/lib/active_support/cache/null_store.rb +4 -4
  16. data/lib/active_support/cache/strategy/local_cache.rb +13 -22
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +4 -5
  18. data/lib/active_support/callbacks.rb +649 -584
  19. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +17 -0
  20. data/lib/active_support/concurrency/share_lock.rb +20 -21
  21. data/lib/active_support/configurable.rb +5 -5
  22. data/lib/active_support/core_ext.rb +1 -2
  23. data/lib/active_support/core_ext/array.rb +7 -7
  24. data/lib/active_support/core_ext/array/access.rb +1 -1
  25. data/lib/active_support/core_ext/array/conversions.rb +15 -15
  26. data/lib/active_support/core_ext/array/grouping.rb +1 -1
  27. data/lib/active_support/core_ext/array/inquiry.rb +1 -1
  28. data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
  29. data/lib/active_support/core_ext/benchmark.rb +1 -1
  30. data/lib/active_support/core_ext/big_decimal.rb +1 -1
  31. data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
  32. data/lib/active_support/core_ext/class.rb +2 -2
  33. data/lib/active_support/core_ext/class/attribute.rb +5 -5
  34. data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
  35. data/lib/active_support/core_ext/class/subclasses.rb +18 -4
  36. data/lib/active_support/core_ext/date.rb +5 -5
  37. data/lib/active_support/core_ext/date/acts_like.rb +1 -1
  38. data/lib/active_support/core_ext/date/blank.rb +1 -1
  39. data/lib/active_support/core_ext/date/calculations.rb +8 -8
  40. data/lib/active_support/core_ext/date/conversions.rb +12 -12
  41. data/lib/active_support/core_ext/date/zones.rb +2 -2
  42. data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
  43. data/lib/active_support/core_ext/date_and_time/compatibility.rb +1 -1
  44. data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
  45. data/lib/active_support/core_ext/date_time.rb +5 -5
  46. data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
  47. data/lib/active_support/core_ext/date_time/blank.rb +1 -1
  48. data/lib/active_support/core_ext/date_time/calculations.rb +20 -10
  49. data/lib/active_support/core_ext/date_time/compatibility.rb +2 -2
  50. data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
  51. data/lib/active_support/core_ext/digest/uuid.rb +4 -4
  52. data/lib/active_support/core_ext/enumerable.rb +23 -12
  53. data/lib/active_support/core_ext/file.rb +1 -1
  54. data/lib/active_support/core_ext/file/atomic.rb +4 -4
  55. data/lib/active_support/core_ext/hash.rb +9 -9
  56. data/lib/active_support/core_ext/hash/compact.rb +12 -9
  57. data/lib/active_support/core_ext/hash/conversions.rb +36 -37
  58. data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
  59. data/lib/active_support/core_ext/hash/keys.rb +6 -6
  60. data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
  61. data/lib/active_support/core_ext/hash/slice.rb +4 -4
  62. data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
  63. data/lib/active_support/core_ext/integer.rb +3 -3
  64. data/lib/active_support/core_ext/integer/inflections.rb +1 -1
  65. data/lib/active_support/core_ext/integer/time.rb +2 -2
  66. data/lib/active_support/core_ext/kernel.rb +4 -4
  67. data/lib/active_support/core_ext/kernel/concern.rb +1 -1
  68. data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
  69. data/lib/active_support/core_ext/load_error.rb +1 -18
  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 +85 -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 +34 -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 +8 -5
  92. data/lib/active_support/core_ext/object/try.rb +1 -1
  93. data/lib/active_support/core_ext/object/with_options.rb +12 -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 +46 -29
  112. data/lib/active_support/core_ext/time/conversions.rb +15 -12
  113. data/lib/active_support/core_ext/time/zones.rb +3 -3
  114. data/lib/active_support/core_ext/uri.rb +2 -2
  115. data/lib/active_support/dependencies.rb +45 -46
  116. data/lib/active_support/dependencies/interlock.rb +1 -1
  117. data/lib/active_support/deprecation.rb +9 -8
  118. data/lib/active_support/deprecation/behaviors.rb +3 -3
  119. data/lib/active_support/deprecation/constant_accessor.rb +50 -0
  120. data/lib/active_support/deprecation/instance_delegator.rb +2 -2
  121. data/lib/active_support/deprecation/method_wrappers.rb +10 -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 +221 -28
  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 -55
  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 +2 -2
  132. data/lib/active_support/gzip.rb +4 -4
  133. data/lib/active_support/hash_with_indifferent_access.rb +40 -28
  134. data/lib/active_support/i18n.rb +5 -5
  135. data/lib/active_support/i18n_railtie.rb +14 -9
  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 +52 -51
  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 +2 -2
  146. data/lib/active_support/log_subscriber.rb +9 -7
  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 +77 -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 +7 -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 +5 -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 +8 -10
  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 +12 -32
  168. data/lib/active_support/number_helper/rounding_helper.rb +64 -0
  169. data/lib/active_support/option_merger.rb +1 -1
  170. data/lib/active_support/ordered_hash.rb +3 -3
  171. data/lib/active_support/ordered_options.rb +6 -4
  172. data/lib/active_support/per_thread_registry.rb +5 -5
  173. data/lib/active_support/rails.rb +12 -6
  174. data/lib/active_support/railtie.rb +3 -3
  175. data/lib/active_support/reloader.rb +1 -1
  176. data/lib/active_support/rescuable.rb +6 -6
  177. data/lib/active_support/security_utils.rb +1 -1
  178. data/lib/active_support/string_inquirer.rb +8 -2
  179. data/lib/active_support/subscriber.rb +9 -5
  180. data/lib/active_support/tagged_logging.rb +4 -4
  181. data/lib/active_support/test_case.rb +12 -29
  182. data/lib/active_support/testing/assertions.rb +100 -2
  183. data/lib/active_support/testing/autorun.rb +2 -2
  184. data/lib/active_support/testing/constant_lookup.rb +0 -1
  185. data/lib/active_support/testing/declarative.rb +1 -1
  186. data/lib/active_support/testing/deprecation.rb +3 -2
  187. data/lib/active_support/testing/isolation.rb +15 -22
  188. data/lib/active_support/testing/method_call_assertions.rb +1 -1
  189. data/lib/active_support/testing/setup_and_teardown.rb +2 -2
  190. data/lib/active_support/testing/stream.rb +28 -28
  191. data/lib/active_support/testing/tagged_logging.rb +1 -1
  192. data/lib/active_support/testing/time_helpers.rb +45 -11
  193. data/lib/active_support/time.rb +12 -12
  194. data/lib/active_support/time_with_zone.rb +16 -14
  195. data/lib/active_support/values/time_zone.rb +100 -31
  196. data/lib/active_support/values/unicode_tables.dat +0 -0
  197. data/lib/active_support/version.rb +1 -1
  198. data/lib/active_support/xml_mini.rb +34 -36
  199. data/lib/active_support/xml_mini/jdom.rb +112 -112
  200. data/lib/active_support/xml_mini/libxml.rb +12 -11
  201. data/lib/active_support/xml_mini/libxmlsax.rb +13 -14
  202. data/lib/active_support/xml_mini/nokogiri.rb +10 -10
  203. data/lib/active_support/xml_mini/nokogirisax.rb +12 -13
  204. data/lib/active_support/xml_mini/rexml.rb +9 -9
  205. metadata +8 -9
  206. data/lib/active_support/concurrency/latch.rb +0 -26
  207. data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
  208. data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
  209. data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
  210. data/lib/active_support/core_ext/struct.rb +0 -3
  211. data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "monitor"
4
+
5
+ module ActiveSupport
6
+ module Concurrency
7
+ # A monitor that will permit dependency loading while blocked waiting for
8
+ # the lock.
9
+ class LoadInterlockAwareMonitor < Monitor
10
+ # Enters an exclusive section, but allows dependency loading while blocked
11
+ def mon_enter
12
+ mon_try_enter ||
13
+ ActiveSupport::Dependencies.interlock.permit_concurrent_loads { super }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
- require 'thread'
2
- require 'monitor'
1
+ require "thread"
2
+ require "monitor"
3
3
 
4
4
  module ActiveSupport
5
5
  module Concurrency
@@ -13,7 +13,6 @@ module ActiveSupport
13
13
  # we need exclusive locks to be reentrant, and we need to be able
14
14
  # to upgrade share locks to exclusive.
15
15
 
16
-
17
16
  def raw_state # :nodoc:
18
17
  synchronize do
19
18
  threads = @sleeping.keys | @sharing.keys | @waiting.keys
@@ -200,27 +199,27 @@ module ActiveSupport
200
199
 
201
200
  private
202
201
 
203
- # Must be called within synchronize
204
- def busy_for_exclusive?(purpose)
205
- busy_for_sharing?(purpose) ||
206
- @sharing.size > (@sharing[Thread.current] > 0 ? 1 : 0)
207
- end
202
+ # Must be called within synchronize
203
+ def busy_for_exclusive?(purpose)
204
+ busy_for_sharing?(purpose) ||
205
+ @sharing.size > (@sharing[Thread.current] > 0 ? 1 : 0)
206
+ end
208
207
 
209
- def busy_for_sharing?(purpose)
210
- (@exclusive_thread && @exclusive_thread != Thread.current) ||
211
- @waiting.any? { |t, (_, c)| t != Thread.current && !c.include?(purpose) }
212
- end
208
+ def busy_for_sharing?(purpose)
209
+ (@exclusive_thread && @exclusive_thread != Thread.current) ||
210
+ @waiting.any? { |t, (_, c)| t != Thread.current && !c.include?(purpose) }
211
+ end
213
212
 
214
- def eligible_waiters?(compatible)
215
- @waiting.any? { |t, (p, _)| compatible.include?(p) && @waiting.all? { |t2, (_, c2)| t == t2 || c2.include?(p) } }
216
- end
213
+ def eligible_waiters?(compatible)
214
+ @waiting.any? { |t, (p, _)| compatible.include?(p) && @waiting.all? { |t2, (_, c2)| t == t2 || c2.include?(p) } }
215
+ end
217
216
 
218
- def wait_for(method)
219
- @sleeping[Thread.current] = method
220
- @cv.wait_while { yield }
221
- ensure
222
- @sleeping.delete Thread.current
223
- end
217
+ def wait_for(method)
218
+ @sleeping[Thread.current] = method
219
+ @cv.wait_while { yield }
220
+ ensure
221
+ @sleeping.delete Thread.current
222
+ end
224
223
  end
225
224
  end
226
225
  end
@@ -1,6 +1,7 @@
1
- require 'active_support/concern'
2
- require 'active_support/ordered_options'
3
- require 'active_support/core_ext/array/extract_options'
1
+ require "active_support/concern"
2
+ require "active_support/ordered_options"
3
+ require "active_support/core_ext/array/extract_options"
4
+ require "active_support/core_ext/regexp"
4
5
 
5
6
  module ActiveSupport
6
7
  # Configurable provides a <tt>config</tt> method to store and retrieve
@@ -107,7 +108,7 @@ module ActiveSupport
107
108
  options = names.extract_options!
108
109
 
109
110
  names.each do |name|
110
- raise NameError.new('invalid config attribute name') unless name =~ /\A[_A-Za-z]\w*\z/
111
+ raise NameError.new("invalid config attribute name") unless /\A[_A-Za-z]\w*\z/.match?(name)
111
112
 
112
113
  reader, reader_line = "def #{name}; config.#{name}; end", __LINE__
113
114
  writer, writer_line = "def #{name}=(value); config.#{name} = value; end", __LINE__
@@ -145,4 +146,3 @@ module ActiveSupport
145
146
  end
146
147
  end
147
148
  end
148
-
@@ -1,4 +1,3 @@
1
- DEPRECATED_FILES = ["#{File.dirname(__FILE__)}/core_ext/struct.rb"]
2
- (Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"] - DEPRECATED_FILES).each do |path|
1
+ (Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"]).each do |path|
3
2
  require path
4
3
  end
@@ -1,7 +1,7 @@
1
- require 'active_support/core_ext/array/wrap'
2
- require 'active_support/core_ext/array/access'
3
- require 'active_support/core_ext/array/conversions'
4
- require 'active_support/core_ext/array/extract_options'
5
- require 'active_support/core_ext/array/grouping'
6
- require 'active_support/core_ext/array/prepend_and_append'
7
- require 'active_support/core_ext/array/inquiry'
1
+ require "active_support/core_ext/array/wrap"
2
+ require "active_support/core_ext/array/access"
3
+ require "active_support/core_ext/array/conversions"
4
+ require "active_support/core_ext/array/extract_options"
5
+ require "active_support/core_ext/array/grouping"
6
+ require "active_support/core_ext/array/prepend_and_append"
7
+ require "active_support/core_ext/array/inquiry"
@@ -31,7 +31,7 @@ class Array
31
31
  #
32
32
  # people = ["David", "Rafael", "Aaron", "Todd"]
33
33
  # people.without "Aaron", "Todd"
34
- # => ["David", "Rafael"]
34
+ # # => ["David", "Rafael"]
35
35
  #
36
36
  # Note: This is an optimization of `Enumerable#without` that uses `Array#-`
37
37
  # instead of `Array#reject` for performance reasons.
@@ -1,8 +1,8 @@
1
- require 'active_support/xml_mini'
2
- require 'active_support/core_ext/hash/keys'
3
- require 'active_support/core_ext/string/inflections'
4
- require 'active_support/core_ext/object/to_param'
5
- require 'active_support/core_ext/object/to_query'
1
+ require "active_support/xml_mini"
2
+ require "active_support/core_ext/hash/keys"
3
+ require "active_support/core_ext/string/inflections"
4
+ require "active_support/core_ext/object/to_param"
5
+ require "active_support/core_ext/object/to_query"
6
6
 
7
7
  class Array
8
8
  # Converts the array to a comma-separated sentence where the last element is
@@ -60,9 +60,9 @@ class Array
60
60
  options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
61
61
 
62
62
  default_connectors = {
63
- :words_connector => ', ',
64
- :two_words_connector => ' and ',
65
- :last_word_connector => ', and '
63
+ words_connector: ", ",
64
+ two_words_connector: " and ",
65
+ last_word_connector: ", and "
66
66
  }
67
67
  if defined?(I18n)
68
68
  i18n_connectors = I18n.translate(:'support.array', locale: options[:locale], default: {})
@@ -72,7 +72,7 @@ class Array
72
72
 
73
73
  case length
74
74
  when 0
75
- ''
75
+ ""
76
76
  when 1
77
77
  "#{self[0]}"
78
78
  when 2
@@ -92,9 +92,9 @@ class Array
92
92
  case format
93
93
  when :db
94
94
  if empty?
95
- 'null'
95
+ "null"
96
96
  else
97
- collect(&:id).join(',')
97
+ collect(&:id).join(",")
98
98
  end
99
99
  else
100
100
  to_default_s
@@ -179,7 +179,7 @@ class Array
179
179
  # </messages>
180
180
  #
181
181
  def to_xml(options = {})
182
- require 'active_support/builder' unless defined?(Builder)
182
+ require "active_support/builder" unless defined?(Builder)
183
183
 
184
184
  options = options.dup
185
185
  options[:indent] ||= 2
@@ -187,9 +187,9 @@ class Array
187
187
  options[:root] ||= \
188
188
  if first.class != Hash && all? { |e| e.is_a?(first.class) }
189
189
  underscored = ActiveSupport::Inflector.underscore(first.class.name)
190
- ActiveSupport::Inflector.pluralize(underscored).tr('/', '_')
190
+ ActiveSupport::Inflector.pluralize(underscored).tr("/", "_")
191
191
  else
192
- 'objects'
192
+ "objects"
193
193
  end
194
194
 
195
195
  builder = options[:builder]
@@ -197,7 +197,7 @@ class Array
197
197
 
198
198
  root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options)
199
199
  children = options.delete(:children) || root.singularize
200
- attributes = options[:skip_types] ? {} : { type: 'array' }
200
+ attributes = options[:skip_types] ? {} : { type: "array" }
201
201
 
202
202
  if empty?
203
203
  builder.tag!(root, attributes)
@@ -89,7 +89,7 @@ class Array
89
89
  # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]]
90
90
  # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]]
91
91
  def split(value = nil)
92
- arr = self.dup
92
+ arr = dup
93
93
  result = []
94
94
  if block_given?
95
95
  while (idx = arr.index { |i| yield i })
@@ -1,4 +1,4 @@
1
- require 'active_support/array_inquirer'
1
+ require "active_support/array_inquirer"
2
2
 
3
3
  class Array
4
4
  # Wraps the array in an +ArrayInquirer+ object, which gives a friendlier way
@@ -4,4 +4,4 @@ class Array
4
4
 
5
5
  # The human way of thinking about adding stuff to the beginning of a list is with prepend.
6
6
  alias_method :prepend, :unshift
7
- end
7
+ end
@@ -1,4 +1,4 @@
1
- require 'benchmark'
1
+ require "benchmark"
2
2
 
3
3
  class << Benchmark
4
4
  # Benchmark realtime in milliseconds.
@@ -1 +1 @@
1
- require 'active_support/core_ext/big_decimal/conversions'
1
+ require "active_support/core_ext/big_decimal/conversions"
@@ -1,12 +1,10 @@
1
- require 'bigdecimal'
2
- require 'bigdecimal/util'
1
+ require "bigdecimal"
2
+ require "bigdecimal/util"
3
3
 
4
4
  module ActiveSupport
5
5
  module BigDecimalWithDefaultFormat #:nodoc:
6
- DEFAULT_STRING_FORMAT = 'F'
7
-
8
- def to_s(format = nil)
9
- super(format || DEFAULT_STRING_FORMAT)
6
+ def to_s(format = "F")
7
+ super(format)
10
8
  end
11
9
  end
12
10
  end
@@ -1,2 +1,2 @@
1
- require 'active_support/core_ext/class/attribute'
2
- require 'active_support/core_ext/class/subclasses'
1
+ require "active_support/core_ext/class/attribute"
2
+ require "active_support/core_ext/class/subclasses"
@@ -1,6 +1,6 @@
1
- require 'active_support/core_ext/kernel/singleton_class'
2
- require 'active_support/core_ext/module/remove_method'
3
- require 'active_support/core_ext/array/extract_options'
1
+ require "active_support/core_ext/kernel/singleton_class"
2
+ require "active_support/core_ext/module/remove_method"
3
+ require "active_support/core_ext/array/extract_options"
4
4
 
5
5
  class Class
6
6
  # Declare a class-level attribute whose value is inheritable by subclasses.
@@ -20,14 +20,14 @@ class Class
20
20
  # Base.setting # => true
21
21
  #
22
22
  # In the above case as long as Subclass does not assign a value to setting
23
- # by performing <tt>Subclass.setting = _something_ </tt>, <tt>Subclass.setting</tt>
23
+ # by performing <tt>Subclass.setting = _something_</tt>, <tt>Subclass.setting</tt>
24
24
  # would read value assigned to parent class. Once Subclass assigns a value then
25
25
  # the value assigned by Subclass would be returned.
26
26
  #
27
27
  # This matches normal Ruby method inheritance: think of writing an attribute
28
28
  # on a subclass as overriding the reader method. However, you need to be aware
29
29
  # when using +class_attribute+ with mutable structures as +Array+ or +Hash+.
30
- # In such cases, you don't want to do changes in places but use setters:
30
+ # In such cases, you don't want to do changes in place. Instead use setters:
31
31
  #
32
32
  # Base.setting = []
33
33
  # Base.setting # => []
@@ -1,4 +1,4 @@
1
1
  # cattr_* became mattr_* aliases in 7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d,
2
2
  # but we keep this around for libraries that directly require it knowing they
3
3
  # want cattr_*. No need to deprecate.
4
- require 'active_support/core_ext/module/attribute_accessors'
4
+ require "active_support/core_ext/module/attribute_accessors"
@@ -1,20 +1,34 @@
1
- require 'active_support/core_ext/module/anonymous'
2
- require 'active_support/core_ext/module/reachable'
1
+ require "active_support/core_ext/module/anonymous"
2
+ require "active_support/core_ext/module/reachable"
3
3
 
4
4
  class Class
5
5
  begin
6
6
  # Test if this Ruby supports each_object against singleton_class
7
7
  ObjectSpace.each_object(Numeric.singleton_class) {}
8
8
 
9
- def descendants # :nodoc:
9
+ # Returns an array with all classes that are < than its receiver.
10
+ #
11
+ # class C; end
12
+ # C.descendants # => []
13
+ #
14
+ # class B < C; end
15
+ # C.descendants # => [B]
16
+ #
17
+ # class A < B; end
18
+ # C.descendants # => [B, A]
19
+ #
20
+ # class D < C; end
21
+ # C.descendants # => [B, A, D]
22
+ def descendants
10
23
  descendants = []
11
24
  ObjectSpace.each_object(singleton_class) do |k|
25
+ next if k.singleton_class?
12
26
  descendants.unshift k unless k == self
13
27
  end
14
28
  descendants
15
29
  end
16
30
  rescue StandardError # JRuby 9.0.4.0 and earlier
17
- def descendants # :nodoc:
31
+ def descendants
18
32
  descendants = []
19
33
  ObjectSpace.each_object(Class) do |k|
20
34
  descendants.unshift k if k < self
@@ -1,5 +1,5 @@
1
- require 'active_support/core_ext/date/acts_like'
2
- require 'active_support/core_ext/date/blank'
3
- require 'active_support/core_ext/date/calculations'
4
- require 'active_support/core_ext/date/conversions'
5
- require 'active_support/core_ext/date/zones'
1
+ require "active_support/core_ext/date/acts_like"
2
+ require "active_support/core_ext/date/blank"
3
+ require "active_support/core_ext/date/calculations"
4
+ require "active_support/core_ext/date/conversions"
5
+ require "active_support/core_ext/date/zones"
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/object/acts_like'
1
+ require "active_support/core_ext/object/acts_like"
2
2
 
3
3
  class Date
4
4
  # Duck-types as a Date-like class. See Object#acts_like?.
@@ -1,4 +1,4 @@
1
- require 'date'
1
+ require "date"
2
2
 
3
3
  class Date #:nodoc:
4
4
  # No Date is blank:
@@ -1,9 +1,9 @@
1
- require 'date'
2
- require 'active_support/duration'
3
- require 'active_support/core_ext/object/acts_like'
4
- require 'active_support/core_ext/date/zones'
5
- require 'active_support/core_ext/time/zones'
6
- require 'active_support/core_ext/date_and_time/calculations'
1
+ require "date"
2
+ require "active_support/duration"
3
+ require "active_support/core_ext/object/acts_like"
4
+ require "active_support/core_ext/date/zones"
5
+ require "active_support/core_ext/time/zones"
6
+ require "active_support/core_ext/date_and_time/calculations"
7
7
 
8
8
  class Date
9
9
  include DateAndTime::Calculations
@@ -129,11 +129,11 @@ class Date
129
129
  options.fetch(:day, day)
130
130
  )
131
131
  end
132
-
132
+
133
133
  # Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there.
134
134
  def compare_with_coercion(other)
135
135
  if other.is_a?(Time)
136
- self.to_datetime <=> other
136
+ to_datetime <=> other
137
137
  else
138
138
  compare_without_coercion(other)
139
139
  end
@@ -1,20 +1,20 @@
1
- require 'date'
2
- require 'active_support/inflector/methods'
3
- require 'active_support/core_ext/date/zones'
4
- require 'active_support/core_ext/module/remove_method'
1
+ require "date"
2
+ require "active_support/inflector/methods"
3
+ require "active_support/core_ext/date/zones"
4
+ require "active_support/core_ext/module/remove_method"
5
5
 
6
6
  class Date
7
7
  DATE_FORMATS = {
8
- :short => '%d %b',
9
- :long => '%B %d, %Y',
10
- :db => '%Y-%m-%d',
11
- :number => '%Y%m%d',
12
- :long_ordinal => lambda { |date|
8
+ short: "%d %b",
9
+ long: "%B %d, %Y",
10
+ db: "%Y-%m-%d",
11
+ number: "%Y%m%d",
12
+ long_ordinal: lambda { |date|
13
13
  day_format = ActiveSupport::Inflector.ordinalize(date.day)
14
14
  date.strftime("%B #{day_format}, %Y") # => "April 25th, 2007"
15
15
  },
16
- :rfc822 => '%d %b %Y',
17
- :iso8601 => lambda { |date| date.iso8601 }
16
+ rfc822: "%d %b %Y",
17
+ iso8601: lambda { |date| date.iso8601 }
18
18
  }
19
19
 
20
20
  # Ruby 1.9 has Date#to_time which converts to localtime only.
@@ -65,7 +65,7 @@ class Date
65
65
 
66
66
  # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005"
67
67
  def readable_inspect
68
- strftime('%a, %d %b %Y')
68
+ strftime("%a, %d %b %Y")
69
69
  end
70
70
  alias_method :default_inspect, :inspect
71
71
  alias_method :inspect, :readable_inspect