activesupport 6.1.7.2 → 7.0.0.alpha1
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 +4 -4
- data/CHANGELOG.md +151 -620
- data/MIT-LICENSE +1 -1
- data/lib/active_support/actionable_error.rb +1 -1
- data/lib/active_support/array_inquirer.rb +0 -2
- data/lib/active_support/benchmarkable.rb +2 -2
- data/lib/active_support/cache/file_store.rb +15 -9
- data/lib/active_support/cache/mem_cache_store.rb +119 -28
- data/lib/active_support/cache/memory_store.rb +21 -13
- data/lib/active_support/cache/null_store.rb +10 -2
- data/lib/active_support/cache/redis_cache_store.rb +39 -59
- data/lib/active_support/cache/strategy/local_cache.rb +29 -49
- data/lib/active_support/cache.rb +189 -45
- data/lib/active_support/callbacks.rb +35 -31
- data/lib/active_support/concern.rb +5 -5
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +2 -4
- data/lib/active_support/concurrency/share_lock.rb +2 -2
- data/lib/active_support/configurable.rb +6 -3
- data/lib/active_support/configuration_file.rb +1 -1
- data/lib/active_support/core_ext/array/access.rb +1 -5
- data/lib/active_support/core_ext/array/conversions.rb +6 -6
- data/lib/active_support/core_ext/array/grouping.rb +6 -6
- data/lib/active_support/core_ext/big_decimal/conversions.rb +1 -1
- data/lib/active_support/core_ext/date/blank.rb +1 -1
- data/lib/active_support/core_ext/date/calculations.rb +2 -2
- data/lib/active_support/core_ext/date_time/blank.rb +1 -1
- data/lib/active_support/core_ext/digest/uuid.rb +13 -13
- data/lib/active_support/core_ext/enumerable.rb +64 -12
- data/lib/active_support/core_ext/file/atomic.rb +1 -1
- data/lib/active_support/core_ext/hash/keys.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +4 -4
- data/lib/active_support/core_ext/module/delegation.rb +2 -8
- data/lib/active_support/core_ext/name_error.rb +2 -8
- data/lib/active_support/core_ext/numeric/conversions.rb +2 -2
- data/lib/active_support/core_ext/object/blank.rb +2 -2
- data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
- data/lib/active_support/core_ext/object/duplicable.rb +11 -0
- data/lib/active_support/core_ext/object/json.rb +29 -24
- data/lib/active_support/core_ext/object/to_query.rb +2 -2
- data/lib/active_support/core_ext/object/try.rb +20 -20
- data/lib/active_support/core_ext/range/compare_range.rb +0 -25
- data/lib/active_support/core_ext/range/each.rb +1 -1
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +1 -1
- data/lib/active_support/core_ext/string/filters.rb +1 -1
- data/lib/active_support/core_ext/string/inflections.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +60 -64
- data/lib/active_support/core_ext/symbol/starts_ends_with.rb +0 -8
- data/lib/active_support/core_ext/time/calculations.rb +4 -5
- data/lib/active_support/core_ext/time/zones.rb +2 -17
- data/lib/active_support/core_ext/uri.rb +0 -14
- data/lib/active_support/current_attributes.rb +17 -2
- data/lib/active_support/dependencies/interlock.rb +10 -18
- data/lib/active_support/dependencies/require_dependency.rb +28 -0
- data/lib/active_support/dependencies.rb +58 -788
- data/lib/active_support/deprecation/behaviors.rb +4 -1
- data/lib/active_support/deprecation/method_wrappers.rb +3 -3
- data/lib/active_support/deprecation/proxy_wrappers.rb +1 -1
- data/lib/active_support/deprecation.rb +1 -1
- data/lib/active_support/descendants_tracker.rb +12 -9
- data/lib/active_support/digest.rb +4 -4
- data/lib/active_support/duration/iso8601_parser.rb +3 -3
- data/lib/active_support/duration/iso8601_serializer.rb +9 -1
- data/lib/active_support/duration.rb +80 -52
- data/lib/active_support/encrypted_configuration.rb +11 -1
- data/lib/active_support/encrypted_file.rb +1 -1
- data/lib/active_support/environment_inquirer.rb +1 -1
- data/lib/active_support/evented_file_update_checker.rb +1 -1
- data/lib/active_support/execution_wrapper.rb +13 -16
- data/lib/active_support/fork_tracker.rb +2 -4
- data/lib/active_support/gem_version.rb +4 -4
- data/lib/active_support/hash_with_indifferent_access.rb +3 -1
- data/lib/active_support/i18n.rb +1 -0
- data/lib/active_support/inflector/inflections.rb +11 -4
- data/lib/active_support/inflector/methods.rb +23 -46
- data/lib/active_support/json/encoding.rb +3 -3
- data/lib/active_support/key_generator.rb +18 -1
- data/lib/active_support/locale/en.yml +1 -1
- data/lib/active_support/log_subscriber.rb +13 -3
- data/lib/active_support/logger_thread_safe_level.rb +5 -13
- data/lib/active_support/message_encryptor.rb +3 -3
- data/lib/active_support/message_verifier.rb +4 -4
- data/lib/active_support/messages/metadata.rb +2 -2
- data/lib/active_support/multibyte/chars.rb +10 -11
- data/lib/active_support/multibyte.rb +1 -1
- data/lib/active_support/notifications/fanout.rb +31 -11
- data/lib/active_support/notifications/instrumenter.rb +17 -0
- data/lib/active_support/notifications.rb +10 -0
- data/lib/active_support/number_helper/number_converter.rb +1 -3
- data/lib/active_support/number_helper/number_to_currency_converter.rb +11 -6
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -1
- data/lib/active_support/number_helper/rounding_helper.rb +1 -5
- data/lib/active_support/number_helper.rb +0 -2
- data/lib/active_support/option_merger.rb +4 -16
- data/lib/active_support/ordered_hash.rb +1 -1
- data/lib/active_support/parameter_filter.rb +5 -0
- data/lib/active_support/per_thread_registry.rb +1 -1
- data/lib/active_support/railtie.rb +33 -10
- data/lib/active_support/reloader.rb +1 -1
- data/lib/active_support/rescuable.rb +2 -2
- data/lib/active_support/secure_compare_rotator.rb +1 -1
- data/lib/active_support/string_inquirer.rb +0 -2
- data/lib/active_support/subscriber.rb +5 -0
- data/lib/active_support/test_case.rb +9 -21
- data/lib/active_support/testing/assertions.rb +34 -4
- data/lib/active_support/testing/deprecation.rb +1 -1
- data/lib/active_support/testing/isolation.rb +1 -1
- data/lib/active_support/testing/method_call_assertions.rb +5 -5
- data/lib/active_support/testing/parallelization/server.rb +4 -0
- data/lib/active_support/testing/parallelization/worker.rb +3 -0
- data/lib/active_support/testing/parallelization.rb +4 -0
- data/lib/active_support/testing/parallelize_executor.rb +76 -0
- data/lib/active_support/testing/stream.rb +3 -5
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +13 -2
- data/lib/active_support/time_with_zone.rb +19 -6
- data/lib/active_support/values/time_zone.rb +25 -11
- data/lib/active_support/xml_mini/jdom.rb +1 -1
- data/lib/active_support/xml_mini/libxml.rb +5 -5
- data/lib/active_support/xml_mini/libxmlsax.rb +1 -1
- data/lib/active_support/xml_mini/nokogiri.rb +4 -4
- data/lib/active_support/xml_mini/nokogirisax.rb +1 -1
- data/lib/active_support/xml_mini/rexml.rb +1 -1
- data/lib/active_support/xml_mini.rb +2 -1
- data/lib/active_support.rb +14 -1
- metadata +14 -29
- data/lib/active_support/core_ext/marshal.rb +0 -26
- data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -120
@@ -229,12 +229,16 @@ module ActiveSupport
|
|
229
229
|
# Returns +nil+ if no such time zone is known to the system.
|
230
230
|
def [](arg)
|
231
231
|
case arg
|
232
|
+
when self
|
233
|
+
arg
|
232
234
|
when String
|
233
235
|
begin
|
234
236
|
@lazy_zones_map[arg] ||= create(arg)
|
235
237
|
rescue TZInfo::InvalidTimezoneIdentifier
|
236
238
|
nil
|
237
239
|
end
|
240
|
+
when TZInfo::Timezone
|
241
|
+
@lazy_zones_map[arg.name] ||= create(arg.name, nil, arg)
|
238
242
|
when Numeric, ActiveSupport::Duration
|
239
243
|
arg *= 3600 if arg.abs <= 13
|
240
244
|
all.find { |z| z.utc_offset == arg.to_i }
|
@@ -256,7 +260,7 @@ module ActiveSupport
|
|
256
260
|
@country_zones[code] ||= load_country_zones(code)
|
257
261
|
end
|
258
262
|
|
259
|
-
def clear
|
263
|
+
def clear # :nodoc:
|
260
264
|
@lazy_zones_map = Concurrent::Map.new
|
261
265
|
@country_zones = Concurrent::Map.new
|
262
266
|
@zones = nil
|
@@ -381,16 +385,23 @@ module ActiveSupport
|
|
381
385
|
# If the string is invalid then an +ArgumentError+ will be raised unlike +parse+
|
382
386
|
# which usually returns +nil+ when given an invalid date string.
|
383
387
|
def iso8601(str)
|
384
|
-
raise ArgumentError, "invalid date" if str.nil?
|
385
|
-
|
386
388
|
parts = Date._iso8601(str)
|
387
389
|
|
388
|
-
|
390
|
+
year = parts.fetch(:year)
|
391
|
+
|
392
|
+
if parts.key?(:yday)
|
393
|
+
ordinal_date = Date.ordinal(year, parts.fetch(:yday))
|
394
|
+
month = ordinal_date.month
|
395
|
+
day = ordinal_date.day
|
396
|
+
else
|
397
|
+
month = parts.fetch(:mon)
|
398
|
+
day = parts.fetch(:mday)
|
399
|
+
end
|
389
400
|
|
390
401
|
time = Time.new(
|
391
|
-
|
392
|
-
|
393
|
-
|
402
|
+
year,
|
403
|
+
month,
|
404
|
+
day,
|
394
405
|
parts.fetch(:hour, 0),
|
395
406
|
parts.fetch(:min, 0),
|
396
407
|
parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0),
|
@@ -402,6 +413,9 @@ module ActiveSupport
|
|
402
413
|
else
|
403
414
|
TimeWithZone.new(nil, self, time)
|
404
415
|
end
|
416
|
+
|
417
|
+
rescue Date::Error, KeyError
|
418
|
+
raise ArgumentError, "invalid date"
|
405
419
|
end
|
406
420
|
|
407
421
|
# Method for creating new ActiveSupport::TimeWithZone instance in time zone
|
@@ -514,7 +528,7 @@ module ActiveSupport
|
|
514
528
|
def utc_to_local(time)
|
515
529
|
tzinfo.utc_to_local(time).yield_self do |t|
|
516
530
|
ActiveSupport.utc_to_local_returns_utc_offset_times ?
|
517
|
-
t : Time.utc(t.year, t.month, t.day, t.hour, t.min, t.sec, t.sec_fraction)
|
531
|
+
t : Time.utc(t.year, t.month, t.day, t.hour, t.min, t.sec, t.sec_fraction * 1_000_000)
|
518
532
|
end
|
519
533
|
end
|
520
534
|
|
@@ -536,15 +550,15 @@ module ActiveSupport
|
|
536
550
|
tzinfo.period_for_local(time, dst) { |periods| periods.last }
|
537
551
|
end
|
538
552
|
|
539
|
-
def periods_for_local(time)
|
553
|
+
def periods_for_local(time) # :nodoc:
|
540
554
|
tzinfo.periods_for_local(time)
|
541
555
|
end
|
542
556
|
|
543
|
-
def init_with(coder)
|
557
|
+
def init_with(coder) # :nodoc:
|
544
558
|
initialize(coder["name"])
|
545
559
|
end
|
546
560
|
|
547
|
-
def encode_with(coder)
|
561
|
+
def encode_with(coder) # :nodoc:
|
548
562
|
coder.tag = "!ruby/object:#{self.class}"
|
549
563
|
coder.map = { "name" => tzinfo.name }
|
550
564
|
end
|
@@ -5,7 +5,7 @@ require "active_support/core_ext/object/blank"
|
|
5
5
|
require "stringio"
|
6
6
|
|
7
7
|
module ActiveSupport
|
8
|
-
module XmlMini_LibXML
|
8
|
+
module XmlMini_LibXML # :nodoc:
|
9
9
|
extend self
|
10
10
|
|
11
11
|
# Parse an XML Document string or IO into a simple hash using libxml.
|
@@ -25,15 +25,15 @@ module ActiveSupport
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
module LibXML
|
29
|
-
module Conversions
|
30
|
-
module Document
|
28
|
+
module LibXML # :nodoc:
|
29
|
+
module Conversions # :nodoc:
|
30
|
+
module Document # :nodoc:
|
31
31
|
def to_hash
|
32
32
|
root.to_hash
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
module Node
|
36
|
+
module Node # :nodoc:
|
37
37
|
CONTENT_ROOT = "__content__"
|
38
38
|
|
39
39
|
# Convert XML document to hash.
|
@@ -10,7 +10,7 @@ require "active_support/core_ext/object/blank"
|
|
10
10
|
require "stringio"
|
11
11
|
|
12
12
|
module ActiveSupport
|
13
|
-
module XmlMini_Nokogiri
|
13
|
+
module XmlMini_Nokogiri # :nodoc:
|
14
14
|
extend self
|
15
15
|
|
16
16
|
# Parse an XML Document string or IO into a simple hash using libxml / nokogiri.
|
@@ -30,14 +30,14 @@ module ActiveSupport
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
module Conversions
|
34
|
-
module Document
|
33
|
+
module Conversions # :nodoc:
|
34
|
+
module Document # :nodoc:
|
35
35
|
def to_hash
|
36
36
|
root.to_hash
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
module Node
|
40
|
+
module Node # :nodoc:
|
41
41
|
CONTENT_ROOT = "__content__"
|
42
42
|
|
43
43
|
# Convert XML document to hash.
|
@@ -19,7 +19,7 @@ module ActiveSupport
|
|
19
19
|
|
20
20
|
# This module decorates files deserialized using Hash.from_xml with
|
21
21
|
# the <tt>original_filename</tt> and <tt>content_type</tt> methods.
|
22
|
-
module FileLike
|
22
|
+
module FileLike # :nodoc:
|
23
23
|
attr_writer :original_filename, :content_type
|
24
24
|
|
25
25
|
def original_filename
|
@@ -50,6 +50,7 @@ module ActiveSupport
|
|
50
50
|
"Hash" => "hash"
|
51
51
|
}
|
52
52
|
end
|
53
|
+
TYPE_NAMES["ActiveSupport::TimeWithZone"] = TYPE_NAMES["Time"]
|
53
54
|
|
54
55
|
FORMATTING = {
|
55
56
|
"symbol" => Proc.new { |symbol| symbol.to_s },
|
data/lib/active_support.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c) 2005-
|
4
|
+
# Copyright (c) 2005-2021 David Heinemeier Hansson
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|
@@ -87,6 +87,15 @@ module ActiveSupport
|
|
87
87
|
end
|
88
88
|
|
89
89
|
cattr_accessor :test_order # :nodoc:
|
90
|
+
cattr_accessor :test_parallelization_threshold, default: 50 # :nodoc:
|
91
|
+
|
92
|
+
def self.cache_format_version
|
93
|
+
Cache.format_version
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.cache_format_version=(value)
|
97
|
+
Cache.format_version = value
|
98
|
+
end
|
90
99
|
|
91
100
|
def self.to_time_preserves_timezone
|
92
101
|
DateAndTime::Compatibility.preserve_timezone
|
@@ -103,6 +112,10 @@ module ActiveSupport
|
|
103
112
|
def self.utc_to_local_returns_utc_offset_times=(value)
|
104
113
|
DateAndTime::Compatibility.utc_to_local_returns_utc_offset_times = value
|
105
114
|
end
|
115
|
+
|
116
|
+
def self.current_attributes_use_thread_variables=(value)
|
117
|
+
CurrentAttributes._use_thread_variables = value
|
118
|
+
end
|
106
119
|
end
|
107
120
|
|
108
121
|
autoload :I18n, "active_support/i18n"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -64,20 +64,6 @@ dependencies:
|
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 1.0.2
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: zeitwerk
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '2.3'
|
74
|
-
type: :runtime
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '2.3'
|
81
67
|
- !ruby/object:Gem::Dependency
|
82
68
|
name: minitest
|
83
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,7 +164,6 @@ files:
|
|
178
164
|
- lib/active_support/core_ext/kernel/reporting.rb
|
179
165
|
- lib/active_support/core_ext/kernel/singleton_class.rb
|
180
166
|
- lib/active_support/core_ext/load_error.rb
|
181
|
-
- lib/active_support/core_ext/marshal.rb
|
182
167
|
- lib/active_support/core_ext/module.rb
|
183
168
|
- lib/active_support/core_ext/module/aliasing.rb
|
184
169
|
- lib/active_support/core_ext/module/anonymous.rb
|
@@ -245,7 +230,7 @@ files:
|
|
245
230
|
- lib/active_support/dependencies.rb
|
246
231
|
- lib/active_support/dependencies/autoload.rb
|
247
232
|
- lib/active_support/dependencies/interlock.rb
|
248
|
-
- lib/active_support/dependencies/
|
233
|
+
- lib/active_support/dependencies/require_dependency.rb
|
249
234
|
- lib/active_support/deprecation.rb
|
250
235
|
- lib/active_support/deprecation/behaviors.rb
|
251
236
|
- lib/active_support/deprecation/constant_accessor.rb
|
@@ -337,6 +322,7 @@ files:
|
|
337
322
|
- lib/active_support/testing/parallelization.rb
|
338
323
|
- lib/active_support/testing/parallelization/server.rb
|
339
324
|
- lib/active_support/testing/parallelization/worker.rb
|
325
|
+
- lib/active_support/testing/parallelize_executor.rb
|
340
326
|
- lib/active_support/testing/setup_and_teardown.rb
|
341
327
|
- lib/active_support/testing/stream.rb
|
342
328
|
- lib/active_support/testing/tagged_logging.rb
|
@@ -357,12 +343,11 @@ licenses:
|
|
357
343
|
- MIT
|
358
344
|
metadata:
|
359
345
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
360
|
-
changelog_uri: https://github.com/rails/rails/blob/
|
361
|
-
documentation_uri: https://api.rubyonrails.org/
|
346
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.0.0.alpha1/activesupport/CHANGELOG.md
|
347
|
+
documentation_uri: https://api.rubyonrails.org/v7.0.0.alpha1/
|
362
348
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
363
|
-
source_code_uri: https://github.com/rails/rails/tree/
|
364
|
-
|
365
|
-
post_install_message:
|
349
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.0.0.alpha1/activesupport
|
350
|
+
post_install_message:
|
366
351
|
rdoc_options:
|
367
352
|
- "--encoding"
|
368
353
|
- UTF-8
|
@@ -372,15 +357,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
372
357
|
requirements:
|
373
358
|
- - ">="
|
374
359
|
- !ruby/object:Gem::Version
|
375
|
-
version: 2.
|
360
|
+
version: 2.7.0
|
376
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
377
362
|
requirements:
|
378
|
-
- - "
|
363
|
+
- - ">"
|
379
364
|
- !ruby/object:Gem::Version
|
380
|
-
version:
|
365
|
+
version: 1.3.1
|
381
366
|
requirements: []
|
382
|
-
rubygems_version: 3.
|
383
|
-
signing_key:
|
367
|
+
rubygems_version: 3.1.6
|
368
|
+
signing_key:
|
384
369
|
specification_version: 4
|
385
370
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|
386
371
|
Rails framework.
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "active_support/core_ext/string/inflections"
|
4
|
-
|
5
|
-
module ActiveSupport
|
6
|
-
module MarshalWithAutoloading # :nodoc:
|
7
|
-
def load(source, proc = nil)
|
8
|
-
super(source, proc)
|
9
|
-
rescue ArgumentError, NameError => exc
|
10
|
-
if exc.message.match(%r|undefined class/module (.+?)(?:::)?\z|)
|
11
|
-
# try loading the class/module
|
12
|
-
loaded = $1.constantize
|
13
|
-
|
14
|
-
raise unless $1 == loaded.name
|
15
|
-
|
16
|
-
# if it is an IO we need to go back to read the object
|
17
|
-
source.rewind if source.respond_to?(:rewind)
|
18
|
-
retry
|
19
|
-
else
|
20
|
-
raise exc
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
Marshal.singleton_class.prepend(ActiveSupport::MarshalWithAutoloading)
|
@@ -1,120 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "set"
|
4
|
-
require "active_support/core_ext/string/inflections"
|
5
|
-
|
6
|
-
module ActiveSupport
|
7
|
-
module Dependencies
|
8
|
-
module ZeitwerkIntegration # :nodoc: all
|
9
|
-
module Decorations
|
10
|
-
def clear
|
11
|
-
Dependencies.unload_interlock do
|
12
|
-
Rails.autoloaders.main.reload
|
13
|
-
rescue Zeitwerk::ReloadingDisabledError
|
14
|
-
raise "reloading is disabled because config.cache_classes is true"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def constantize(cpath)
|
19
|
-
ActiveSupport::Inflector.constantize(cpath)
|
20
|
-
end
|
21
|
-
|
22
|
-
def safe_constantize(cpath)
|
23
|
-
ActiveSupport::Inflector.safe_constantize(cpath)
|
24
|
-
end
|
25
|
-
|
26
|
-
def autoloaded_constants
|
27
|
-
Rails.autoloaders.main.unloadable_cpaths
|
28
|
-
end
|
29
|
-
|
30
|
-
def autoloaded?(object)
|
31
|
-
cpath = object.is_a?(Module) ? real_mod_name(object) : object.to_s
|
32
|
-
Rails.autoloaders.main.unloadable_cpath?(cpath)
|
33
|
-
end
|
34
|
-
|
35
|
-
def verbose=(verbose)
|
36
|
-
l = verbose ? logger || Rails.logger : nil
|
37
|
-
Rails.autoloaders.each { |autoloader| autoloader.logger = l }
|
38
|
-
end
|
39
|
-
|
40
|
-
def unhook!
|
41
|
-
:no_op
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
module RequireDependency
|
46
|
-
def require_dependency(filename)
|
47
|
-
filename = filename.to_path if filename.respond_to?(:to_path)
|
48
|
-
if abspath = ActiveSupport::Dependencies.search_for_file(filename)
|
49
|
-
require abspath
|
50
|
-
else
|
51
|
-
require filename
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
module Inflector
|
57
|
-
# Concurrent::Map is not needed. This is a private class, and overrides
|
58
|
-
# must be defined while the application boots.
|
59
|
-
@overrides = {}
|
60
|
-
|
61
|
-
def self.camelize(basename, _abspath)
|
62
|
-
@overrides[basename] || basename.camelize
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.inflect(overrides)
|
66
|
-
@overrides.merge!(overrides)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
class << self
|
71
|
-
def take_over(enable_reloading:)
|
72
|
-
setup_autoloaders(enable_reloading)
|
73
|
-
freeze_paths
|
74
|
-
decorate_dependencies
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
def setup_autoloaders(enable_reloading)
|
79
|
-
Dependencies.autoload_paths.each do |autoload_path|
|
80
|
-
# Zeitwerk only accepts existing directories in `push_dir` to
|
81
|
-
# prevent misconfigurations.
|
82
|
-
next unless File.directory?(autoload_path)
|
83
|
-
|
84
|
-
autoloader = \
|
85
|
-
autoload_once?(autoload_path) ? Rails.autoloaders.once : Rails.autoloaders.main
|
86
|
-
|
87
|
-
autoloader.push_dir(autoload_path)
|
88
|
-
autoloader.do_not_eager_load(autoload_path) unless eager_load?(autoload_path)
|
89
|
-
end
|
90
|
-
|
91
|
-
Rails.autoloaders.main.enable_reloading if enable_reloading
|
92
|
-
|
93
|
-
# Order matters.
|
94
|
-
Rails.autoloaders.once.setup
|
95
|
-
Rails.autoloaders.main.setup
|
96
|
-
end
|
97
|
-
|
98
|
-
def autoload_once?(autoload_path)
|
99
|
-
Dependencies.autoload_once_paths.include?(autoload_path)
|
100
|
-
end
|
101
|
-
|
102
|
-
def eager_load?(autoload_path)
|
103
|
-
Dependencies._eager_load_paths.member?(autoload_path)
|
104
|
-
end
|
105
|
-
|
106
|
-
def freeze_paths
|
107
|
-
Dependencies.autoload_paths.freeze
|
108
|
-
Dependencies.autoload_once_paths.freeze
|
109
|
-
Dependencies._eager_load_paths.freeze
|
110
|
-
end
|
111
|
-
|
112
|
-
def decorate_dependencies
|
113
|
-
Dependencies.unhook!
|
114
|
-
Dependencies.singleton_class.prepend(Decorations)
|
115
|
-
Object.prepend(RequireDependency)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|