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,6 +1,6 @@
1
- require 'set'
2
- require 'pathname'
3
- require 'concurrent/atomic/atomic_boolean'
1
+ require "set"
2
+ require "pathname"
3
+ require "concurrent/atomic/atomic_boolean"
4
4
 
5
5
  module ActiveSupport
6
6
  # Allows you to "listen" to changes in a file system.
@@ -17,7 +17,7 @@ module ActiveSupport
17
17
  #
18
18
  # Example:
19
19
  #
20
- # checker = EventedFileUpdateChecker.new(["/tmp/foo"], -> { puts "changed" })
20
+ # checker = ActiveSupport::EventedFileUpdateChecker.new(["/tmp/foo"]) { puts "changed" }
21
21
  # checker.updated?
22
22
  # # => false
23
23
  # checker.execute_if_updated
@@ -32,6 +32,10 @@ module ActiveSupport
32
32
  #
33
33
  class EventedFileUpdateChecker #:nodoc: all
34
34
  def initialize(files, dirs = {}, &block)
35
+ unless block
36
+ raise ArgumentError, "A block is required to initialize an EventedFileUpdateChecker"
37
+ end
38
+
35
39
  @ph = PathHelper.new
36
40
  @files = files.map { |f| @ph.xpath(f) }.to_set
37
41
 
@@ -52,7 +56,7 @@ module ActiveSupport
52
56
  # to our test suite. Thus, we lazy load it and disable warnings locally.
53
57
  silence_warnings do
54
58
  begin
55
- require 'listen'
59
+ require "listen"
56
60
  rescue LoadError => e
57
61
  raise LoadError, "Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile", e.backtrace
58
62
  end
@@ -121,79 +125,74 @@ module ActiveSupport
121
125
  dtw.compact!
122
126
  dtw.uniq!
123
127
 
124
- normalized_gem_paths = Gem.path.map { |path| File.join path, "" }
125
- dtw = dtw.reject do |path|
126
- normalized_gem_paths.any? { |gem_path| path.to_s.start_with?(gem_path) }
127
- end
128
-
129
128
  @ph.filter_out_descendants(dtw)
130
129
  end
131
130
 
132
- class PathHelper
133
- def xpath(path)
134
- Pathname.new(path).expand_path
135
- end
131
+ class PathHelper
132
+ def xpath(path)
133
+ Pathname.new(path).expand_path
134
+ end
136
135
 
137
- def normalize_extension(ext)
138
- ext.to_s.sub(/\A\./, '')
139
- end
136
+ def normalize_extension(ext)
137
+ ext.to_s.sub(/\A\./, "")
138
+ end
140
139
 
141
- # Given a collection of Pathname objects returns the longest subpath
142
- # common to all of them, or +nil+ if there is none.
143
- def longest_common_subpath(paths)
144
- return if paths.empty?
145
-
146
- lcsp = Pathname.new(paths[0])
147
-
148
- paths[1..-1].each do |path|
149
- until ascendant_of?(lcsp, path)
150
- if lcsp.root?
151
- # If we get here a root directory is not an ascendant of path.
152
- # This may happen if there are paths in different drives on
153
- # Windows.
154
- return
155
- else
156
- lcsp = lcsp.parent
140
+ # Given a collection of Pathname objects returns the longest subpath
141
+ # common to all of them, or +nil+ if there is none.
142
+ def longest_common_subpath(paths)
143
+ return if paths.empty?
144
+
145
+ lcsp = Pathname.new(paths[0])
146
+
147
+ paths[1..-1].each do |path|
148
+ until ascendant_of?(lcsp, path)
149
+ if lcsp.root?
150
+ # If we get here a root directory is not an ascendant of path.
151
+ # This may happen if there are paths in different drives on
152
+ # Windows.
153
+ return
154
+ else
155
+ lcsp = lcsp.parent
156
+ end
157
157
  end
158
158
  end
159
- end
160
159
 
161
- lcsp
162
- end
160
+ lcsp
161
+ end
163
162
 
164
- # Returns the deepest existing ascendant, which could be the argument itself.
165
- def existing_parent(dir)
166
- dir.ascend do |ascendant|
167
- break ascendant if ascendant.directory?
163
+ # Returns the deepest existing ascendant, which could be the argument itself.
164
+ def existing_parent(dir)
165
+ dir.ascend do |ascendant|
166
+ break ascendant if ascendant.directory?
167
+ end
168
168
  end
