activesupport 5.1.7 → 5.2.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 +303 -617
- data/README.rdoc +1 -1
- data/lib/active_support.rb +3 -12
- data/lib/active_support/all.rb +2 -0
- data/lib/active_support/array_inquirer.rb +2 -0
- data/lib/active_support/backtrace_cleaner.rb +2 -0
- data/lib/active_support/benchmarkable.rb +2 -0
- data/lib/active_support/builder.rb +2 -0
- data/lib/active_support/cache.rb +127 -58
- data/lib/active_support/cache/file_store.rb +4 -3
- data/lib/active_support/cache/mem_cache_store.rb +12 -4
- data/lib/active_support/cache/memory_store.rb +2 -0
- data/lib/active_support/cache/null_store.rb +2 -0
- data/lib/active_support/cache/redis_cache_store.rb +404 -0
- data/lib/active_support/cache/strategy/local_cache.rb +9 -2
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +2 -0
- data/lib/active_support/callbacks.rb +26 -37
- data/lib/active_support/concern.rb +3 -1
- data/lib/active_support/concurrency/share_lock.rb +2 -0
- data/lib/active_support/configurable.rb +2 -0
- data/lib/active_support/core_ext.rb +3 -1
- data/lib/active_support/core_ext/array.rb +2 -0
- data/lib/active_support/core_ext/array/access.rb +4 -2
- data/lib/active_support/core_ext/array/conversions.rb +2 -0
- data/lib/active_support/core_ext/array/extract_options.rb +2 -0
- data/lib/active_support/core_ext/array/grouping.rb +2 -0
- data/lib/active_support/core_ext/array/inquiry.rb +2 -0
- data/lib/active_support/core_ext/array/prepend_and_append.rb +4 -2
- data/lib/active_support/core_ext/array/wrap.rb +2 -0
- data/lib/active_support/core_ext/benchmark.rb +2 -0
- data/lib/active_support/core_ext/big_decimal.rb +2 -0
- data/lib/active_support/core_ext/big_decimal/conversions.rb +2 -0
- data/lib/active_support/core_ext/class.rb +2 -0
- data/lib/active_support/core_ext/class/attribute.rb +34 -16
- data/lib/active_support/core_ext/class/attribute_accessors.rb +2 -0
- data/lib/active_support/core_ext/class/subclasses.rb +1 -2
- data/lib/active_support/core_ext/date.rb +2 -0
- data/lib/active_support/core_ext/date/acts_like.rb +2 -0
- data/lib/active_support/core_ext/date/blank.rb +2 -0
- data/lib/active_support/core_ext/date/calculations.rb +2 -0
- data/lib/active_support/core_ext/date/conversions.rb +10 -9
- data/lib/active_support/core_ext/date/zones.rb +2 -0
- data/lib/active_support/core_ext/date_and_time/calculations.rb +42 -16
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +3 -1
- data/lib/active_support/core_ext/date_and_time/zones.rb +2 -0
- data/lib/active_support/core_ext/date_time.rb +2 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +2 -0
- data/lib/active_support/core_ext/date_time/blank.rb +2 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +2 -0
- data/lib/active_support/core_ext/date_time/compatibility.rb +6 -4
- data/lib/active_support/core_ext/date_time/conversions.rb +2 -0
- data/lib/active_support/core_ext/digest/uuid.rb +3 -1
- data/lib/active_support/core_ext/enumerable.rb +3 -1
- data/lib/active_support/core_ext/file.rb +2 -0
- data/lib/active_support/core_ext/file/atomic.rb +2 -0
- data/lib/active_support/core_ext/hash.rb +2 -0
- data/lib/active_support/core_ext/hash/compact.rb +2 -0
- data/lib/active_support/core_ext/hash/conversions.rb +2 -0
- data/lib/active_support/core_ext/hash/deep_merge.rb +8 -12
- data/lib/active_support/core_ext/hash/except.rb +2 -0
- data/lib/active_support/core_ext/hash/indifferent_access.rb +2 -0
- data/lib/active_support/core_ext/hash/keys.rb +2 -0
- data/lib/active_support/core_ext/hash/reverse_merge.rb +5 -2
- data/lib/active_support/core_ext/hash/slice.rb +4 -4
- data/lib/active_support/core_ext/hash/transform_values.rb +2 -0
- data/lib/active_support/core_ext/integer.rb +2 -0
- data/lib/active_support/core_ext/integer/inflections.rb +2 -0
- data/lib/active_support/core_ext/integer/multiple.rb +2 -0
- data/lib/active_support/core_ext/integer/time.rb +7 -14
- data/lib/active_support/core_ext/kernel.rb +2 -0
- data/lib/active_support/core_ext/kernel/agnostics.rb +2 -0
- data/lib/active_support/core_ext/kernel/concern.rb +2 -0
- data/lib/active_support/core_ext/kernel/reporting.rb +2 -0
- data/lib/active_support/core_ext/kernel/singleton_class.rb +2 -0
- data/lib/active_support/core_ext/load_error.rb +2 -7
- data/lib/active_support/core_ext/marshal.rb +2 -0
- data/lib/active_support/core_ext/module.rb +3 -0
- data/lib/active_support/core_ext/module/aliasing.rb +2 -0
- data/lib/active_support/core_ext/module/anonymous.rb +2 -0
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -0
- data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -24
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +2 -0
- data/lib/active_support/core_ext/module/concerning.rb +2 -0
- data/lib/active_support/core_ext/module/delegation.rb +29 -24
- data/lib/active_support/core_ext/module/deprecation.rb +2 -0
- data/lib/active_support/core_ext/module/introspection.rb +2 -0
- data/lib/active_support/core_ext/module/reachable.rb +3 -0
- data/lib/active_support/core_ext/module/redefine_method.rb +49 -0
- data/lib/active_support/core_ext/module/remove_method.rb +5 -23
- data/lib/active_support/core_ext/name_error.rb +2 -0
- data/lib/active_support/core_ext/numeric.rb +2 -0
- data/lib/active_support/core_ext/numeric/bytes.rb +2 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +9 -7
- data/lib/active_support/core_ext/numeric/inquiry.rb +2 -0
- data/lib/active_support/core_ext/numeric/time.rb +7 -15
- data/lib/active_support/core_ext/object.rb +2 -0
- data/lib/active_support/core_ext/object/acts_like.rb +12 -1
- data/lib/active_support/core_ext/object/blank.rb +2 -0
- data/lib/active_support/core_ext/object/conversions.rb +2 -0
- data/lib/active_support/core_ext/object/deep_dup.rb +2 -0
- data/lib/active_support/core_ext/object/duplicable.rb +10 -8
- data/lib/active_support/core_ext/object/inclusion.rb +2 -0
- data/lib/active_support/core_ext/object/instance_variables.rb +2 -0
- data/lib/active_support/core_ext/object/json.rb +8 -0
- data/lib/active_support/core_ext/object/to_param.rb +2 -0
- data/lib/active_support/core_ext/object/to_query.rb +4 -5
- data/lib/active_support/core_ext/object/try.rb +2 -0
- data/lib/active_support/core_ext/object/with_options.rb +3 -1
- data/lib/active_support/core_ext/range.rb +3 -0
- data/lib/active_support/core_ext/range/conversions.rb +9 -1
- data/lib/active_support/core_ext/range/each.rb +5 -1
- data/lib/active_support/core_ext/range/include_range.rb +2 -0
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +23 -0
- data/lib/active_support/core_ext/range/overlaps.rb +2 -0
- data/lib/active_support/core_ext/regexp.rb +2 -0
- data/lib/active_support/core_ext/securerandom.rb +2 -0
- data/lib/active_support/core_ext/string.rb +2 -0
- data/lib/active_support/core_ext/string/access.rb +2 -0
- data/lib/active_support/core_ext/string/behavior.rb +2 -0
- data/lib/active_support/core_ext/string/conversions.rb +2 -0
- data/lib/active_support/core_ext/string/exclude.rb +2 -0
- data/lib/active_support/core_ext/string/filters.rb +2 -0
- data/lib/active_support/core_ext/string/indent.rb +2 -0
- data/lib/active_support/core_ext/string/inflections.rb +26 -12
- data/lib/active_support/core_ext/string/inquiry.rb +2 -0
- data/lib/active_support/core_ext/string/multibyte.rb +2 -0
- data/lib/active_support/core_ext/string/output_safety.rb +6 -7
- data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -0
- data/lib/active_support/core_ext/string/strip.rb +2 -0
- data/lib/active_support/core_ext/string/zones.rb +2 -0
- data/lib/active_support/core_ext/time.rb +2 -0
- data/lib/active_support/core_ext/time/acts_like.rb +2 -0
- data/lib/active_support/core_ext/time/calculations.rb +23 -15
- data/lib/active_support/core_ext/time/compatibility.rb +4 -2
- data/lib/active_support/core_ext/time/conversions.rb +2 -0
- data/lib/active_support/core_ext/time/zones.rb +6 -4
- data/lib/active_support/core_ext/uri.rb +4 -1
- data/lib/active_support/current_attributes.rb +195 -0
- data/lib/active_support/dependencies.rb +15 -25
- data/lib/active_support/dependencies/autoload.rb +2 -0
- data/lib/active_support/dependencies/interlock.rb +2 -0
- data/lib/active_support/deprecation.rb +4 -2
- data/lib/active_support/deprecation/behaviors.rb +23 -8
- data/lib/active_support/deprecation/constant_accessor.rb +3 -1
- data/lib/active_support/deprecation/instance_delegator.rb +2 -0
- data/lib/active_support/deprecation/method_wrappers.rb +2 -7
- data/lib/active_support/deprecation/proxy_wrappers.rb +4 -1
- data/lib/active_support/deprecation/reporting.rb +4 -2
- data/lib/active_support/descendants_tracker.rb +2 -0
- data/lib/active_support/duration.rb +8 -14
- data/lib/active_support/duration/iso8601_parser.rb +4 -2
- data/lib/active_support/duration/iso8601_serializer.rb +4 -2
- data/lib/active_support/encrypted_configuration.rb +48 -0
- data/lib/active_support/encrypted_file.rb +99 -0
- data/lib/active_support/evented_file_update_checker.rb +2 -0
- data/lib/active_support/execution_wrapper.rb +2 -0
- data/lib/active_support/executor.rb +2 -0
- data/lib/active_support/file_update_checker.rb +2 -0
- data/lib/active_support/gem_version.rb +5 -3
- data/lib/active_support/gzip.rb +2 -0
- data/lib/active_support/hash_with_indifferent_access.rb +33 -1
- data/lib/active_support/i18n.rb +3 -1
- data/lib/active_support/i18n_railtie.rb +5 -11
- data/lib/active_support/inflections.rb +2 -0
- data/lib/active_support/inflector.rb +2 -0
- data/lib/active_support/inflector/inflections.rb +19 -3
- data/lib/active_support/inflector/methods.rb +40 -23
- data/lib/active_support/inflector/transliterate.rb +17 -8
- data/lib/active_support/json.rb +2 -0
- data/lib/active_support/json/decoding.rb +2 -0
- data/lib/active_support/json/encoding.rb +2 -0
- data/lib/active_support/key_generator.rb +3 -1
- data/lib/active_support/lazy_load_hooks.rb +2 -0
- data/lib/active_support/log_subscriber.rb +3 -2
- data/lib/active_support/log_subscriber/test_helper.rb +2 -0
- data/lib/active_support/logger.rb +2 -0
- data/lib/active_support/logger_silence.rb +3 -2
- data/lib/active_support/logger_thread_safe_level.rb +2 -0
- data/lib/active_support/message_encryptor.rb +94 -22
- data/lib/active_support/message_verifier.rb +78 -7
- data/lib/active_support/messages/metadata.rb +71 -0
- data/lib/active_support/messages/rotation_configuration.rb +22 -0
- data/lib/active_support/messages/rotator.rb +56 -0
- data/lib/active_support/multibyte.rb +2 -0
- data/lib/active_support/multibyte/chars.rb +2 -0
- data/lib/active_support/multibyte/unicode.rb +3 -1
- data/lib/active_support/notifications.rb +2 -0
- data/lib/active_support/notifications/fanout.rb +2 -0
- data/lib/active_support/notifications/instrumenter.rb +2 -0
- data/lib/active_support/number_helper.rb +2 -0
- data/lib/active_support/number_helper/number_converter.rb +2 -0
- data/lib/active_support/number_helper/number_to_currency_converter.rb +2 -0
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +2 -0
- data/lib/active_support/number_helper/number_to_human_converter.rb +2 -0
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +2 -0
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +2 -0
- data/lib/active_support/number_helper/number_to_phone_converter.rb +3 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +2 -20
- data/lib/active_support/number_helper/rounding_helper.rb +5 -3
- data/lib/active_support/option_merger.rb +2 -0
- data/lib/active_support/ordered_hash.rb +2 -0
- data/lib/active_support/ordered_options.rb +4 -2
- data/lib/active_support/per_thread_registry.rb +2 -0
- data/lib/active_support/proxy_object.rb +2 -0
- data/lib/active_support/rails.rb +2 -0
- data/lib/active_support/railtie.rb +27 -8
- data/lib/active_support/reloader.rb +7 -5
- data/lib/active_support/rescuable.rb +3 -2
- data/lib/active_support/security_utils.rb +15 -11
- data/lib/active_support/string_inquirer.rb +2 -0
- data/lib/active_support/subscriber.rb +2 -0
- data/lib/active_support/tagged_logging.rb +2 -0
- data/lib/active_support/test_case.rb +2 -1
- data/lib/active_support/testing/assertions.rb +6 -4
- data/lib/active_support/testing/autorun.rb +2 -0
- data/lib/active_support/testing/constant_lookup.rb +2 -0
- data/lib/active_support/testing/declarative.rb +2 -0
- data/lib/active_support/testing/deprecation.rb +2 -0
- data/lib/active_support/testing/file_fixtures.rb +2 -0
- data/lib/active_support/testing/isolation.rb +5 -5
- data/lib/active_support/testing/method_call_assertions.rb +2 -0
- data/lib/active_support/testing/setup_and_teardown.rb +2 -0
- data/lib/active_support/testing/stream.rb +2 -0
- data/lib/active_support/testing/tagged_logging.rb +2 -0
- data/lib/active_support/testing/time_helpers.rb +31 -2
- data/lib/active_support/time.rb +2 -0
- data/lib/active_support/time_with_zone.rb +38 -0
- data/lib/active_support/values/time_zone.rb +20 -12
- data/lib/active_support/version.rb +2 -0
- data/lib/active_support/xml_mini.rb +2 -0
- data/lib/active_support/xml_mini/jdom.rb +4 -2
- data/lib/active_support/xml_mini/libxml.rb +3 -1
- data/lib/active_support/xml_mini/libxmlsax.rb +4 -2
- data/lib/active_support/xml_mini/nokogiri.rb +3 -1
- data/lib/active_support/xml_mini/nokogirisax.rb +3 -1
- data/lib/active_support/xml_mini/rexml.rb +3 -1
- metadata +19 -15
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveSupport
|
4
|
+
module Messages
|
5
|
+
module Rotator # :nodoc:
|
6
|
+
def initialize(*, **options)
|
7
|
+
super
|
8
|
+
|
9
|
+
@options = options
|
10
|
+
@rotations = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def rotate(*secrets, **options)
|
14
|
+
@rotations << build_rotation(*secrets, @options.merge(options))
|
15
|
+
end
|
16
|
+
|
17
|
+
module Encryptor
|
18
|
+
include Rotator
|
19
|
+
|
20
|
+
def decrypt_and_verify(*args, on_rotation: nil, **options)
|
21
|
+
super
|
22
|
+
rescue MessageEncryptor::InvalidMessage, MessageVerifier::InvalidSignature
|
23
|
+
run_rotations(on_rotation) { |encryptor| encryptor.decrypt_and_verify(*args, options) } || raise
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def build_rotation(secret = @secret, sign_secret = @sign_secret, options)
|
28
|
+
self.class.new(secret, sign_secret, options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Verifier
|
33
|
+
include Rotator
|
34
|
+
|
35
|
+
def verified(*args, on_rotation: nil, **options)
|
36
|
+
super || run_rotations(on_rotation) { |verifier| verifier.verified(*args, options) }
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def build_rotation(secret = @secret, options)
|
41
|
+
self.class.new(secret, options)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def run_rotations(on_rotation)
|
47
|
+
@rotations.find do |rotation|
|
48
|
+
if message = yield(rotation) rescue next
|
49
|
+
on_rotation.call if on_rotation
|
50
|
+
return message
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveSupport
|
2
4
|
module Multibyte
|
3
5
|
module Unicode
|
@@ -357,7 +359,7 @@ module ActiveSupport
|
|
357
359
|
|
358
360
|
# Returns the directory in which the data files are stored.
|
359
361
|
def self.dirname
|
360
|
-
File.
|
362
|
+
File.expand_path("../values", __dir__)
|
361
363
|
end
|
362
364
|
|
363
365
|
# Returns the filename for the data file for this version.
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveSupport
|
2
4
|
module NumberHelper
|
3
5
|
class NumberToPhoneConverter < NumberConverter #:nodoc:
|
4
6
|
def convert
|
5
|
-
str = country_code(opts[:country_code])
|
7
|
+
str = country_code(opts[:country_code]).dup
|
6
8
|
str << convert_to_phone_number(number.to_s.strip)
|
7
9
|
str << phone_ext(opts[:extension])
|
8
10
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveSupport
|
2
4
|
module NumberHelper
|
3
5
|
class NumberToRoundedConverter < NumberConverter # :nodoc:
|
@@ -35,26 +37,6 @@ module ActiveSupport
|
|
35
37
|
|
36
38
|
private
|
37
39
|
|
38
|
-
def digits_and_rounded_number(precision)
|
39
|
-
if zero?
|
40
|
-
[1, 0]
|
41
|
-
else
|
42
|
-
digits = digit_count(number)
|
43
|
-
multiplier = 10**(digits - precision)
|
44
|
-
rounded_number = calculate_rounded_number(multiplier)
|
45
|
-
digits = digit_count(rounded_number) # After rounding, the number of digits may have changed
|
46
|
-
[digits, rounded_number]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def calculate_rounded_number(multiplier)
|
51
|
-
(number / BigDecimal.new(multiplier.to_f.to_s)).round * multiplier
|
52
|
-
end
|
53
|
-
|
54
|
-
def digit_count(number)
|
55
|
-
number.zero? ? 1 : (Math.log10(absolute_number(number)) + 1).floor
|
56
|
-
end
|
57
|
-
|
58
40
|
def strip_insignificant_zeros
|
59
41
|
options[:strip_insignificant_zeros]
|
60
42
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveSupport
|
2
4
|
module NumberHelper
|
3
5
|
class RoundingHelper # :nodoc:
|
@@ -40,11 +42,11 @@ module ActiveSupport
|
|
40
42
|
def convert_to_decimal(number)
|
41
43
|
case number
|
42
44
|
when Float, String
|
43
|
-
|
45
|
+
BigDecimal(number.to_s)
|
44
46
|
when Rational
|
45
|
-
|
47
|
+
BigDecimal(number, digit_count(number.to_i) + precision)
|
46
48
|
else
|
47
|
-
number
|
49
|
+
number.to_d
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/object/blank"
|
2
4
|
|
3
5
|
module ActiveSupport
|
@@ -22,7 +24,7 @@ module ActiveSupport
|
|
22
24
|
# To raise an exception when the value is blank, append a
|
23
25
|
# bang to the key name, like:
|
24
26
|
#
|
25
|
-
# h.dog! # => raises KeyError:
|
27
|
+
# h.dog! # => raises KeyError: :dog is blank
|
26
28
|
#
|
27
29
|
class OrderedOptions < Hash
|
28
30
|
alias_method :_get, :[] # preserve the original #[] method
|
@@ -44,7 +46,7 @@ module ActiveSupport
|
|
44
46
|
bangs = name_string.chomp!("!")
|
45
47
|
|
46
48
|
if bangs
|
47
|
-
|
49
|
+
self[name_string].presence || raise(KeyError.new(":#{name_string} is blank"))
|
48
50
|
else
|
49
51
|
self[name_string]
|
50
52
|
end
|
data/lib/active_support/rails.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support"
|
2
4
|
require "active_support/i18n_railtie"
|
3
5
|
|
@@ -7,6 +9,19 @@ module ActiveSupport
|
|
7
9
|
|
8
10
|
config.eager_load_namespaces << ActiveSupport
|
9
11
|
|
12
|
+
initializer "active_support.set_authenticated_message_encryption" do |app|
|
13
|
+
if app.config.active_support.respond_to?(:use_authenticated_message_encryption)
|
14
|
+
ActiveSupport::MessageEncryptor.use_authenticated_message_encryption =
|
15
|
+
app.config.active_support.use_authenticated_message_encryption
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
initializer "active_support.reset_all_current_attributes_instances" do |app|
|
20
|
+
app.reloader.before_class_unload { ActiveSupport::CurrentAttributes.clear_all }
|
21
|
+
app.executor.to_run { ActiveSupport::CurrentAttributes.reset_all }
|
22
|
+
app.executor.to_complete { ActiveSupport::CurrentAttributes.reset_all }
|
23
|
+
end
|
24
|
+
|
10
25
|
initializer "active_support.deprecation_behavior" do |app|
|
11
26
|
if deprecation = app.config.active_support.deprecation
|
12
27
|
ActiveSupport::Deprecation.behavior = deprecation
|
@@ -22,14 +37,7 @@ module ActiveSupport
|
|
22
37
|
raise e.exception "tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install"
|
23
38
|
end
|
24
39
|
require "active_support/core_ext/time/zones"
|
25
|
-
zone_default = Time.find_zone!(app.config.time_zone)
|
26
|
-
|
27
|
-
unless zone_default
|
28
|
-
raise "Value assigned to config.time_zone not recognized. " \
|
29
|
-
'Run "rake time:zones:all" for a time zone names list.'
|
30
|
-
end
|
31
|
-
|
32
|
-
Time.zone_default = zone_default
|
40
|
+
Time.zone_default = Time.find_zone!(app.config.time_zone)
|
33
41
|
end
|
34
42
|
|
35
43
|
# Sets the default week start
|
@@ -41,6 +49,17 @@ module ActiveSupport
|
|
41
49
|
Date.beginning_of_week_default = beginning_of_week_default
|
42
50
|
end
|
43
51
|
|
52
|
+
initializer "active_support.require_master_key" do |app|
|
53
|
+
if app.config.respond_to?(:require_master_key) && app.config.require_master_key
|
54
|
+
begin
|
55
|
+
app.credentials.key
|
56
|
+
rescue ActiveSupport::EncryptedFile::MissingKeyError => error
|
57
|
+
$stderr.puts error.message
|
58
|
+
exit 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
44
63
|
initializer "active_support.set_configs" do |app|
|
45
64
|
app.config.active_support.each do |k, v|
|
46
65
|
k = "#{k}="
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/execution_wrapper"
|
2
4
|
|
3
5
|
module ActiveSupport
|
@@ -26,14 +28,17 @@ module ActiveSupport
|
|
26
28
|
|
27
29
|
define_callbacks :class_unload
|
28
30
|
|
31
|
+
# Registers a callback that will run once at application startup and every time the code is reloaded.
|
29
32
|
def self.to_prepare(*args, &block)
|
30
33
|
set_callback(:prepare, *args, &block)
|
31
34
|
end
|
32
35
|
|
36
|
+
# Registers a callback that will run immediately before the classes are unloaded.
|
33
37
|
def self.before_class_unload(*args, &block)
|
34
38
|
set_callback(:class_unload, *args, &block)
|
35
39
|
end
|
36
40
|
|
41
|
+
# Registers a callback that will run immediately after the classes are unloaded.
|
37
42
|
def self.after_class_unload(*args, &block)
|
38
43
|
set_callback(:class_unload, :after, *args, &block)
|
39
44
|
end
|
@@ -69,11 +74,8 @@ module ActiveSupport
|
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
72
|
-
class_attribute :executor
|
73
|
-
class_attribute :check
|
74
|
-
|
75
|
-
self.executor = Executor
|
76
|
-
self.check = lambda { false }
|
77
|
+
class_attribute :executor, default: Executor
|
78
|
+
class_attribute :check, default: lambda { false }
|
77
79
|
|
78
80
|
def self.check! # :nodoc:
|
79
81
|
@should_reload ||= check.call
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/concern"
|
2
4
|
require "active_support/core_ext/class/attribute"
|
3
5
|
require "active_support/core_ext/string/inflections"
|
@@ -8,8 +10,7 @@ module ActiveSupport
|
|
8
10
|
extend Concern
|
9
11
|
|
10
12
|
included do
|
11
|
-
class_attribute :rescue_handlers
|
12
|
-
self.rescue_handlers = []
|
13
|
+
class_attribute :rescue_handlers, default: []
|
13
14
|
end
|
14
15
|
|
15
16
|
module ClassMethods
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "digest/sha2"
|
2
4
|
|
3
5
|
module ActiveSupport
|
4
6
|
module SecurityUtils
|
5
|
-
# Constant time string comparison.
|
7
|
+
# Constant time string comparison, for fixed length strings.
|
6
8
|
#
|
7
9
|
# The values compared should be of fixed length, such as strings
|
8
|
-
# that have already been processed by HMAC.
|
9
|
-
|
10
|
-
|
11
|
-
def secure_compare(a, b)
|
12
|
-
return false unless a.bytesize == b.bytesize
|
10
|
+
# that have already been processed by HMAC. Raises in case of length mismatch.
|
11
|
+
def fixed_length_secure_compare(a, b)
|
12
|
+
raise ArgumentError, "string length mismatch." unless a.bytesize == b.bytesize
|
13
13
|
|
14
14
|
l = a.unpack "C#{a.bytesize}"
|
15
15
|
|
@@ -17,11 +17,15 @@ module ActiveSupport
|
|
17
17
|
b.each_byte { |byte| res |= byte ^ l.shift }
|
18
18
|
res == 0
|
19
19
|
end
|
20
|
-
module_function :
|
20
|
+
module_function :fixed_length_secure_compare
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
# Constant time string comparison, for variable length strings.
|
23
|
+
#
|
24
|
+
# The values are first processed by SHA256, so that we don't leak length info
|
25
|
+
# via timing attacks.
|
26
|
+
def secure_compare(a, b)
|
27
|
+
fixed_length_secure_compare(::Digest::SHA256.hexdigest(a), ::Digest::SHA256.hexdigest(b)) && a == b
|
24
28
|
end
|
25
|
-
module_function :
|
29
|
+
module_function :secure_compare
|
26
30
|
end
|
27
31
|
end
|