activesupport 4.2.11.3 → 5.0.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 +309 -485
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -3
- data/lib/active_support.rb +8 -15
- data/lib/active_support/array_inquirer.rb +44 -0
- data/lib/active_support/backtrace_cleaner.rb +1 -1
- data/lib/active_support/cache.rb +59 -72
- data/lib/active_support/cache/file_store.rb +27 -19
- data/lib/active_support/cache/mem_cache_store.rb +71 -60
- data/lib/active_support/cache/memory_store.rb +16 -21
- data/lib/active_support/cache/null_store.rb +1 -4
- data/lib/active_support/cache/strategy/local_cache.rb +31 -20
- data/lib/active_support/callbacks.rb +107 -111
- data/lib/active_support/concern.rb +1 -1
- data/lib/active_support/concurrency/latch.rb +7 -15
- data/lib/active_support/concurrency/share_lock.rb +142 -0
- data/lib/active_support/configurable.rb +1 -0
- data/lib/active_support/core_ext.rb +2 -1
- data/lib/active_support/core_ext/array.rb +1 -0
- data/lib/active_support/core_ext/array/access.rb +13 -1
- data/lib/active_support/core_ext/array/conversions.rb +6 -4
- data/lib/active_support/core_ext/array/inquiry.rb +17 -0
- data/lib/active_support/core_ext/array/wrap.rb +5 -4
- data/lib/active_support/core_ext/big_decimal/conversions.rb +8 -10
- data/lib/active_support/core_ext/class.rb +0 -1
- data/lib/active_support/core_ext/class/attribute.rb +10 -9
- data/lib/active_support/core_ext/class/subclasses.rb +5 -2
- data/lib/active_support/core_ext/date.rb +1 -1
- data/lib/active_support/core_ext/date/blank.rb +12 -0
- data/lib/active_support/core_ext/date/calculations.rb +1 -1
- data/lib/active_support/core_ext/date/conversions.rb +3 -3
- data/lib/active_support/core_ext/date_and_time/calculations.rb +93 -27
- data/lib/active_support/core_ext/date_and_time/zones.rb +1 -2
- data/lib/active_support/core_ext/date_time.rb +1 -1
- data/lib/active_support/core_ext/date_time/blank.rb +12 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +7 -23
- data/lib/active_support/core_ext/date_time/conversions.rb +2 -0
- data/lib/active_support/core_ext/enumerable.rb +27 -17
- data/lib/active_support/core_ext/file/atomic.rb +30 -25
- data/lib/active_support/core_ext/hash/compact.rb +15 -19
- data/lib/active_support/core_ext/hash/conversions.rb +21 -2
- data/lib/active_support/core_ext/hash/deep_merge.rb +1 -1
- data/lib/active_support/core_ext/hash/except.rb +9 -8
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -1
- data/lib/active_support/core_ext/hash/keys.rb +22 -18
- data/lib/active_support/core_ext/hash/slice.rb +1 -1
- data/lib/active_support/core_ext/hash/transform_values.rb +13 -7
- data/lib/active_support/core_ext/integer/time.rb +1 -1
- data/lib/active_support/core_ext/kernel.rb +0 -1
- data/lib/active_support/core_ext/kernel/debugger.rb +3 -10
- data/lib/active_support/core_ext/kernel/reporting.rb +0 -84
- data/lib/active_support/core_ext/load_error.rb +4 -2
- data/lib/active_support/core_ext/marshal.rb +8 -13
- data/lib/active_support/core_ext/module.rb +1 -0
- data/lib/active_support/core_ext/module/aliasing.rb +6 -1
- data/lib/active_support/core_ext/module/anonymous.rb +10 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -5
- data/lib/active_support/core_ext/module/attribute_accessors.rb +7 -7
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +141 -0
- data/lib/active_support/core_ext/module/concerning.rb +4 -4
- data/lib/active_support/core_ext/module/delegation.rb +7 -14
- data/lib/active_support/core_ext/module/method_transplanting.rb +3 -13
- data/lib/active_support/core_ext/module/qualified_const.rb +30 -12
- data/lib/active_support/core_ext/module/remove_method.rb +23 -0
- data/lib/active_support/core_ext/name_error.rb +15 -2
- data/lib/active_support/core_ext/numeric.rb +1 -0
- data/lib/active_support/core_ext/numeric/bytes.rb +20 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +12 -23
- data/lib/active_support/core_ext/numeric/inquiry.rb +26 -0
- data/lib/active_support/core_ext/numeric/time.rb +20 -0
- data/lib/active_support/core_ext/object.rb +0 -1
- data/lib/active_support/core_ext/object/blank.rb +11 -2
- data/lib/active_support/core_ext/object/deep_dup.rb +10 -3
- data/lib/active_support/core_ext/object/duplicable.rb +39 -70
- data/lib/active_support/core_ext/object/inclusion.rb +2 -2
- data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +9 -7
- data/lib/active_support/core_ext/object/to_query.rb +1 -1
- data/lib/active_support/core_ext/object/try.rb +67 -21
- data/lib/active_support/core_ext/object/with_options.rb +1 -1
- data/lib/active_support/core_ext/range/conversions.rb +18 -6
- data/lib/active_support/core_ext/range/each.rb +16 -18
- data/lib/active_support/core_ext/range/include_range.rb +20 -20
- data/lib/active_support/core_ext/securerandom.rb +23 -0
- data/lib/active_support/core_ext/string/access.rb +1 -1
- data/lib/active_support/core_ext/string/behavior.rb +1 -1
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/filters.rb +1 -2
- data/lib/active_support/core_ext/string/inflections.rb +23 -5
- data/lib/active_support/core_ext/string/multibyte.rb +11 -7
- data/lib/active_support/core_ext/string/output_safety.rb +8 -9
- data/lib/active_support/core_ext/string/strip.rb +3 -6
- data/lib/active_support/core_ext/struct.rb +3 -6
- data/lib/active_support/core_ext/time.rb +0 -2
- data/lib/active_support/core_ext/time/calculations.rb +18 -16
- data/lib/active_support/core_ext/time/conversions.rb +4 -2
- data/lib/active_support/core_ext/time/marshal.rb +2 -29
- data/lib/active_support/core_ext/time/zones.rb +19 -3
- data/lib/active_support/core_ext/uri.rb +1 -3
- data/lib/active_support/dependencies.rb +79 -44
- data/lib/active_support/dependencies/interlock.rb +47 -0
- data/lib/active_support/deprecation/behaviors.rb +12 -0
- data/lib/active_support/deprecation/method_wrappers.rb +42 -16
- data/lib/active_support/deprecation/proxy_wrappers.rb +47 -24
- data/lib/active_support/deprecation/reporting.rb +13 -2
- data/lib/active_support/duration.rb +5 -8
- data/lib/active_support/evented_file_update_checker.rb +150 -0
- data/lib/active_support/file_update_checker.rb +1 -1
- data/lib/active_support/gem_version.rb +5 -5
- data/lib/active_support/hash_with_indifferent_access.rb +15 -17
- data/lib/active_support/i18n_railtie.rb +25 -4
- data/lib/active_support/inflector/inflections.rb +36 -5
- data/lib/active_support/inflector/methods.rb +87 -89
- data/lib/active_support/inflector/transliterate.rb +36 -21
- data/lib/active_support/json/decoding.rb +2 -8
- data/lib/active_support/json/encoding.rb +0 -50
- data/lib/active_support/key_generator.rb +4 -4
- data/lib/active_support/log_subscriber.rb +1 -1
- data/lib/active_support/log_subscriber/test_helper.rb +3 -3
- data/lib/active_support/logger.rb +4 -52
- data/lib/active_support/logger_silence.rb +3 -5
- data/lib/active_support/message_encryptor.rb +4 -11
- data/lib/active_support/message_verifier.rb +64 -8
- data/lib/active_support/multibyte/chars.rb +12 -3
- data/lib/active_support/multibyte/unicode.rb +6 -8
- data/lib/active_support/notifications.rb +2 -2
- data/lib/active_support/notifications/fanout.rb +5 -5
- data/lib/active_support/notifications/instrumenter.rb +19 -2
- data/lib/active_support/number_helper.rb +21 -15
- data/lib/active_support/number_helper/number_to_currency_converter.rb +4 -4
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +7 -2
- data/lib/active_support/number_helper/number_to_human_converter.rb +6 -4
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +5 -1
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +28 -25
- data/lib/active_support/ordered_options.rb +15 -1
- data/lib/active_support/per_thread_registry.rb +3 -0
- data/lib/active_support/rails.rb +2 -2
- data/lib/active_support/railtie.rb +6 -1
- data/lib/active_support/rescuable.rb +4 -4
- data/lib/active_support/security_utils.rb +0 -7
- data/lib/active_support/string_inquirer.rb +1 -1
- data/lib/active_support/subscriber.rb +5 -10
- data/lib/active_support/tagged_logging.rb +3 -1
- data/lib/active_support/test_case.rb +13 -25
- data/lib/active_support/testing/assertions.rb +15 -13
- data/lib/active_support/testing/autorun.rb +8 -1
- data/lib/active_support/testing/composite_filter.rb +54 -0
- data/lib/active_support/testing/deprecation.rb +9 -8
- data/lib/active_support/testing/file_fixtures.rb +34 -0
- data/lib/active_support/testing/isolation.rb +22 -8
- data/lib/active_support/testing/method_call_assertions.rb +41 -0
- data/lib/active_support/testing/stream.rb +42 -0
- data/lib/active_support/testing/time_helpers.rb +6 -6
- data/lib/active_support/time_with_zone.rb +135 -53
- data/lib/active_support/values/time_zone.rb +80 -46
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/xml_mini.rb +15 -30
- data/lib/active_support/xml_mini/jdom.rb +1 -1
- data/lib/active_support/xml_mini/libxml.rb +5 -3
- data/lib/active_support/xml_mini/libxmlsax.rb +4 -1
- data/lib/active_support/xml_mini/nokogiri.rb +5 -3
- data/lib/active_support/xml_mini/nokogirisax.rb +3 -1
- data/lib/active_support/xml_mini/rexml.rb +3 -1
- metadata +57 -21
- data/lib/active_support/core_ext/big_decimal/yaml_conversions.rb +0 -16
- data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -45
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +0 -15
- data/lib/active_support/core_ext/date_time/compatibility.rb +0 -16
- data/lib/active_support/core_ext/object/itself.rb +0 -15
- data/lib/active_support/core_ext/thread.rb +0 -86
- data/lib/active_support/core_ext/time/compatibility.rb +0 -14
- data/lib/active_support/logger_thread_safe_level.rb +0 -32
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'tzinfo'
|
2
|
-
require '
|
2
|
+
require 'concurrent/map'
|
3
3
|
require 'active_support/core_ext/object/blank'
|
4
4
|
require 'active_support/core_ext/object/try'
|
5
5
|
|
@@ -23,15 +23,9 @@ module ActiveSupport
|
|
23
23
|
# config.time_zone = 'Eastern Time (US & Canada)'
|
24
24
|
# end
|
25
25
|
#
|
26
|
-
# Time.zone # => #<TimeZone:0x514834...>
|
26
|
+
# Time.zone # => #<ActiveSupport::TimeZone:0x514834...>
|
27
27
|
# Time.zone.name # => "Eastern Time (US & Canada)"
|
28
28
|
# Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00
|
29
|
-
#
|
30
|
-
# The version of TZInfo bundled with Active Support only includes the
|
31
|
-
# definitions necessary to support the zones defined by the TimeZone class.
|
32
|
-
# If you need to use zones that aren't defined by TimeZone, you'll need to
|
33
|
-
# install the TZInfo gem (if a recent version of the gem is installed locally,
|
34
|
-
# this will be used instead of the bundled version.)
|
35
29
|
class TimeZone
|
36
30
|
# Keys are Rails TimeZone names, values are TZInfo identifiers.
|
37
31
|
MAPPING = {
|
@@ -92,7 +86,8 @@ module ActiveSupport
|
|
92
86
|
"Paris" => "Europe/Paris",
|
93
87
|
"Amsterdam" => "Europe/Amsterdam",
|
94
88
|
"Berlin" => "Europe/Berlin",
|
95
|
-
"Bern" => "Europe/
|
89
|
+
"Bern" => "Europe/Zurich",
|
90
|
+
"Zurich" => "Europe/Zurich",
|
96
91
|
"Rome" => "Europe/Rome",
|
97
92
|
"Stockholm" => "Europe/Stockholm",
|
98
93
|
"Vienna" => "Europe/Vienna",
|
@@ -189,13 +184,13 @@ module ActiveSupport
|
|
189
184
|
UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
|
190
185
|
UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.tr(':', '')
|
191
186
|
|
192
|
-
@lazy_zones_map =
|
187
|
+
@lazy_zones_map = Concurrent::Map.new
|
193
188
|
|
194
189
|
class << self
|
195
190
|
# Assumes self represents an offset from UTC in seconds (as returned from
|
196
191
|
# Time#utc_offset) and turns this into an +HH:MM formatted string.
|
197
192
|
#
|
198
|
-
# TimeZone.seconds_to_utc_offset(-21_600) # => "-06:00"
|
193
|
+
# ActiveSupport::TimeZone.seconds_to_utc_offset(-21_600) # => "-06:00"
|
199
194
|
def seconds_to_utc_offset(seconds, colon = true)
|
200
195
|
format = colon ? UTC_OFFSET_WITH_COLON : UTC_OFFSET_WITHOUT_COLON
|
201
196
|
sign = (seconds < 0 ? '-' : '+')
|
@@ -205,7 +200,7 @@ module ActiveSupport
|
|
205
200
|
end
|
206
201
|
|
207
202
|
def find_tzinfo(name)
|
208
|
-
TZInfo::
|
203
|
+
TZInfo::Timezone.new(MAPPING[name] || name)
|
209
204
|
end
|
210
205
|
|
211
206
|
alias_method :create, :new
|
@@ -224,13 +219,6 @@ module ActiveSupport
|
|
224
219
|
@zones ||= zones_map.values.sort
|
225
220
|
end
|
226
221
|
|
227
|
-
def zones_map #:nodoc:
|
228
|
-
@zones_map ||= begin
|
229
|
-
MAPPING.each_key {|place| self[place]} # load all the zones
|
230
|
-
@lazy_zones_map
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
222
|
# Locate a specific time zone object. If the argument is a string, it
|
235
223
|
# is interpreted to mean the name of the timezone to locate. If it is a
|
236
224
|
# numeric value it is either the hour offset, or the second offset, of the
|
@@ -240,7 +228,7 @@ module ActiveSupport
|
|
240
228
|
case arg
|
241
229
|
when String
|
242
230
|
begin
|
243
|
-
@lazy_zones_map[arg] ||= create(arg)
|
231
|
+
@lazy_zones_map[arg] ||= create(arg)
|
244
232
|
rescue TZInfo::InvalidTimezoneIdentifier
|
245
233
|
nil
|
246
234
|
end
|
@@ -257,6 +245,14 @@ module ActiveSupport
|
|
257
245
|
def us_zones
|
258
246
|
@us_zones ||= all.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
|
259
247
|
end
|
248
|
+
|
249
|
+
private
|
250
|
+
def zones_map
|
251
|
+
@zones_map ||= begin
|
252
|
+
MAPPING.each_key {|place| self[place]} # load all the zones
|
253
|
+
@lazy_zones_map
|
254
|
+
end
|
255
|
+
end
|
260
256
|
end
|
261
257
|
|
262
258
|
include Comparable
|
@@ -271,10 +267,7 @@ module ActiveSupport
|
|
271
267
|
@name = name
|
272
268
|
@utc_offset = utc_offset
|
273
269
|
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
|
274
|
-
|
275
|
-
|
276
|
-
def init_with(coder) #:nodoc:
|
277
|
-
initialize(coder['name'])
|
270
|
+
@current_period = nil
|
278
271
|
end
|
279
272
|
|
280
273
|
# Returns the offset of this time zone from UTC in seconds.
|
@@ -282,12 +275,17 @@ module ActiveSupport
|
|
282
275
|
if @utc_offset
|
283
276
|
@utc_offset
|
284
277
|
else
|
285
|
-
tzinfo.current_period
|
278
|
+
@current_period ||= tzinfo.current_period if tzinfo
|
279
|
+
@current_period.utc_offset if @current_period
|
286
280
|
end
|
287
281
|
end
|
288
282
|
|
289
|
-
# Returns
|
290
|
-
#
|
283
|
+
# Returns a formatted string of the offset from UTC, or an alternative
|
284
|
+
# string if the time zone is already UTC.
|
285
|
+
#
|
286
|
+
# zone = ActiveSupport::TimeZone['Central Time (US & Canada)']
|
287
|
+
# zone.formatted_offset # => "-06:00"
|
288
|
+
# zone.formatted_offset(false) # => "-0600"
|
291
289
|
def formatted_offset(colon=true, alternate_utc_string = nil)
|
292
290
|
utc_offset == 0 && alternate_utc_string || self.class.seconds_to_utc_offset(utc_offset, colon)
|
293
291
|
end
|
@@ -349,24 +347,31 @@ module ActiveSupport
|
|
349
347
|
#
|
350
348
|
# Time.zone.parse('Mar 2000') # => Wed, 01 Mar 2000 00:00:00 HST -10:00
|
351
349
|
def parse(str, now=now())
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
350
|
+
parts_to_time(Date._parse(str, false), now)
|
351
|
+
end
|
352
|
+
|
353
|
+
# Parses +str+ according to +format+ and returns an ActiveSupport::TimeWithZone.
|
354
|
+
#
|
355
|
+
# Assumes that +str+ is a time in the time zone +self+,
|
356
|
+
# unless +format+ includes an explicit time zone.
|
357
|
+
# (This is the same behavior as +parse+.)
|
358
|
+
# In either case, the returned TimeWithZone has the timezone of +self+.
|
359
|
+
#
|
360
|
+
# Time.zone = 'Hawaii' # => "Hawaii"
|
361
|
+
# Time.zone.strptime('1999-12-31 14:00:00', '%Y-%m-%d %H:%M:%S') # => Fri, 31 Dec 1999 14:00:00 HST -10:00
|
362
|
+
#
|
363
|
+
# If upper components are missing from the string, they are supplied from
|
364
|
+
# TimeZone#now:
|
365
|
+
#
|
366
|
+
# Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00
|
367
|
+
# Time.zone.strptime('22:30:00', '%H:%M:%S') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
|
368
|
+
#
|
369
|
+
# However, if the date component is not provided, but any other upper
|
370
|
+
# components are supplied, then the day of the month defaults to 1:
|
371
|
+
#
|
372
|
+
# Time.zone.strptime('Mar 2000', '%b %Y') # => Wed, 01 Mar 2000 00:00:00 HST -10:00
|
373
|
+
def strptime(str, format, now=now())
|
374
|
+
parts_to_time(DateTime._strptime(str, format), now)
|
370
375
|
end
|
371
376
|
|
372
377
|
# Returns an ActiveSupport::TimeWithZone instance representing the current
|
@@ -378,7 +383,7 @@ module ActiveSupport
|
|
378
383
|
time_now.utc.in_time_zone(self)
|
379
384
|
end
|
380
385
|
|
381
|
-
#
|
386
|
+
# Returns the current date in this time zone.
|
382
387
|
def today
|
383
388
|
tzinfo.now.to_date
|
384
389
|
end
|
@@ -422,7 +427,36 @@ module ActiveSupport
|
|
422
427
|
tzinfo.periods_for_local(time)
|
423
428
|
end
|
424
429
|
|
430
|
+
def init_with(coder) #:nodoc:
|
431
|
+
initialize(coder['name'])
|
432
|
+
end
|
433
|
+
|
434
|
+
def encode_with(coder) #:nodoc:
|
435
|
+
coder.tag ="!ruby/object:#{self.class}"
|
436
|
+
coder.map = { 'name' => tzinfo.name }
|
437
|
+
end
|
438
|
+
|
425
439
|
private
|
440
|
+
def parts_to_time(parts, now)
|
441
|
+
return if parts.empty?
|
442
|
+
|
443
|
+
time = Time.new(
|
444
|
+
parts.fetch(:year, now.year),
|
445
|
+
parts.fetch(:mon, now.month),
|
446
|
+
parts.fetch(:mday, parts[:year] || parts[:mon] ? 1 : now.day),
|
447
|
+
parts.fetch(:hour, 0),
|
448
|
+
parts.fetch(:min, 0),
|
449
|
+
parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0),
|
450
|
+
parts.fetch(:offset, 0)
|
451
|
+
)
|
452
|
+
|
453
|
+
if parts[:offset]
|
454
|
+
TimeWithZone.new(time.utc, self)
|
455
|
+
else
|
456
|
+
TimeWithZone.new(nil, self, time)
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
426
460
|
def time_now
|
427
461
|
Time.now
|
428
462
|
end
|
Binary file
|
@@ -32,25 +32,20 @@ module ActiveSupport
|
|
32
32
|
"binary" => "base64"
|
33
33
|
} unless defined?(DEFAULT_ENCODINGS)
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# No need to map these on Ruby 2.4+
|
51
|
-
TYPE_NAMES["Fixnum"] = "integer" unless 0.class == Integer
|
52
|
-
TYPE_NAMES["Bignum"] = "integer" unless 0.class == Integer
|
53
|
-
end
|
35
|
+
TYPE_NAMES = {
|
36
|
+
"Symbol" => "symbol",
|
37
|
+
"Fixnum" => "integer",
|
38
|
+
"Bignum" => "integer",
|
39
|
+
"BigDecimal" => "decimal",
|
40
|
+
"Float" => "float",
|
41
|
+
"TrueClass" => "boolean",
|
42
|
+
"FalseClass" => "boolean",
|
43
|
+
"Date" => "date",
|
44
|
+
"DateTime" => "dateTime",
|
45
|
+
"Time" => "dateTime",
|
46
|
+
"Array" => "array",
|
47
|
+
"Hash" => "hash"
|
48
|
+
} unless defined?(TYPE_NAMES)
|
54
49
|
|
55
50
|
FORMATTING = {
|
56
51
|
"symbol" => Proc.new { |symbol| symbol.to_s },
|
@@ -68,17 +63,7 @@ module ActiveSupport
|
|
68
63
|
"datetime" => Proc.new { |time| Time.xmlschema(time).utc rescue ::DateTime.parse(time).utc },
|
69
64
|
"integer" => Proc.new { |integer| integer.to_i },
|
70
65
|
"float" => Proc.new { |float| float.to_f },
|
71
|
-
"decimal" => Proc.new
|
72
|
-
if String === number
|
73
|
-
begin
|
74
|
-
BigDecimal(number)
|
75
|
-
rescue ArgumentError
|
76
|
-
BigDecimal('0')
|
77
|
-
end
|
78
|
-
else
|
79
|
-
BigDecimal(number)
|
80
|
-
end
|
81
|
-
end,
|
66
|
+
"decimal" => Proc.new { |number| BigDecimal(number) },
|
82
67
|
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.to_s.strip) },
|
83
68
|
"string" => Proc.new { |string| string.to_s },
|
84
69
|
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
|
@@ -14,9 +14,11 @@ module ActiveSupport
|
|
14
14
|
data = StringIO.new(data || '')
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
char = data.getc
|
18
|
+
if char.nil?
|
18
19
|
{}
|
19
20
|
else
|
21
|
+
data.ungetc(char)
|
20
22
|
LibXML::XML::Parser.io(data).parse.to_hash
|
21
23
|
end
|
22
24
|
end
|
@@ -73,5 +75,5 @@ module LibXML #:nodoc:
|
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
|
-
LibXML::XML::Document.
|
77
|
-
LibXML::XML::Node.
|
78
|
+
LibXML::XML::Document.include(LibXML::Conversions::Document)
|
79
|
+
LibXML::XML::Node.include(LibXML::Conversions::Node)
|
@@ -66,9 +66,12 @@ module ActiveSupport
|
|
66
66
|
data = StringIO.new(data || '')
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
char = data.getc
|
70
|
+
if char.nil?
|
70
71
|
{}
|
71
72
|
else
|
73
|
+
data.ungetc(char)
|
74
|
+
|
72
75
|
LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
|
73
76
|
parser = LibXML::XML::SaxParser.io(data)
|
74
77
|
document = self.document_class.new
|
@@ -19,9 +19,11 @@ module ActiveSupport
|
|
19
19
|
data = StringIO.new(data || '')
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
char = data.getc
|
23
|
+
if char.nil?
|
23
24
|
{}
|
24
25
|
else
|
26
|
+
data.ungetc(char)
|
25
27
|
doc = Nokogiri::XML(data)
|
26
28
|
raise doc.errors.first if doc.errors.length > 0
|
27
29
|
doc.to_hash
|
@@ -75,7 +77,7 @@ module ActiveSupport
|
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
|
-
Nokogiri::XML::Document.
|
79
|
-
Nokogiri::XML::Node.
|
80
|
+
Nokogiri::XML::Document.include(Conversions::Document)
|
81
|
+
Nokogiri::XML::Node.include(Conversions::Node)
|
80
82
|
end
|
81
83
|
end
|
@@ -72,9 +72,11 @@ module ActiveSupport
|
|
72
72
|
data = StringIO.new(data || '')
|
73
73
|
end
|
74
74
|
|
75
|
-
|
75
|
+
char = data.getc
|
76
|
+
if char.nil?
|
76
77
|
{}
|
77
78
|
else
|
79
|
+
data.ungetc(char)
|
78
80
|
document = self.document_class.new
|
79
81
|
parser = Nokogiri::XML::SAX::Parser.new(document)
|
80
82
|
parser.parse(data)
|
@@ -20,9 +20,11 @@ module ActiveSupport
|
|
20
20
|
data = StringIO.new(data || '')
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
char = data.getc
|
24
|
+
if char.nil?
|
24
25
|
{}
|
25
26
|
else
|
27
|
+
data.ungetc(char)
|
26
28
|
silence_warnings { require 'rexml/document' } unless defined?(REXML::Document)
|
27
29
|
doc = REXML::Document.new(data)
|
28
30
|
|
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: 5.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.7.7
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.7'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.7.7
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: tzinfo
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,25 +73,33 @@ dependencies:
|
|
53
73
|
- !ruby/object:Gem::Version
|
54
74
|
version: '5.1'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
76
|
+
name: concurrent-ruby
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
58
78
|
requirements:
|
59
79
|
- - "~>"
|
60
80
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 0.3.4
|
81
|
+
version: '1.0'
|
65
82
|
type: :runtime
|
66
83
|
prerelease: false
|
67
84
|
version_requirements: !ruby/object:Gem::Requirement
|
68
85
|
requirements:
|
69
86
|
- - "~>"
|
70
87
|
- !ruby/object:Gem::Version
|
71
|
-
version: '0
|
88
|
+
version: '1.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: method_source
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
72
93
|
- - ">="
|
73
94
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
75
103
|
description: A toolkit of support libraries and Ruby core extensions extracted from
|
76
104
|
the Rails framework. Rich support for multibyte strings, internationalization, time
|
77
105
|
zones, and testing.
|
@@ -85,6 +113,7 @@ files:
|
|
85
113
|
- README.rdoc
|
86
114
|
- lib/active_support.rb
|
87
115
|
- lib/active_support/all.rb
|
116
|
+
- lib/active_support/array_inquirer.rb
|
88
117
|
- lib/active_support/backtrace_cleaner.rb
|
89
118
|
- lib/active_support/benchmarkable.rb
|
90
119
|
- lib/active_support/builder.rb
|
@@ -98,6 +127,7 @@ files:
|
|
98
127
|
- lib/active_support/callbacks.rb
|
99
128
|
- lib/active_support/concern.rb
|
100
129
|
- lib/active_support/concurrency/latch.rb
|
130
|
+
- lib/active_support/concurrency/share_lock.rb
|
101
131
|
- lib/active_support/configurable.rb
|
102
132
|
- lib/active_support/core_ext.rb
|
103
133
|
- lib/active_support/core_ext/array.rb
|
@@ -105,29 +135,28 @@ files:
|
|
105
135
|
- lib/active_support/core_ext/array/conversions.rb
|
106
136
|
- lib/active_support/core_ext/array/extract_options.rb
|
107
137
|
- lib/active_support/core_ext/array/grouping.rb
|
138
|
+
- lib/active_support/core_ext/array/inquiry.rb
|
108
139
|
- lib/active_support/core_ext/array/prepend_and_append.rb
|
109
140
|
- lib/active_support/core_ext/array/wrap.rb
|
110
141
|
- lib/active_support/core_ext/benchmark.rb
|
111
142
|
- lib/active_support/core_ext/big_decimal.rb
|
112
143
|
- lib/active_support/core_ext/big_decimal/conversions.rb
|
113
|
-
- lib/active_support/core_ext/big_decimal/yaml_conversions.rb
|
114
144
|
- lib/active_support/core_ext/class.rb
|
115
145
|
- lib/active_support/core_ext/class/attribute.rb
|
116
146
|
- lib/active_support/core_ext/class/attribute_accessors.rb
|
117
|
-
- lib/active_support/core_ext/class/delegating_attributes.rb
|
118
147
|
- lib/active_support/core_ext/class/subclasses.rb
|
119
148
|
- lib/active_support/core_ext/date.rb
|
120
149
|
- lib/active_support/core_ext/date/acts_like.rb
|
150
|
+
- lib/active_support/core_ext/date/blank.rb
|
121
151
|
- lib/active_support/core_ext/date/calculations.rb
|
122
152
|
- lib/active_support/core_ext/date/conversions.rb
|
123
153
|
- lib/active_support/core_ext/date/zones.rb
|
124
154
|
- lib/active_support/core_ext/date_and_time/calculations.rb
|
125
|
-
- lib/active_support/core_ext/date_and_time/compatibility.rb
|
126
155
|
- lib/active_support/core_ext/date_and_time/zones.rb
|
127
156
|
- lib/active_support/core_ext/date_time.rb
|
128
157
|
- lib/active_support/core_ext/date_time/acts_like.rb
|
158
|
+
- lib/active_support/core_ext/date_time/blank.rb
|
129
159
|
- lib/active_support/core_ext/date_time/calculations.rb
|
130
|
-
- lib/active_support/core_ext/date_time/compatibility.rb
|
131
160
|
- lib/active_support/core_ext/date_time/conversions.rb
|
132
161
|
- lib/active_support/core_ext/date_time/zones.rb
|
133
162
|
- lib/active_support/core_ext/digest/uuid.rb
|
@@ -161,6 +190,7 @@ files:
|
|
161
190
|
- lib/active_support/core_ext/module/anonymous.rb
|
162
191
|
- lib/active_support/core_ext/module/attr_internal.rb
|
163
192
|
- lib/active_support/core_ext/module/attribute_accessors.rb
|
193
|
+
- lib/active_support/core_ext/module/attribute_accessors_per_thread.rb
|
164
194
|
- lib/active_support/core_ext/module/concerning.rb
|
165
195
|
- lib/active_support/core_ext/module/delegation.rb
|
166
196
|
- lib/active_support/core_ext/module/deprecation.rb
|
@@ -173,6 +203,7 @@ files:
|
|
173
203
|
- lib/active_support/core_ext/numeric.rb
|
174
204
|
- lib/active_support/core_ext/numeric/bytes.rb
|
175
205
|
- lib/active_support/core_ext/numeric/conversions.rb
|
206
|
+
- lib/active_support/core_ext/numeric/inquiry.rb
|
176
207
|
- lib/active_support/core_ext/numeric/time.rb
|
177
208
|
- lib/active_support/core_ext/object.rb
|
178
209
|
- lib/active_support/core_ext/object/acts_like.rb
|
@@ -182,7 +213,6 @@ files:
|
|
182
213
|
- lib/active_support/core_ext/object/duplicable.rb
|
183
214
|
- lib/active_support/core_ext/object/inclusion.rb
|
184
215
|
- lib/active_support/core_ext/object/instance_variables.rb
|
185
|
-
- lib/active_support/core_ext/object/itself.rb
|
186
216
|
- lib/active_support/core_ext/object/json.rb
|
187
217
|
- lib/active_support/core_ext/object/to_param.rb
|
188
218
|
- lib/active_support/core_ext/object/to_query.rb
|
@@ -194,6 +224,7 @@ files:
|
|
194
224
|
- lib/active_support/core_ext/range/include_range.rb
|
195
225
|
- lib/active_support/core_ext/range/overlaps.rb
|
196
226
|
- lib/active_support/core_ext/regexp.rb
|
227
|
+
- lib/active_support/core_ext/securerandom.rb
|
197
228
|
- lib/active_support/core_ext/string.rb
|
198
229
|
- lib/active_support/core_ext/string/access.rb
|
199
230
|
- lib/active_support/core_ext/string/behavior.rb
|
@@ -209,17 +240,16 @@ files:
|
|
209
240
|
- lib/active_support/core_ext/string/strip.rb
|
210
241
|
- lib/active_support/core_ext/string/zones.rb
|
211
242
|
- lib/active_support/core_ext/struct.rb
|
212
|
-
- lib/active_support/core_ext/thread.rb
|
213
243
|
- lib/active_support/core_ext/time.rb
|
214
244
|
- lib/active_support/core_ext/time/acts_like.rb
|
215
245
|
- lib/active_support/core_ext/time/calculations.rb
|
216
|
-
- lib/active_support/core_ext/time/compatibility.rb
|
217
246
|
- lib/active_support/core_ext/time/conversions.rb
|
218
247
|
- lib/active_support/core_ext/time/marshal.rb
|
219
248
|
- lib/active_support/core_ext/time/zones.rb
|
220
249
|
- lib/active_support/core_ext/uri.rb
|
221
250
|
- lib/active_support/dependencies.rb
|
222
251
|
- lib/active_support/dependencies/autoload.rb
|
252
|
+
- lib/active_support/dependencies/interlock.rb
|
223
253
|
- lib/active_support/deprecation.rb
|
224
254
|
- lib/active_support/deprecation/behaviors.rb
|
225
255
|
- lib/active_support/deprecation/instance_delegator.rb
|
@@ -228,6 +258,7 @@ files:
|
|
228
258
|
- lib/active_support/deprecation/reporting.rb
|
229
259
|
- lib/active_support/descendants_tracker.rb
|
230
260
|
- lib/active_support/duration.rb
|
261
|
+
- lib/active_support/evented_file_update_checker.rb
|
231
262
|
- lib/active_support/file_update_checker.rb
|
232
263
|
- lib/active_support/gem_version.rb
|
233
264
|
- lib/active_support/gzip.rb
|
@@ -249,7 +280,6 @@ files:
|
|
249
280
|
- lib/active_support/log_subscriber/test_helper.rb
|
250
281
|
- lib/active_support/logger.rb
|
251
282
|
- lib/active_support/logger_silence.rb
|
252
|
-
- lib/active_support/logger_thread_safe_level.rb
|
253
283
|
- lib/active_support/message_encryptor.rb
|
254
284
|
- lib/active_support/message_verifier.rb
|
255
285
|
- lib/active_support/multibyte.rb
|
@@ -282,11 +312,15 @@ files:
|
|
282
312
|
- lib/active_support/test_case.rb
|
283
313
|
- lib/active_support/testing/assertions.rb
|
284
314
|
- lib/active_support/testing/autorun.rb
|
315
|
+
- lib/active_support/testing/composite_filter.rb
|
285
316
|
- lib/active_support/testing/constant_lookup.rb
|
286
317
|
- lib/active_support/testing/declarative.rb
|
287
318
|
- lib/active_support/testing/deprecation.rb
|
319
|
+
- lib/active_support/testing/file_fixtures.rb
|
288
320
|
- lib/active_support/testing/isolation.rb
|
321
|
+
- lib/active_support/testing/method_call_assertions.rb
|
289
322
|
- lib/active_support/testing/setup_and_teardown.rb
|
323
|
+
- lib/active_support/testing/stream.rb
|
290
324
|
- lib/active_support/testing/tagged_logging.rb
|
291
325
|
- lib/active_support/testing/time_helpers.rb
|
292
326
|
- lib/active_support/time.rb
|
@@ -315,16 +349,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
349
|
requirements:
|
316
350
|
- - ">="
|
317
351
|
- !ruby/object:Gem::Version
|
318
|
-
version:
|
352
|
+
version: 2.2.2
|
319
353
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
320
354
|
requirements:
|
321
|
-
- - "
|
355
|
+
- - ">"
|
322
356
|
- !ruby/object:Gem::Version
|
323
|
-
version:
|
357
|
+
version: 1.3.1
|
324
358
|
requirements: []
|
325
|
-
|
359
|
+
rubyforge_project:
|
360
|
+
rubygems_version: 2.5.1
|
326
361
|
signing_key:
|
327
362
|
specification_version: 4
|
328
363
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|
329
364
|
Rails framework.
|
330
365
|
test_files: []
|
366
|
+
has_rdoc:
|