169
- end
170
169
 
171
- # Filters out directories which are descendants of others in the collection (stable).
172
- def filter_out_descendants(dirs)
173
- return dirs if dirs.length < 2
170
+ # Filters out directories which are descendants of others in the collection (stable).
171
+ def filter_out_descendants(dirs)
172
+ return dirs if dirs.length < 2
174
173
 
175
- dirs_sorted_by_nparts = dirs.sort_by { |dir| dir.each_filename.to_a.length }
176
- descendants = []
174
+ dirs_sorted_by_nparts = dirs.sort_by { |dir| dir.each_filename.to_a.length }
175
+ descendants = []
177
176
 
178
- until dirs_sorted_by_nparts.empty?
179
- dir = dirs_sorted_by_nparts.shift
177
+ until dirs_sorted_by_nparts.empty?
178
+ dir = dirs_sorted_by_nparts.shift
180
179
 
181
- dirs_sorted_by_nparts.reject! do |possible_descendant|
182
- ascendant_of?(dir, possible_descendant) && descendants << possible_descendant
180
+ dirs_sorted_by_nparts.reject! do |possible_descendant|
181
+ ascendant_of?(dir, possible_descendant) && descendants << possible_descendant
182
+ end
183
183
  end
184
- end
185
184
 
186
- # Array#- preserves order.
187
- dirs - descendants
188
- end
185
+ # Array#- preserves order.
186
+ dirs - descendants
187
+ end
189
188
 
190
- private
189
+ private
191
190
 
192
- def ascendant_of?(base, other)
193
- base != other && other.ascend do |ascendant|
194
- break true if base == ascendant
191
+ def ascendant_of?(base, other)
192
+ base != other && other.ascend do |ascendant|
193
+ break true if base == ascendant
194
+ end
195
195
  end
196
- end
197
- end
196
+ end
198
197
  end
199
198
  end
@@ -1,4 +1,4 @@
1
- require 'active_support/callbacks'
1
+ require "active_support/callbacks"
2
2
 
3
3
  module ActiveSupport
4
4
  class ExecutionWrapper
@@ -19,14 +19,14 @@ module ActiveSupport
19
19
  set_callback(:complete, *args, &block)
20
20
  end
21
21
 
22
- class RunHook < Struct.new(:hook) # :nodoc:
22
+ RunHook = Struct.new(:hook) do # :nodoc:
23
23
  def before(target)
24
24
  hook_state = target.send(:hook_state)
25
25
  hook_state[hook] = hook.run
26
26
  end
27
27
  end
28
28
 
29
- class CompleteHook < Struct.new(:hook) # :nodoc:
29
+ CompleteHook = Struct.new(:hook) do # :nodoc:
30
30
  def before(target)
31
31
  hook_state = target.send(:hook_state)
32
32
  if hook_state.key?(hook)
@@ -1,4 +1,4 @@
1
- require 'active_support/execution_wrapper'
1
+ require "active_support/execution_wrapper"
2
2
 
3
3
  module ActiveSupport
4
4
  class Executor < ExecutionWrapper
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/time/calculations'
1
+ require "active_support/core_ext/time/calculations"
2
2
 
3
3
  module ActiveSupport
4
4
  # FileUpdateChecker specifies the API used by Rails to watch files
@@ -38,6 +38,10 @@ module ActiveSupport
38
38
  # changes. The array of files and list of directories cannot be changed
39
39
  # after FileUpdateChecker has been initialized.
40
40
  def initialize(files, dirs = {}, &block)
41
+ unless block
42
+ raise ArgumentError, "A block is required to initialize a FileUpdateChecker"
43
+ end
44
+
41
45
  @files = files.freeze
42
46
  @glob = compile_glob(dirs)
43
47
  @block = block
@@ -93,65 +97,65 @@ module ActiveSupport
93
97
 
94
98
  private
95
99
 
96
- def watched
97
- @watched || begin
98
- all = @files.select { |f| File.exist?(f) }
99
- all.concat(Dir[@glob]) if @glob
100
- all
100
+ def watched
101
+ @watched || begin
102
+ all = @files.select { |f| File.exist?(f) }
103
+ all.concat(Dir[@glob]) if @glob
104
+ all
105
+ end
101
106
  end
102
- end
103
107
 
104
- def updated_at(paths)
105
- @updated_at || max_mtime(paths) || Time.at(0)
106
- end
108
+ def updated_at(paths)
109
+ @updated_at || max_mtime(paths) || Time.at(0)
110
+ end
107
111
 
