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
@@ -18,6 +18,6 @@ class String
|
|
18
18
|
# Technically, it looks for the least indented non-empty line
|
19
19
|
# in the whole string, and removes that amount of leading whitespace.
|
20
20
|
def strip_heredoc
|
21
|
-
gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/,
|
21
|
+
gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "".freeze)
|
22
22
|
end
|
23
23
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_support/core_ext/string/conversions"
|
2
|
+
require "active_support/core_ext/time/zones"
|
3
3
|
|
4
4
|
class String
|
5
5
|
# Converts String to a TimeWithZone in the current zone if Time.zone or Time.zone_default
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "active_support/core_ext/time/acts_like"
|
2
|
+
require "active_support/core_ext/time/calculations"
|
3
|
+
require "active_support/core_ext/time/compatibility"
|
4
|
+
require "active_support/core_ext/time/conversions"
|
5
|
+
require "active_support/core_ext/time/zones"
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require "active_support/duration"
|
2
|
+
require "active_support/core_ext/time/conversions"
|
3
|
+
require "active_support/time_with_zone"
|
4
|
+
require "active_support/core_ext/time/zones"
|
5
|
+
require "active_support/core_ext/date_and_time/calculations"
|
6
|
+
require "active_support/core_ext/date/calculations"
|
7
7
|
|
8
8
|
class Time
|
9
9
|
include DateAndTime::Calculations
|
@@ -61,7 +61,7 @@ class Time
|
|
61
61
|
# Time.new(2012, 8, 29, 12, 34, 56).seconds_since_midnight # => 45296.0
|
62
62
|
# Time.new(2012, 8, 29, 23, 59, 59).seconds_since_midnight # => 86399.0
|
63
63
|
def seconds_since_midnight
|
64
|
-
to_i - change(:
|
64
|
+
to_i - change(hour: 0).to_i + (usec / 1.0e+6)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Returns the number of seconds until 23:59:59.
|
@@ -104,7 +104,7 @@ class Time
|
|
104
104
|
raise ArgumentError, "Can't change both :nsec and :usec at the same time: #{options.inspect}" if options[:usec]
|
105
105
|
new_usec = Rational(new_nsec, 1000)
|
106
106
|
else
|
107
|
-
new_usec
|
107
|
+
new_usec = options.fetch(:usec, (options[:hour] || options[:min] || options[:sec]) ? 0 : Rational(nsec, 1000))
|
108
108
|
end
|
109
109
|
|
110
110
|
if utc?
|
@@ -112,7 +112,7 @@ class Time
|
|
112
112
|
elsif zone
|
113
113
|
::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
|
114
114
|
else
|
115
|
-
raise ArgumentError,
|
115
|
+
raise ArgumentError, "argument out of range" if new_usec >= 1000000
|
116
116
|
::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec + (new_usec.to_r / 1000000), utc_offset)
|
117
117
|
end
|
118
118
|
end
|
@@ -141,7 +141,7 @@ class Time
|
|
141
141
|
|
142
142
|
d = to_date.advance(options)
|
143
143
|
d = d.gregorian if d.julian?
|
144
|
-
time_advanced_by_date = change(:
|
144
|
+
time_advanced_by_date = change(year: d.year, month: d.month, day: d.day)
|
145
145
|
seconds_to_advance = \
|
146
146
|
options.fetch(:seconds, 0) +
|
147
147
|
options.fetch(:minutes, 0) * 60 +
|
@@ -169,7 +169,7 @@ class Time
|
|
169
169
|
|
170
170
|
# Returns a new Time representing the start of the day (0:00)
|
171
171
|
def beginning_of_day
|
172
|
-
change(:
|
172
|
+
change(hour: 0)
|
173
173
|
end
|
174
174
|
alias :midnight :beginning_of_day
|
175
175
|
alias :at_midnight :beginning_of_day
|
@@ -177,7 +177,7 @@ class Time
|
|
177
177
|
|
178
178
|
# Returns a new Time representing the middle of the day (12:00)
|
179
179
|
def middle_of_day
|
180
|
-
change(:
|
180
|
+
change(hour: 12)
|
181
181
|
end
|
182
182
|
alias :midday :middle_of_day
|
183
183
|
alias :noon :middle_of_day
|
@@ -188,50 +188,45 @@ class Time
|
|
188
188
|
# Returns a new Time representing the end of the day, 23:59:59.999999
|
189
189
|
def end_of_day
|
190
190
|
change(
|
191
|
-
:
|
192
|
-
:
|
193
|
-
:
|
194
|
-
:
|
191
|
+
hour: 23,
|
192
|
+
min: 59,
|
193
|
+
sec: 59,
|
194
|
+
usec: Rational(999999999, 1000)
|
195
195
|
)
|
196
196
|
end
|
197
197
|
alias :at_end_of_day :end_of_day
|
198
198
|
|
199
199
|
# Returns a new Time representing the start of the hour (x:00)
|
200
200
|
def beginning_of_hour
|
201
|
-
change(:
|
201
|
+
change(min: 0)
|
202
202
|
end
|
203
203
|
alias :at_beginning_of_hour :beginning_of_hour
|
204
204
|
|
205
205
|
# Returns a new Time representing the end of the hour, x:59:59.999999
|
206
206
|
def end_of_hour
|
207
207
|
change(
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
208
|
+
min: 59,
|
209
|
+
sec: 59,
|
210
|
+
usec: Rational(999999999, 1000)
|
211
211
|
)
|
212
212
|
end
|
213
213
|
alias :at_end_of_hour :end_of_hour
|
214
214
|
|
215
215
|
# Returns a new Time representing the start of the minute (x:xx:00)
|
216
216
|
def beginning_of_minute
|
217
|
-
change(:
|
217
|
+
change(sec: 0)
|
218
218
|
end
|
219
219
|
alias :at_beginning_of_minute :beginning_of_minute
|
220
220
|
|
221
221
|
# Returns a new Time representing the end of the minute, x:xx:59.999999
|
222
222
|
def end_of_minute
|
223
223
|
change(
|
224
|
-
:
|
225
|
-
:
|
224
|
+
sec: 59,
|
225
|
+
usec: Rational(999999999, 1000)
|
226
226
|
)
|
227
227
|
end
|
228
228
|
alias :at_end_of_minute :end_of_minute
|
229
229
|
|
230
|
-
# Returns a Range representing the whole day of the current time.
|
231
|
-
def all_day
|
232
|
-
beginning_of_day..end_of_day
|
233
|
-
end
|
234
|
-
|
235
230
|
def plus_with_duration(other) #:nodoc:
|
236
231
|
if ActiveSupport::Duration === other
|
237
232
|
other.since(self)
|
@@ -286,5 +281,4 @@ class Time
|
|
286
281
|
end
|
287
282
|
alias_method :eql_without_coercion, :eql?
|
288
283
|
alias_method :eql?, :eql_with_coercion
|
289
|
-
|
290
284
|
end
|
@@ -1,14 +1,5 @@
|
|
1
1
|
require "active_support/core_ext/date_and_time/compatibility"
|
2
|
-
require "active_support/core_ext/module/remove_method"
|
3
2
|
|
4
3
|
class Time
|
5
|
-
|
6
|
-
|
7
|
-
remove_possible_method :to_time
|
8
|
-
|
9
|
-
# Either return +self+ or the time in the local system timezone depending
|
10
|
-
# on the setting of +ActiveSupport.to_time_preserves_timezone+.
|
11
|
-
def to_time
|
12
|
-
preserve_timezone ? self : getlocal
|
13
|
-
end
|
4
|
+
prepend DateAndTime::Compatibility
|
14
5
|
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_support/inflector/methods"
|
2
|
+
require "active_support/values/time_zone"
|
3
3
|
|
4
4
|
class Time
|
5
5
|
DATE_FORMATS = {
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
6
|
+
db: "%Y-%m-%d %H:%M:%S",
|
7
|
+
number: "%Y%m%d%H%M%S",
|
8
|
+
nsec: "%Y%m%d%H%M%S%9N",
|
9
|
+
usec: "%Y%m%d%H%M%S%6N",
|
10
|
+
time: "%H:%M",
|
11
|
+
short: "%d %b %H:%M",
|
12
|
+
long: "%B %d, %Y %H:%M",
|
13
|
+
long_ordinal: lambda { |time|
|
14
14
|
day_format = ActiveSupport::Inflector.ordinalize(time.day)
|
15
15
|
time.strftime("%B #{day_format}, %Y %H:%M")
|
16
16
|
},
|
17
|
-
:
|
17
|
+
rfc822: lambda { |time|
|
18
18
|
offset_format = time.formatted_offset(false)
|
19
19
|
time.strftime("%a, %d %b %Y %H:%M:%S #{offset_format}")
|
20
20
|
},
|
21
|
-
:
|
21
|
+
iso8601: lambda { |time| time.iso8601 }
|
22
22
|
}
|
23
23
|
|
24
24
|
# Converts to a formatted string. See DATE_FORMATS for built-in formats.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "active_support/time_with_zone"
|
2
|
+
require "active_support/core_ext/time/acts_like"
|
3
|
+
require "active_support/core_ext/date_and_time/zones"
|
4
4
|
|
5
5
|
class Time
|
6
6
|
include DateAndTime::Zones
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "uri"
|
2
2
|
str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
|
3
3
|
parser = URI::Parser.new
|
4
4
|
|
@@ -10,7 +10,7 @@ unless str == parser.unescape(parser.escape(str))
|
|
10
10
|
# YK: My initial experiments say yes, but let's be sure please
|
11
11
|
enc = str.encoding
|
12
12
|
enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
|
13
|
-
str.gsub(escaped) { |match| [match[1, 2].hex].pack(
|
13
|
+
str.gsub(escaped) { |match| [match[1, 2].hex].pack("C") }.force_encoding(enc)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,19 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require 'active_support/core_ext/string/starts_ends_with'
|
1
|
+
require "set"
|
2
|
+
require "thread"
|
3
|
+
require "concurrent/map"
|
4
|
+
require "pathname"
|
5
|
+
require "active_support/core_ext/module/aliasing"
|
6
|
+
require "active_support/core_ext/module/attribute_accessors"
|
7
|
+
require "active_support/core_ext/module/introspection"
|
8
|
+
require "active_support/core_ext/module/anonymous"
|
9
|
+
require "active_support/core_ext/object/blank"
|
10
|
+
require "active_support/core_ext/kernel/reporting"
|
11
|
+
require "active_support/core_ext/load_error"
|
12
|
+
require "active_support/core_ext/name_error"
|
13
|
+
require "active_support/core_ext/string/starts_ends_with"
|
15
14
|
require "active_support/dependencies/interlock"
|
16
|
-
require
|
15
|
+
require "active_support/inflector"
|
17
16
|
|
18
17
|
module ActiveSupport #:nodoc:
|
19
18
|
module Dependencies #:nodoc:
|
@@ -64,7 +63,7 @@ module ActiveSupport #:nodoc:
|
|
64
63
|
|
65
64
|
# Should we load files or require them?
|
66
65
|
mattr_accessor :mechanism
|
67
|
-
self.mechanism = ENV[
|
66
|
+
self.mechanism = ENV["NO_RELOAD"] ? :require : :load
|
68
67
|
|
69
68
|
# The set of directories from which we may automatically load files. Files
|
70
69
|
# under these directories will be reloaded on each request in development mode,
|
@@ -108,7 +107,7 @@ module ActiveSupport #:nodoc:
|
|
108
107
|
|
109
108
|
def initialize
|
110
109
|
@watching = []
|
111
|
-
@stack = Hash.new { |h,k| h[k] = [] }
|
110
|
+
@stack = Hash.new { |h, k| h[k] = [] }
|
112
111
|
end
|
113
112
|
|
114
113
|
def each(&block)
|
@@ -170,9 +169,9 @@ module ActiveSupport #:nodoc:
|
|
170
169
|
end
|
171
170
|
|
172
171
|
private
|
173
|
-
|
174
|
-
|
175
|
-
|
172
|
+
def pop_modules(modules)
|
173
|
+
modules.each { |mod| @stack[mod].pop }
|
174
|
+
end
|
176
175
|
end
|
177
176
|
|
178
177
|
# An internal stack used to record which constants are loaded by any block.
|
@@ -243,7 +242,7 @@ module ActiveSupport #:nodoc:
|
|
243
242
|
# resolution deterministic for constants with the same relative name in
|
244
243
|
# different namespaces whose evaluation would depend on load order
|
245
244
|
# otherwise.
|
246
|
-
def require_dependency(file_name, message = "No such file to load -- %s")
|
245
|
+
def require_dependency(file_name, message = "No such file to load -- %s.rb")
|
247
246
|
file_name = file_name.to_path if file_name.respond_to?(:to_path)
|
248
247
|
unless file_name.is_a?(String)
|
249
248
|
raise ArgumentError, "the file name must either be a String or implement #to_path -- you passed #{file_name.inspect}"
|
@@ -282,17 +281,17 @@ module ActiveSupport #:nodoc:
|
|
282
281
|
|
283
282
|
private
|
284
283
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
284
|
+
def load(file, wrap = false)
|
285
|
+
result = false
|
286
|
+
load_dependency(file) { result = super }
|
287
|
+
result
|
288
|
+
end
|
290
289
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
290
|
+
def require(file)
|
291
|
+
result = false
|
292
|
+
load_dependency(file) { result = super }
|
293
|
+
result
|
294
|
+
end
|
296
295
|
end
|
297
296
|
|
298
297
|
# Exception file-blaming.
|
@@ -371,7 +370,7 @@ module ActiveSupport #:nodoc:
|
|
371
370
|
load_args = ["#{file_name}.rb"]
|
372
371
|
load_args << const_path unless const_path.nil?
|
373
372
|
|
374
|
-
if !warnings_on_first_load
|
373
|
+
if !warnings_on_first_load || history.include?(expanded)
|
375
374
|
result = load_file(*load_args)
|
376
375
|
else
|
377
376
|
enable_warnings { result = load_file(*load_args) }
|
@@ -457,7 +456,6 @@ module ActiveSupport #:nodoc:
|
|
457
456
|
mod = Module.new
|
458
457
|
into.const_set const_name, mod
|
459
458
|
autoloaded_constants << qualified_name unless autoload_once_paths.include?(base_path)
|
460
|
-
autoloaded_constants.uniq!
|
461
459
|
mod
|
462
460
|
end
|
463
461
|
|
@@ -504,7 +502,7 @@ module ActiveSupport #:nodoc:
|
|
504
502
|
|
505
503
|
if file_path
|
506
504
|
expanded = File.expand_path(file_path)
|
507
|
-
expanded.sub!(/\.rb\z/,
|
505
|
+
expanded.sub!(/\.rb\z/, "".freeze)
|
508
506
|
|
509
507
|
if loading.include?(expanded)
|
510
508
|
raise "Circular dependency detected while autoloading constant #{qualified_name}"
|
@@ -548,7 +546,7 @@ module ActiveSupport #:nodoc:
|
|
548
546
|
end
|
549
547
|
|
550
548
|
name_error = NameError.new("uninitialized constant #{qualified_name}", const_name)
|
551
|
-
name_error.set_backtrace(caller.reject {|l| l.starts_with? __FILE__ })
|
549
|
+
name_error.set_backtrace(caller.reject { |l| l.starts_with? __FILE__ })
|
552
550
|
raise name_error
|
553
551
|
end
|
554
552
|
|
@@ -592,7 +590,7 @@ module ActiveSupport #:nodoc:
|
|
592
590
|
|
593
591
|
def store(klass)
|
594
592
|
return self unless klass.respond_to?(:name)
|
595
|
-
raise(ArgumentError,
|
593
|
+
raise(ArgumentError, "anonymous classes cannot be cached") if klass.name.empty?
|
596
594
|
@store[klass.name] = klass
|
597
595
|
self
|
598
596
|
end
|
@@ -676,29 +674,29 @@ module ActiveSupport #:nodoc:
|
|
676
674
|
# A module, class, symbol, or string may be provided.
|
677
675
|
def to_constant_name(desc) #:nodoc:
|
678
676
|
case desc
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
677
|
+
when String then desc.sub(/^::/, "")
|
678
|
+
when Symbol then desc.to_s
|
679
|
+
when Module
|
680
|
+
desc.name ||
|
681
|
+
raise(ArgumentError, "Anonymous modules have no name to be referenced by")
|
684
682
|
else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}"
|
685
683
|
end
|
686
684
|
end
|
687
685
|
|
688
686
|
def remove_constant(const) #:nodoc:
|
689
687
|
# Normalize ::Foo, ::Object::Foo, Object::Foo, Object::Object::Foo, etc. as Foo.
|
690
|
-
normalized = const.to_s.sub(/\A::/,
|
691
|
-
normalized.sub!(/\A(Object::)+/,
|
688
|
+
normalized = const.to_s.sub(/\A::/, "")
|
689
|
+
normalized.sub!(/\A(Object::)+/, "")
|
692
690
|
|
693
|
-
constants = normalized.split(
|
691
|
+
constants = normalized.split("::")
|
694
692
|
to_remove = constants.pop
|
695
693
|
|
696
694
|
# Remove the file path from the loaded list.
|
697
695
|
file_path = search_for_file(const.underscore)
|
698
696
|
if file_path
|
699
697
|
expanded = File.expand_path(file_path)
|
700
|
-
expanded.sub!(/\.rb\z/,
|
701
|
-
|
698
|
+
expanded.sub!(/\.rb\z/, "")
|
699
|
+
loaded.delete(expanded)
|
702
700
|
end
|
703
701
|
|
704
702
|
if constants.empty?
|
@@ -711,7 +709,7 @@ module ActiveSupport #:nodoc:
|
|
711
709
|
# here than require the caller to be clever. We check the parent
|
712
710
|
# rather than the very const argument because we do not want to
|
713
711
|
# trigger Kernel#autoloads, see the comment below.
|
714
|
-
parent_name = constants.join(
|
712
|
+
parent_name = constants.join("::")
|
715
713
|
return unless qualified_const_defined?(parent_name)
|
716
714
|
parent = constantize(parent_name)
|
717
715
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "singleton"
|
2
2
|
|
3
3
|
module ActiveSupport
|
4
4
|
# \Deprecation specifies the API used by Rails to deprecate methods, instance
|
@@ -12,12 +12,12 @@ module ActiveSupport
|
|
12
12
|
# a circular require warning for active_support/deprecation.rb.
|
13
13
|
#
|
14
14
|
# So, we define the constant first, and load dependencies later.
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
15
|
+
require "active_support/deprecation/instance_delegator"
|
16
|
+
require "active_support/deprecation/behaviors"
|
17
|
+
require "active_support/deprecation/reporting"
|
18
|
+
require "active_support/deprecation/method_wrappers"
|
19
|
+
require "active_support/deprecation/proxy_wrappers"
|
20
|
+
require "active_support/core_ext/module/deprecation"
|
21
21
|
|
22
22
|
include Singleton
|
23
23
|
include InstanceDelegator
|
@@ -32,7 +32,7 @@ module ActiveSupport
|
|
32
32
|
# and the second is a library name
|
33
33
|
#
|
34
34
|
# ActiveSupport::Deprecation.new('2.0', 'MyLibrary')
|
35
|
-
def initialize(deprecation_horizon =
|
35
|
+
def initialize(deprecation_horizon = "5.2", gem_name = "Rails")
|
36
36
|
self.gem_name = gem_name
|
37
37
|
self.deprecation_horizon = deprecation_horizon
|
38
38
|
# By default, warnings are not silenced and debugging is off.
|