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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +215 -820
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/active_support.rb +8 -4
- data/lib/active_support/all.rb +3 -3
- data/lib/active_support/array_inquirer.rb +7 -5
- data/lib/active_support/backtrace_cleaner.rb +4 -4
- data/lib/active_support/benchmarkable.rb +3 -3
- data/lib/active_support/builder.rb +1 -1
- data/lib/active_support/cache.rb +42 -49
- data/lib/active_support/cache/file_store.rb +12 -21
- data/lib/active_support/cache/mem_cache_store.rb +30 -40
- data/lib/active_support/cache/memory_store.rb +11 -13
- data/lib/active_support/cache/null_store.rb +4 -4
- data/lib/active_support/cache/strategy/local_cache.rb +16 -25
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +8 -9
- data/lib/active_support/callbacks.rb +647 -584
- data/lib/active_support/concurrency/share_lock.rb +20 -21
- data/lib/active_support/configurable.rb +5 -5
- data/lib/active_support/core_ext.rb +1 -2
- data/lib/active_support/core_ext/array.rb +7 -7
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +15 -15
- data/lib/active_support/core_ext/array/grouping.rb +1 -1
- data/lib/active_support/core_ext/array/inquiry.rb +1 -1
- data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
- data/lib/active_support/core_ext/benchmark.rb +1 -1
- data/lib/active_support/core_ext/big_decimal.rb +1 -1
- data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
- data/lib/active_support/core_ext/class.rb +2 -2
- data/lib/active_support/core_ext/class/attribute.rb +5 -5
- data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
- data/lib/active_support/core_ext/class/subclasses.rb +18 -4
- data/lib/active_support/core_ext/date.rb +5 -5
- data/lib/active_support/core_ext/date/acts_like.rb +1 -1
- data/lib/active_support/core_ext/date/blank.rb +1 -1
- data/lib/active_support/core_ext/date/calculations.rb +8 -8
- data/lib/active_support/core_ext/date/conversions.rb +12 -12
- data/lib/active_support/core_ext/date/zones.rb +2 -2
- data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +9 -1
- data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
- data/lib/active_support/core_ext/date_time.rb +5 -5
- data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
- data/lib/active_support/core_ext/date_time/blank.rb +1 -1
- data/lib/active_support/core_ext/date_time/calculations.rb +9 -9
- data/lib/active_support/core_ext/date_time/compatibility.rb +2 -13
- data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
- data/lib/active_support/core_ext/digest/uuid.rb +4 -4
- data/lib/active_support/core_ext/enumerable.rb +46 -57
- data/lib/active_support/core_ext/file.rb +1 -1
- data/lib/active_support/core_ext/file/atomic.rb +4 -4
- data/lib/active_support/core_ext/hash.rb +9 -9
- data/lib/active_support/core_ext/hash/compact.rb +12 -9
- data/lib/active_support/core_ext/hash/conversions.rb +36 -37
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
- data/lib/active_support/core_ext/hash/keys.rb +8 -8
- data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
- data/lib/active_support/core_ext/hash/slice.rb +4 -4
- data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
- data/lib/active_support/core_ext/integer.rb +3 -3
- data/lib/active_support/core_ext/integer/inflections.rb +1 -1
- data/lib/active_support/core_ext/integer/time.rb +2 -2
- data/lib/active_support/core_ext/kernel.rb +4 -4
- data/lib/active_support/core_ext/kernel/concern.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
- data/lib/active_support/core_ext/load_error.rb +1 -18
- data/lib/active_support/core_ext/marshal.rb +2 -2
- data/lib/active_support/core_ext/module.rb +11 -12
- data/lib/active_support/core_ext/module/aliasing.rb +3 -48
- data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
- data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -5
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +20 -13
- data/lib/active_support/core_ext/module/concerning.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +82 -16
- data/lib/active_support/core_ext/module/introspection.rb +3 -11
- data/lib/active_support/core_ext/module/reachable.rb +2 -2
- data/lib/active_support/core_ext/numeric.rb +4 -4
- data/lib/active_support/core_ext/numeric/conversions.rb +3 -9
- data/lib/active_support/core_ext/numeric/inquiry.rb +21 -21
- data/lib/active_support/core_ext/numeric/time.rb +5 -5
- data/lib/active_support/core_ext/object.rb +12 -12
- data/lib/active_support/core_ext/object/blank.rb +3 -1
- data/lib/active_support/core_ext/object/conversions.rb +4 -4
- data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
- data/lib/active_support/core_ext/object/duplicable.rb +24 -4
- data/lib/active_support/core_ext/object/inclusion.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +26 -12
- data/lib/active_support/core_ext/object/to_param.rb +1 -1
- data/lib/active_support/core_ext/object/to_query.rb +4 -4
- data/lib/active_support/core_ext/object/try.rb +1 -1
- data/lib/active_support/core_ext/object/with_options.rb +1 -1
- data/lib/active_support/core_ext/range.rb +4 -4
- data/lib/active_support/core_ext/range/conversions.rb +1 -1
- data/lib/active_support/core_ext/regexp.rb +4 -0
- data/lib/active_support/core_ext/securerandom.rb +3 -3
- data/lib/active_support/core_ext/string.rb +13 -13
- data/lib/active_support/core_ext/string/access.rb +6 -6
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/filters.rb +3 -3
- data/lib/active_support/core_ext/string/indent.rb +4 -4
- data/lib/active_support/core_ext/string/inflections.rb +10 -14
- data/lib/active_support/core_ext/string/inquiry.rb +1 -1
- data/lib/active_support/core_ext/string/multibyte.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +19 -20
- data/lib/active_support/core_ext/string/strip.rb +1 -1
- data/lib/active_support/core_ext/string/zones.rb +2 -2
- data/lib/active_support/core_ext/time.rb +5 -5
- data/lib/active_support/core_ext/time/acts_like.rb +1 -1
- data/lib/active_support/core_ext/time/calculations.rb +23 -29
- data/lib/active_support/core_ext/time/compatibility.rb +1 -10
- data/lib/active_support/core_ext/time/conversions.rb +12 -12
- data/lib/active_support/core_ext/time/zones.rb +3 -3
- data/lib/active_support/core_ext/uri.rb +2 -2
- data/lib/active_support/dependencies.rb +45 -47
- data/lib/active_support/dependencies/interlock.rb +1 -1
- data/lib/active_support/deprecation.rb +8 -8
- data/lib/active_support/deprecation/behaviors.rb +3 -3
- data/lib/active_support/deprecation/instance_delegator.rb +2 -2
- data/lib/active_support/deprecation/method_wrappers.rb +3 -3
- data/lib/active_support/deprecation/proxy_wrappers.rb +6 -4
- data/lib/active_support/deprecation/reporting.rb +7 -7
- data/lib/active_support/duration.rb +30 -26
- data/lib/active_support/duration/iso8601_parser.rb +66 -65
- data/lib/active_support/duration/iso8601_serializer.rb +11 -9
- data/lib/active_support/evented_file_update_checker.rb +59 -60
- data/lib/active_support/execution_wrapper.rb +3 -3
- data/lib/active_support/executor.rb +1 -1
- data/lib/active_support/file_update_checker.rb +54 -50
- data/lib/active_support/gem_version.rb +3 -3
- data/lib/active_support/gzip.rb +5 -5
- data/lib/active_support/hash_with_indifferent_access.rb +10 -20
- data/lib/active_support/i18n.rb +5 -5
- data/lib/active_support/i18n_railtie.rb +11 -10
- data/lib/active_support/inflections.rb +11 -11
- data/lib/active_support/inflector.rb +5 -5
- data/lib/active_support/inflector/inflections.rb +11 -9
- data/lib/active_support/inflector/methods.rb +51 -50
- data/lib/active_support/inflector/transliterate.rb +8 -11
- data/lib/active_support/json.rb +2 -2
- data/lib/active_support/json/decoding.rb +3 -3
- data/lib/active_support/json/encoding.rb +8 -7
- data/lib/active_support/key_generator.rb +17 -17
- data/lib/active_support/lazy_load_hooks.rb +12 -30
- data/lib/active_support/log_subscriber.rb +5 -5
- data/lib/active_support/log_subscriber/test_helper.rb +9 -9
- data/lib/active_support/logger.rb +3 -3
- data/lib/active_support/logger_silence.rb +3 -3
- data/lib/active_support/logger_thread_safe_level.rb +1 -1
- data/lib/active_support/message_encryptor.rb +72 -35
- data/lib/active_support/message_verifier.rb +7 -7
- data/lib/active_support/multibyte.rb +2 -2
- data/lib/active_support/multibyte/chars.rb +23 -21
- data/lib/active_support/multibyte/unicode.rb +68 -89
- data/lib/active_support/notifications.rb +5 -5
- data/lib/active_support/notifications/fanout.rb +3 -3
- data/lib/active_support/notifications/instrumenter.rb +5 -5
- data/lib/active_support/number_helper.rb +4 -4
- data/lib/active_support/number_helper/number_converter.rb +11 -11
- data/lib/active_support/number_helper/number_to_currency_converter.rb +3 -3
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -2
- data/lib/active_support/number_helper/number_to_human_converter.rb +6 -6
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -11
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -3
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +6 -6
- data/lib/active_support/option_merger.rb +1 -1
- data/lib/active_support/ordered_hash.rb +3 -3
- data/lib/active_support/ordered_options.rb +6 -4
- data/lib/active_support/per_thread_registry.rb +5 -5
- data/lib/active_support/rails.rb +12 -6
- data/lib/active_support/railtie.rb +3 -3
- data/lib/active_support/reloader.rb +1 -1
- data/lib/active_support/rescuable.rb +8 -14
- data/lib/active_support/security_utils.rb +1 -1
- data/lib/active_support/string_inquirer.rb +8 -2
- data/lib/active_support/subscriber.rb +9 -5
- data/lib/active_support/tagged_logging.rb +4 -4
- data/lib/active_support/test_case.rb +12 -29
- data/lib/active_support/testing/assertions.rb +100 -2
- data/lib/active_support/testing/autorun.rb +6 -2
- data/lib/active_support/testing/constant_lookup.rb +0 -1
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/deprecation.rb +3 -2
- data/lib/active_support/testing/isolation.rb +13 -22
- data/lib/active_support/testing/method_call_assertions.rb +1 -1
- data/lib/active_support/testing/setup_and_teardown.rb +2 -2
- data/lib/active_support/testing/stream.rb +28 -28
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +45 -12
- data/lib/active_support/time.rb +12 -12
- data/lib/active_support/time_with_zone.rb +16 -26
- data/lib/active_support/values/time_zone.rb +40 -46
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini.rb +34 -36
- data/lib/active_support/xml_mini/jdom.rb +112 -112
- data/lib/active_support/xml_mini/libxml.rb +15 -12
- data/lib/active_support/xml_mini/libxmlsax.rb +17 -15
- data/lib/active_support/xml_mini/nokogiri.rb +13 -11
- data/lib/active_support/xml_mini/nokogirisax.rb +15 -14
- data/lib/active_support/xml_mini/rexml.rb +9 -9
- metadata +8 -19
- data/lib/active_support/concurrency/latch.rb +0 -26
- data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
- data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
- data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
- data/lib/active_support/core_ext/struct.rb +0 -3
- data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
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"]
|
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
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
class PathHelper
|
132
|
+
def xpath(path)
|
133
|
+
Pathname.new(path).expand_path
|
134
|
+
end
|
136
135
|
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
def normalize_extension(ext)
|
137
|
+
ext.to_s.sub(/\A\./, "")
|
138
|
+
end
|
140
139
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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
|
-
|
162
|
-
|
160
|
+
lcsp
|
161
|
+
end
|
163
162
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
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
|
-
|
172
|
-
|
173
|
-
|
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
|
-
|
176
|
-
|
174
|
+
dirs_sorted_by_nparts = dirs.sort_by { |dir| dir.each_filename.to_a.length }
|
175
|
+
descendants = []
|
177
176
|
|
178
|
-
|
179
|
-
|
177
|
+
until dirs_sorted_by_nparts.empty?
|
178
|
+
dir = dirs_sorted_by_nparts.shift
|
180
179
|
|
181
|
-
|
182
|
-
|
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
|
-
|
187
|
-
|
188
|
-
|
185
|
+
# Array#- preserves order.
|
186
|
+
dirs - descendants
|
187
|
+
end
|
189
188
|
|
190
|
-
|
189
|
+
private
|
191
190
|
|
192
|
-
|
193
|
-
|
194
|
-
|
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
|
-
|
197
|
-
end
|
196
|
+
end
|
198
197
|
end
|
199
198
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
108
|
+
def updated_at(paths)
|
109
|
+
@updated_at || max_mtime(paths) || Time.at(0)
|
110
|
+
end
|
107
111
|
|
108
|
-
|
109
|
-
|
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
|
-
#
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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
|
-
|
135
|
-
|
138
|
+
max_mtime
|
139
|
+
end
|
136
140
|
|
137
|
-
|
138
|
-
|
139
|
-
|
141
|
+
def compile_glob(hash)
|
142
|
+
hash.freeze # Freeze so changes aren't accidentally pushed
|
143
|
+
return if hash.empty?
|
140
144
|
|
141
|
-
|
142
|
-
|
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
|
-
|
148
|
-
|
149
|
-
|
151
|
+
def escape(key)
|
152
|
+
key.gsub(",", '\,')
|
153
|
+
end
|
150
154
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
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
|
data/lib/active_support/gzip.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
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.
|
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
|
2
|
-
require
|
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] # =>
|
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
|
-
|
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(
|
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.
|
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
|
-
|
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
|