108
- # This method returns the maximum mtime of the files in +paths+, or +nil+
109
- # if the array is empty.
110
- #
111
- # Files with a mtime in the future are ignored. Such abnormal situation
112
- # can happen for example if the user changes the clock by hand. It is
113
- # healthy to consider this edge case because with mtimes in the future
114
- # reloading is not triggered.
115
- def max_mtime(paths)
116
- time_now = Time.now
117
- max_mtime = nil
118
-
119
- # Time comparisons are performed with #compare_without_coercion because
120
- # AS redefines these operators in a way that is much slower and does not
121
- # bring any benefit in this particular code.
112
+ # This method returns the maximum mtime of the files in +paths+, or +nil+
113
+ # if the array is empty.
122
114
  #
123
- # Read t1.compare_without_coercion(t2) < 0 as t1 < t2.
124
- paths.each do |path|
125
- mtime = File.mtime(path)
126
-
127
- next if time_now.compare_without_coercion(mtime) < 0
128
-
129
- if max_mtime.nil? || max_mtime.compare_without_coercion(mtime) < 0
130
- max_mtime = mtime
115
+ # Files with a mtime in the future are ignored. Such abnormal situation
116
+ # can happen for example if the user changes the clock by hand. It is
117
+ # healthy to consider this edge case because with mtimes in the future
118
+ # reloading is not triggered.
119
+ def max_mtime(paths)
120
+ time_now = Time.now
121
+ max_mtime = nil
122
+
123
+ # Time comparisons are performed with #compare_without_coercion because
124
+ # AS redefines these operators in a way that is much slower and does not
125
+ # bring any benefit in this particular code.
126
+ #
127
+ # Read t1.compare_without_coercion(t2) < 0 as t1 < t2.
128
+ paths.each do |path|
129
+ mtime = File.mtime(path)
130
+
131
+ next if time_now.compare_without_coercion(mtime) < 0
132
+
133
+ if max_mtime.nil? || max_mtime.compare_without_coercion(mtime) < 0
134
+ max_mtime = mtime
135
+ end
131
136
  end
132
- end
133
137
 
134
- max_mtime
135
- end
138
+ max_mtime
139
+ end
136
140
 
137
- def compile_glob(hash)
138
- hash.freeze # Freeze so changes aren't accidentally pushed
139
- return if hash.empty?
141
+ def compile_glob(hash)
142
+ hash.freeze # Freeze so changes aren't accidentally pushed
143
+ return if hash.empty?
140
144
 
141
- globs = hash.map do |key, value|
142
- "#{escape(key)}/**/*#{compile_ext(value)}"
145
+ globs = hash.map do |key, value|
146
+ "#{escape(key)}/**/*#{compile_ext(value)}"
147
+ end
148
+ "{#{globs.join(",")}}"
143
149
  end
144
- "{#{globs.join(",")}}"
145
- end
146
150
 
147
- def escape(key)
148
- key.gsub(',','\,')
149
- end
151
+ def escape(key)
152
+ key.gsub(",", '\,')
153
+ end
150
154
 
151
- def compile_ext(array)
152
- array = Array(array)
153
- return if array.empty?
154
- ".{#{array.join(",")}}"
155
- end
155
+ def compile_ext(array)
156
+ array = Array(array)
157
+ return if array.empty?
158
+ ".{#{array.join(",")}}"
159
+ end
156
160
  end
157
161
  end
@@ -6,9 +6,9 @@ module ActiveSupport
6
6
 
7
7
  module VERSION
8
8
  MAJOR = 5
9
- MINOR = 0
10
- TINY = 7
11
- PRE = "2"
9
+ MINOR = 1
10
+ TINY = 0
11
+ PRE = "beta1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -1,5 +1,5 @@
1
- require 'zlib'
2
- require 'stringio'
1
+ require "zlib"
2
+ require "stringio"
3
3
 
4
4
  module ActiveSupport
5
5
  # A convenient wrapper for the zlib standard library that allows
@@ -9,7 +9,7 @@ module ActiveSupport
9
9
  # # => "\x1F\x8B\b\x00o\x8D\xCDO\x00\x03K\xCE\xCF-(J-.V\xC8MU\x04\x00R>n\x83\f\x00\x00\x00"
10
10
  #
11
11
  # ActiveSupport::Gzip.decompress(gzip)
12
- # # => "compress me!"
12
+ # # => "compress me!"
13
13
  module Gzip
14
14
  class Stream < StringIO
15
15
  def initialize(*)
@@ -21,11 +21,11 @@ module ActiveSupport
21
21
 
22
22
  # Decompresses a gzipped string.
23
23
  def self.decompress(source)
24
- Zlib::GzipReader.wrap(StringIO.new(source), &:read)
24
+ Zlib::GzipReader.new(StringIO.new(source)).read
25
25
  end
26
26
 
27
27
  # Compresses a string using gzip.
28
- def self.compress(source, level=Zlib::DEFAULT_COMPRESSION, strategy=Zlib::DEFAULT_STRATEGY)
28
+ def self.compress(source, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY)
29
29
  output = Stream.new
30
30
  gz = Zlib::GzipWriter.new(output, level, strategy)
31
31
  gz.write(source)
@@ -1,5 +1,5 @@
1
- require 'active_support/core_ext/hash/keys'
2
- require 'active_support/core_ext/hash/reverse_merge'
1
+ require "active_support/core_ext/hash/keys"
2
+ require "active_support/core_ext/hash/reverse_merge"
3
3
 
4
4
  module ActiveSupport
5
5
  # Implements a hash where keys <tt>:foo</tt> and <tt>"foo"</tt> are considered
@@ -84,15 +84,6 @@ module ActiveSupport
84
84
  end
85
85
  end
86
86
 
87
- def self.new_from_hash_copying_default(hash)
88
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
89
- `ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default`
90
- has been deprecated, and will be removed in Rails 5.1. The behavior of
91
- this method is now identical to the behavior of `.new`.
92
- MSG
93
- new(hash)
94
- end
95
-
96
87
  def self.[](*args)
97
88
  new.merge!(Hash[*args])
98
89
  end
@@ -167,7 +158,6 @@ module ActiveSupport
167
158
  alias_method :has_key?, :key?
168
159
  alias_method :member?, :key?
169
160
 
170
-
171
161
  # Same as <tt>Hash#[]</tt> where the key passed as argument can be
172
162
  # either a string or a symbol:
173
163
  #
@@ -211,7 +201,7 @@ module ActiveSupport
211
201
  # dup = hash.dup
212
202
  # dup[:a][:c] = 'c'
213
203
  #
214
- # hash[:a][:c] # => "c"
204
+ # hash[:a][:c] # => nil
215
205
  # dup[:a][:c] # => "c"
216
206
  def dup
217
207
  self.class.new(self).tap do |new_hash|
@@ -223,7 +213,7 @@ module ActiveSupport
223
213
  # modify the receiver but rather returns a new hash with indifferent
224
214
  # access with the result of the merge.
225
215
  def merge(hash, &block)
226
- self.dup.update(hash, &block)
216
+ dup.update(hash, &block)
227
217
  end
228
218
 
229
219
  # Like +merge+ but the other way around: Merges the receiver into the
@@ -238,7 +228,7 @@ module ActiveSupport
238
228
 
239
229
  # Same semantics as +reverse_merge+ but modifies the receiver in-place.
240
230
  def reverse_merge!(other_hash)
241
- replace(reverse_merge( other_hash ))
231
+ replace(reverse_merge(other_hash))
242
232
  end
243
233
 
244
234
  # Replaces the contents of this hash with other_hash.
@@ -280,7 +270,7 @@ module ActiveSupport
280
270
  end
281
271
 
282
272
  def compact
283
- dup.tap(&:compact!)
273
+ dup.compact!
284
274
  end
285
275
 
286
276
  # Convert to a regular hash with string keys.
@@ -294,12 +284,12 @@ module ActiveSupport
294
284
  _new_hash
295
285
  end
296
286
 
297
- protected
298
- def convert_key(key)
287
+ private
288
+ def convert_key(key) # :doc:
299
289
  key.kind_of?(Symbol) ? key.to_s : key
300
290
  end
301
291
 
302
- def convert_value(value, options = {})
292
+ def convert_value(value, options = {}) # :doc:
303
293
  if value.is_a? Hash
304
294
  if options[:for] == :to_hash
305
295
  value.to_hash
@@ -316,7 +306,7 @@ module ActiveSupport
316
306
  end
317
307
  end
318
308
 
319
- def set_defaults(target)
309
+ def set_defaults(target) # :doc:
320
310
  if default_proc
321
311
  target.default_proc = default_proc.dup
322
312
  else