activesupport 5.0.7.2 → 5.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +215 -820
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/active_support.rb +8 -4
- data/lib/active_support/all.rb +3 -3
- data/lib/active_support/array_inquirer.rb +7 -5
- data/lib/active_support/backtrace_cleaner.rb +4 -4
- data/lib/active_support/benchmarkable.rb +3 -3
- data/lib/active_support/builder.rb +1 -1
- data/lib/active_support/cache.rb +42 -49
- data/lib/active_support/cache/file_store.rb +12 -21
- data/lib/active_support/cache/mem_cache_store.rb +30 -40
- data/lib/active_support/cache/memory_store.rb +11 -13
- data/lib/active_support/cache/null_store.rb +4 -4
- data/lib/active_support/cache/strategy/local_cache.rb +16 -25
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +8 -9
- data/lib/active_support/callbacks.rb +647 -584
- data/lib/active_support/concurrency/share_lock.rb +20 -21
- data/lib/active_support/configurable.rb +5 -5
- data/lib/active_support/core_ext.rb +1 -2
- data/lib/active_support/core_ext/array.rb +7 -7
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +15 -15
- data/lib/active_support/core_ext/array/grouping.rb +1 -1
- data/lib/active_support/core_ext/array/inquiry.rb +1 -1
- data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
- data/lib/active_support/core_ext/benchmark.rb +1 -1
- data/lib/active_support/core_ext/big_decimal.rb +1 -1
- data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
- data/lib/active_support/core_ext/class.rb +2 -2
- data/lib/active_support/core_ext/class/attribute.rb +5 -5
- data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
- data/lib/active_support/core_ext/class/subclasses.rb +18 -4
- data/lib/active_support/core_ext/date.rb +5 -5
- data/lib/active_support/core_ext/date/acts_like.rb +1 -1
- data/lib/active_support/core_ext/date/blank.rb +1 -1
- data/lib/active_support/core_ext/date/calculations.rb +8 -8
- data/lib/active_support/core_ext/date/conversions.rb +12 -12
- data/lib/active_support/core_ext/date/zones.rb +2 -2
- data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +9 -1
- data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
- data/lib/active_support/core_ext/date_time.rb +5 -5
- data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
- data/lib/active_support/core_ext/date_time/blank.rb +1 -1
- data/lib/active_support/core_ext/date_time/calculations.rb +9 -9
- data/lib/active_support/core_ext/date_time/compatibility.rb +2 -13
- data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
- data/lib/active_support/core_ext/digest/uuid.rb +4 -4
- data/lib/active_support/core_ext/enumerable.rb +46 -57
- data/lib/active_support/core_ext/file.rb +1 -1
- data/lib/active_support/core_ext/file/atomic.rb +4 -4
- data/lib/active_support/core_ext/hash.rb +9 -9
- data/lib/active_support/core_ext/hash/compact.rb +12 -9
- data/lib/active_support/core_ext/hash/conversions.rb +36 -37
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
- data/lib/active_support/core_ext/hash/keys.rb +8 -8
- data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
- data/lib/active_support/core_ext/hash/slice.rb +4 -4
- data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
- data/lib/active_support/core_ext/integer.rb +3 -3
- data/lib/active_support/core_ext/integer/inflections.rb +1 -1
- data/lib/active_support/core_ext/integer/time.rb +2 -2
- data/lib/active_support/core_ext/kernel.rb +4 -4
- data/lib/active_support/core_ext/kernel/concern.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
- data/lib/active_support/core_ext/load_error.rb +1 -18
- data/lib/active_support/core_ext/marshal.rb +2 -2
- data/lib/active_support/core_ext/module.rb +11 -12
- data/lib/active_support/core_ext/module/aliasing.rb +3 -48
- data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
- data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -5
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +20 -13
- data/lib/active_support/core_ext/module/concerning.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +82 -16
- data/lib/active_support/core_ext/module/introspection.rb +3 -11
- data/lib/active_support/core_ext/module/reachable.rb +2 -2
- data/lib/active_support/core_ext/numeric.rb +4 -4
- data/lib/active_support/core_ext/numeric/conversions.rb +3 -9
- data/lib/active_support/core_ext/numeric/inquiry.rb +21 -21
- data/lib/active_support/core_ext/numeric/time.rb +5 -5
- data/lib/active_support/core_ext/object.rb +12 -12
- data/lib/active_support/core_ext/object/blank.rb +3 -1
- data/lib/active_support/core_ext/object/conversions.rb +4 -4
- data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
- data/lib/active_support/core_ext/object/duplicable.rb +24 -4
- data/lib/active_support/core_ext/object/inclusion.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +26 -12
- data/lib/active_support/core_ext/object/to_param.rb +1 -1
- data/lib/active_support/core_ext/object/to_query.rb +4 -4
- data/lib/active_support/core_ext/object/try.rb +1 -1
- data/lib/active_support/core_ext/object/with_options.rb +1 -1
- data/lib/active_support/core_ext/range.rb +4 -4
- data/lib/active_support/core_ext/range/conversions.rb +1 -1
- data/lib/active_support/core_ext/regexp.rb +4 -0
- data/lib/active_support/core_ext/securerandom.rb +3 -3
- data/lib/active_support/core_ext/string.rb +13 -13
- data/lib/active_support/core_ext/string/access.rb +6 -6
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/filters.rb +3 -3
- data/lib/active_support/core_ext/string/indent.rb +4 -4
- data/lib/active_support/core_ext/string/inflections.rb +10 -14
- data/lib/active_support/core_ext/string/inquiry.rb +1 -1
- data/lib/active_support/core_ext/string/multibyte.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +19 -20
- data/lib/active_support/core_ext/string/strip.rb +1 -1
- data/lib/active_support/core_ext/string/zones.rb +2 -2
- data/lib/active_support/core_ext/time.rb +5 -5
- data/lib/active_support/core_ext/time/acts_like.rb +1 -1
- data/lib/active_support/core_ext/time/calculations.rb +23 -29
- data/lib/active_support/core_ext/time/compatibility.rb +1 -10
- data/lib/active_support/core_ext/time/conversions.rb +12 -12
- data/lib/active_support/core_ext/time/zones.rb +3 -3
- data/lib/active_support/core_ext/uri.rb +2 -2
- data/lib/active_support/dependencies.rb +45 -47
- data/lib/active_support/dependencies/interlock.rb +1 -1
- data/lib/active_support/deprecation.rb +8 -8
- data/lib/active_support/deprecation/behaviors.rb +3 -3
- data/lib/active_support/deprecation/instance_delegator.rb +2 -2
- data/lib/active_support/deprecation/method_wrappers.rb +3 -3
- data/lib/active_support/deprecation/proxy_wrappers.rb +6 -4
- data/lib/active_support/deprecation/reporting.rb +7 -7
- data/lib/active_support/duration.rb +30 -26
- data/lib/active_support/duration/iso8601_parser.rb +66 -65
- data/lib/active_support/duration/iso8601_serializer.rb +11 -9
- data/lib/active_support/evented_file_update_checker.rb +59 -60
- data/lib/active_support/execution_wrapper.rb +3 -3
- data/lib/active_support/executor.rb +1 -1
- data/lib/active_support/file_update_checker.rb +54 -50
- data/lib/active_support/gem_version.rb +3 -3
- data/lib/active_support/gzip.rb +5 -5
- data/lib/active_support/hash_with_indifferent_access.rb +10 -20
- data/lib/active_support/i18n.rb +5 -5
- data/lib/active_support/i18n_railtie.rb +11 -10
- data/lib/active_support/inflections.rb +11 -11
- data/lib/active_support/inflector.rb +5 -5
- data/lib/active_support/inflector/inflections.rb +11 -9
- data/lib/active_support/inflector/methods.rb +51 -50
- data/lib/active_support/inflector/transliterate.rb +8 -11
- data/lib/active_support/json.rb +2 -2
- data/lib/active_support/json/decoding.rb +3 -3
- data/lib/active_support/json/encoding.rb +8 -7
- data/lib/active_support/key_generator.rb +17 -17
- data/lib/active_support/lazy_load_hooks.rb +12 -30
- data/lib/active_support/log_subscriber.rb +5 -5
- data/lib/active_support/log_subscriber/test_helper.rb +9 -9
- data/lib/active_support/logger.rb +3 -3
- data/lib/active_support/logger_silence.rb +3 -3
- data/lib/active_support/logger_thread_safe_level.rb +1 -1
- data/lib/active_support/message_encryptor.rb +72 -35
- data/lib/active_support/message_verifier.rb +7 -7
- data/lib/active_support/multibyte.rb +2 -2
- data/lib/active_support/multibyte/chars.rb +23 -21
- data/lib/active_support/multibyte/unicode.rb +68 -89
- data/lib/active_support/notifications.rb +5 -5
- data/lib/active_support/notifications/fanout.rb +3 -3
- data/lib/active_support/notifications/instrumenter.rb +5 -5
- data/lib/active_support/number_helper.rb +4 -4
- data/lib/active_support/number_helper/number_converter.rb +11 -11
- data/lib/active_support/number_helper/number_to_currency_converter.rb +3 -3
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -2
- data/lib/active_support/number_helper/number_to_human_converter.rb +6 -6
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -11
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -3
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +6 -6
- data/lib/active_support/option_merger.rb +1 -1
- data/lib/active_support/ordered_hash.rb +3 -3
- data/lib/active_support/ordered_options.rb +6 -4
- data/lib/active_support/per_thread_registry.rb +5 -5
- data/lib/active_support/rails.rb +12 -6
- data/lib/active_support/railtie.rb +3 -3
- data/lib/active_support/reloader.rb +1 -1
- data/lib/active_support/rescuable.rb +8 -14
- data/lib/active_support/security_utils.rb +1 -1
- data/lib/active_support/string_inquirer.rb +8 -2
- data/lib/active_support/subscriber.rb +9 -5
- data/lib/active_support/tagged_logging.rb +4 -4
- data/lib/active_support/test_case.rb +12 -29
- data/lib/active_support/testing/assertions.rb +100 -2
- data/lib/active_support/testing/autorun.rb +6 -2
- data/lib/active_support/testing/constant_lookup.rb +0 -1
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/deprecation.rb +3 -2
- data/lib/active_support/testing/isolation.rb +13 -22
- data/lib/active_support/testing/method_call_assertions.rb +1 -1
- data/lib/active_support/testing/setup_and_teardown.rb +2 -2
- data/lib/active_support/testing/stream.rb +28 -28
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +45 -12
- data/lib/active_support/time.rb +12 -12
- data/lib/active_support/time_with_zone.rb +16 -26
- data/lib/active_support/values/time_zone.rb +40 -46
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini.rb +34 -36
- data/lib/active_support/xml_mini/jdom.rb +112 -112
- data/lib/active_support/xml_mini/libxml.rb +15 -12
- data/lib/active_support/xml_mini/libxmlsax.rb +17 -15
- data/lib/active_support/xml_mini/nokogiri.rb +13 -11
- data/lib/active_support/xml_mini/nokogirisax.rb +15 -14
- data/lib/active_support/xml_mini/rexml.rb +9 -9
- metadata +8 -19
- data/lib/active_support/concurrency/latch.rb +0 -26
- data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
- data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
- data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
- data/lib/active_support/core_ext/struct.rb +0 -3
- data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "libxml"
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
|
+
require "stringio"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
6
|
module XmlMini_LibXML #:nodoc:
|
@@ -11,16 +11,17 @@ module ActiveSupport
|
|
11
11
|
# XML Document string or IO to parse
|
12
12
|
def parse(data)
|
13
13
|
if !data.respond_to?(:read)
|
14
|
-
data = StringIO.new(data ||
|
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
|
23
|
-
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -33,20 +34,20 @@ module LibXML #:nodoc:
|
|
33
34
|
end
|
34
35
|
|
35
36
|
module Node #:nodoc:
|
36
|
-
CONTENT_ROOT =
|
37
|
+
CONTENT_ROOT = "__content__".freeze
|
37
38
|
|
38
39
|
# Convert XML document to hash.
|
39
40
|
#
|
40
41
|
# hash::
|
41
42
|
# Hash to merge the converted element into.
|
42
|
-
def to_hash(hash={})
|
43
|
+
def to_hash(hash = {})
|
43
44
|
node_hash = {}
|
44
45
|
|
45
46
|
# Insert node hash into parent hash correctly.
|
46
47
|
case hash[name]
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
when Array then hash[name] << node_hash
|
49
|
+
when Hash then hash[name] = [hash[name], node_hash]
|
50
|
+
when nil then hash[name] = node_hash
|
50
51
|
end
|
51
52
|
|
52
53
|
# Handle child elements
|
@@ -54,7 +55,7 @@ module LibXML #:nodoc:
|
|
54
55
|
if c.element?
|
55
56
|
c.to_hash(node_hash)
|
56
57
|
elsif c.text? || c.cdata?
|
57
|
-
node_hash[CONTENT_ROOT] ||=
|
58
|
+
node_hash[CONTENT_ROOT] ||= ""
|
58
59
|
node_hash[CONTENT_ROOT] << c.content
|
59
60
|
end
|
60
61
|
end
|
@@ -73,5 +74,7 @@ module LibXML #:nodoc:
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
77
|
+
# :enddoc:
|
78
|
+
|
76
79
|
LibXML::XML::Document.include(LibXML::Conversions::Document)
|
77
80
|
LibXML::XML::Node.include(LibXML::Conversions::Node)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "libxml"
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
|
+
require "stringio"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
6
|
module XmlMini_LibXMLSAX #:nodoc:
|
@@ -9,11 +9,10 @@ module ActiveSupport
|
|
9
9
|
# Class that will build the hash while the XML document
|
10
10
|
# is being parsed using SAX events.
|
11
11
|
class HashBuilder
|
12
|
-
|
13
12
|
include LibXML::XML::SaxParser::Callbacks
|
14
13
|
|
15
|
-
CONTENT_KEY =
|
16
|
-
HASH_SIZE_KEY =
|
14
|
+
CONTENT_KEY = "__content__".freeze
|
15
|
+
HASH_SIZE_KEY = "__hash_size__".freeze
|
17
16
|
|
18
17
|
attr_reader :hash
|
19
18
|
|
@@ -22,7 +21,7 @@ module ActiveSupport
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def on_start_document
|
25
|
-
@hash = { CONTENT_KEY =>
|
24
|
+
@hash = { CONTENT_KEY => "" }
|
26
25
|
@hash_stack = [@hash]
|
27
26
|
end
|
28
27
|
|
@@ -32,20 +31,20 @@ module ActiveSupport
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def on_start_element(name, attrs = {})
|
35
|
-
new_hash = { CONTENT_KEY =>
|
34
|
+
new_hash = { CONTENT_KEY => "" }.merge!(attrs)
|
36
35
|
new_hash[HASH_SIZE_KEY] = new_hash.size + 1
|
37
36
|
|
38
37
|
case current_hash[name]
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
when Array then current_hash[name] << new_hash
|
39
|
+
when Hash then current_hash[name] = [current_hash[name], new_hash]
|
40
|
+
when nil then current_hash[name] = new_hash
|
42
41
|
end
|
43
42
|
|
44
43
|
@hash_stack.push(new_hash)
|
45
44
|
end
|
46
45
|
|
47
46
|
def on_end_element(name)
|
48
|
-
if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] ==
|
47
|
+
if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] == ""
|
49
48
|
current_hash.delete(CONTENT_KEY)
|
50
49
|
end
|
51
50
|
@hash_stack.pop
|
@@ -63,15 +62,18 @@ module ActiveSupport
|
|
63
62
|
|
64
63
|
def parse(data)
|
65
64
|
if !data.respond_to?(:read)
|
66
|
-
data = StringIO.new(data ||
|
65
|
+
data = StringIO.new(data || "")
|
67
66
|
end
|
68
67
|
|
69
|
-
|
68
|
+
char = data.getc
|
69
|
+
if char.nil?
|
70
70
|
{}
|
71
71
|
else
|
72
|
+
data.ungetc(char)
|
73
|
+
|
72
74
|
LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
|
73
75
|
parser = LibXML::XML::SaxParser.io(data)
|
74
|
-
document =
|
76
|
+
document = document_class.new
|
75
77
|
|
76
78
|
parser.callbacks = document
|
77
79
|
parser.parse
|
@@ -1,11 +1,11 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "nokogiri"
|
3
3
|
rescue LoadError => e
|
4
4
|
$stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
|
5
5
|
raise e
|
6
6
|
end
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require "active_support/core_ext/object/blank"
|
8
|
+
require "stringio"
|
9
9
|
|
10
10
|
module ActiveSupport
|
11
11
|
module XmlMini_Nokogiri #:nodoc:
|
@@ -16,12 +16,14 @@ module ActiveSupport
|
|
16
16
|
# XML Document string or IO to parse
|
17
17
|
def parse(data)
|
18
18
|
if !data.respond_to?(:read)
|
19
|
-
data = StringIO.new(data ||
|
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
|
@@ -36,20 +38,20 @@ module ActiveSupport
|
|
36
38
|
end
|
37
39
|
|
38
40
|
module Node #:nodoc:
|
39
|
-
CONTENT_ROOT =
|
41
|
+
CONTENT_ROOT = "__content__".freeze
|
40
42
|
|
41
43
|
# Convert XML document to hash.
|
42
44
|
#
|
43
45
|
# hash::
|
44
46
|
# Hash to merge the converted element into.
|
45
|
-
def to_hash(hash={})
|
47
|
+
def to_hash(hash = {})
|
46
48
|
node_hash = {}
|
47
49
|
|
48
50
|
# Insert node hash into parent hash correctly.
|
49
51
|
case hash[name]
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
when Array then hash[name] << node_hash
|
53
|
+
when Hash then hash[name] = [hash[name], node_hash]
|
54
|
+
when nil then hash[name] = node_hash
|
53
55
|
end
|
54
56
|
|
55
57
|
# Handle child elements
|
@@ -57,7 +59,7 @@ module ActiveSupport
|
|
57
59
|
if c.element?
|
58
60
|
c.to_hash(node_hash)
|
59
61
|
elsif c.text? || c.cdata?
|
60
|
-
node_hash[CONTENT_ROOT] ||=
|
62
|
+
node_hash[CONTENT_ROOT] ||= ""
|
61
63
|
node_hash[CONTENT_ROOT] << c.content
|
62
64
|
end
|
63
65
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "nokogiri"
|
3
3
|
rescue LoadError => e
|
4
4
|
$stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
|
5
5
|
raise e
|
6
6
|
end
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require "active_support/core_ext/object/blank"
|
8
|
+
require "stringio"
|
9
9
|
|
10
10
|
module ActiveSupport
|
11
11
|
module XmlMini_NokogiriSAX #:nodoc:
|
@@ -14,9 +14,8 @@ module ActiveSupport
|
|
14
14
|
# Class that will build the hash while the XML document
|
15
15
|
# is being parsed using SAX events.
|
16
16
|
class HashBuilder < Nokogiri::XML::SAX::Document
|
17
|
-
|
18
|
-
|
19
|
-
HASH_SIZE_KEY = '__hash_size__'.freeze
|
17
|
+
CONTENT_KEY = "__content__".freeze
|
18
|
+
HASH_SIZE_KEY = "__hash_size__".freeze
|
20
19
|
|
21
20
|
attr_reader :hash
|
22
21
|
|
@@ -38,20 +37,20 @@ module ActiveSupport
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def start_element(name, attrs = [])
|
41
|
-
new_hash = { CONTENT_KEY =>
|
40
|
+
new_hash = { CONTENT_KEY => "" }.merge!(Hash[attrs])
|
42
41
|
new_hash[HASH_SIZE_KEY] = new_hash.size + 1
|
43
42
|
|
44
43
|
case current_hash[name]
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
when Array then current_hash[name] << new_hash
|
45
|
+
when Hash then current_hash[name] = [current_hash[name], new_hash]
|
46
|
+
when nil then current_hash[name] = new_hash
|
48
47
|
end
|
49
48
|
|
50
49
|
@hash_stack.push(new_hash)
|
51
50
|
end
|
52
51
|
|
53
52
|
def end_element(name)
|
54
|
-
if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] ==
|
53
|
+
if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] == ""
|
55
54
|
current_hash.delete(CONTENT_KEY)
|
56
55
|
end
|
57
56
|
@hash_stack.pop
|
@@ -69,13 +68,15 @@ module ActiveSupport
|
|
69
68
|
|
70
69
|
def parse(data)
|
71
70
|
if !data.respond_to?(:read)
|
72
|
-
data = StringIO.new(data ||
|
71
|
+
data = StringIO.new(data || "")
|
73
72
|
end
|
74
73
|
|
75
|
-
|
74
|
+
char = data.getc
|
75
|
+
if char.nil?
|
76
76
|
{}
|
77
77
|
else
|
78
|
-
|
78
|
+
data.ungetc(char)
|
79
|
+
document = document_class.new
|
79
80
|
parser = Nokogiri::XML::SAX::Parser.new(document)
|
80
81
|
parser.parse(data)
|
81
82
|
document.hash
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "active_support/core_ext/kernel/reporting"
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
|
+
require "stringio"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
6
|
module XmlMini_REXML #:nodoc:
|
7
7
|
extend self
|
8
8
|
|
9
|
-
CONTENT_KEY =
|
9
|
+
CONTENT_KEY = "__content__".freeze
|
10
10
|
|
11
11
|
# Parse an XML Document string or IO into a simple hash.
|
12
12
|
#
|
@@ -17,13 +17,13 @@ module ActiveSupport
|
|
17
17
|
# XML Document string or IO to parse
|
18
18
|
def parse(data)
|
19
19
|
if !data.respond_to?(:read)
|
20
|
-
data = StringIO.new(data ||
|
20
|
+
data = StringIO.new(data || "")
|
21
21
|
end
|
22
22
|
|
23
23
|
if data.eof?
|
24
24
|
{}
|
25
25
|
else
|
26
|
-
silence_warnings { require
|
26
|
+
silence_warnings { require "rexml/document" } unless defined?(REXML::Document)
|
27
27
|
doc = REXML::Document.new(data)
|
28
28
|
|
29
29
|
if doc.root
|
@@ -55,7 +55,7 @@ module ActiveSupport
|
|
55
55
|
hash = get_attributes(element)
|
56
56
|
|
57
57
|
if element.has_elements?
|
58
|
-
element.each_element {|child| merge_element!(hash, child, depth - 1) }
|
58
|
+
element.each_element { |child| merge_element!(hash, child, depth - 1) }
|
59
59
|
merge_texts!(hash, element) unless empty_content?(element)
|
60
60
|
hash
|
61
61
|
else
|
@@ -74,7 +74,7 @@ module ActiveSupport
|
|
74
74
|
hash
|
75
75
|
else
|
76
76
|
# must use value to prevent double-escaping
|
77
|
-
texts =
|
77
|
+
texts = ""
|
78
78
|
element.texts.each { |t| texts << t.value }
|
79
79
|
merge!(hash, CONTENT_KEY, texts)
|
80
80
|
end
|
@@ -113,7 +113,7 @@ module ActiveSupport
|
|
113
113
|
# XML element to extract attributes from.
|
114
114
|
def get_attributes(element)
|
115
115
|
attributes = {}
|
116
|
-
element.attributes.each { |n,v| attributes[n] = v }
|
116
|
+
element.attributes.each { |n, v| attributes[n] = v }
|
117
117
|
attributes
|
118
118
|
end
|
119
119
|
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.1.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: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.7'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.7'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '2'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: tzinfo
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +98,6 @@ files:
|
|
104
98
|
- lib/active_support/cache/strategy/local_cache_middleware.rb
|
105
99
|
- lib/active_support/callbacks.rb
|
106
100
|
- lib/active_support/concern.rb
|
107
|
-
- lib/active_support/concurrency/latch.rb
|
108
101
|
- lib/active_support/concurrency/share_lock.rb
|
109
102
|
- lib/active_support/configurable.rb
|
110
103
|
- lib/active_support/core_ext.rb
|
@@ -159,7 +152,6 @@ files:
|
|
159
152
|
- lib/active_support/core_ext/kernel.rb
|
160
153
|
- lib/active_support/core_ext/kernel/agnostics.rb
|
161
154
|
- lib/active_support/core_ext/kernel/concern.rb
|
162
|
-
- lib/active_support/core_ext/kernel/debugger.rb
|
163
155
|
- lib/active_support/core_ext/kernel/reporting.rb
|
164
156
|
- lib/active_support/core_ext/kernel/singleton_class.rb
|
165
157
|
- lib/active_support/core_ext/load_error.rb
|
@@ -174,8 +166,6 @@ files:
|
|
174
166
|
- lib/active_support/core_ext/module/delegation.rb
|
175
167
|
- lib/active_support/core_ext/module/deprecation.rb
|
176
168
|
- lib/active_support/core_ext/module/introspection.rb
|
177
|
-
- lib/active_support/core_ext/module/method_transplanting.rb
|
178
|
-
- lib/active_support/core_ext/module/qualified_const.rb
|
179
169
|
- lib/active_support/core_ext/module/reachable.rb
|
180
170
|
- lib/active_support/core_ext/module/remove_method.rb
|
181
171
|
- lib/active_support/core_ext/name_error.rb
|
@@ -218,13 +208,11 @@ files:
|
|
218
208
|
- lib/active_support/core_ext/string/starts_ends_with.rb
|
219
209
|
- lib/active_support/core_ext/string/strip.rb
|
220
210
|
- lib/active_support/core_ext/string/zones.rb
|
221
|
-
- lib/active_support/core_ext/struct.rb
|
222
211
|
- lib/active_support/core_ext/time.rb
|
223
212
|
- lib/active_support/core_ext/time/acts_like.rb
|
224
213
|
- lib/active_support/core_ext/time/calculations.rb
|
225
214
|
- lib/active_support/core_ext/time/compatibility.rb
|
226
215
|
- lib/active_support/core_ext/time/conversions.rb
|
227
|
-
- lib/active_support/core_ext/time/marshal.rb
|
228
216
|
- lib/active_support/core_ext/time/zones.rb
|
229
217
|
- lib/active_support/core_ext/uri.rb
|
230
218
|
- lib/active_support/dependencies.rb
|
@@ -337,11 +325,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
337
325
|
version: 2.2.2
|
338
326
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
339
327
|
requirements:
|
340
|
-
- - "
|
328
|
+
- - ">"
|
341
329
|
- !ruby/object:Gem::Version
|
342
|
-
version:
|
330
|
+
version: 1.3.1
|
343
331
|
requirements: []
|
344
|
-
|
332
|
+
rubyforge_project:
|
333
|
+
rubygems_version: 2.6.10
|
345
334
|
signing_key:
|
346
335
|
specification_version: 4
|
347
336
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'concurrent/atomic/count_down_latch'
|
2
|
-
|
3
|
-
module ActiveSupport
|
4
|
-
module Concurrency
|
5
|
-
class Latch
|
6
|
-
|
7
|
-
def initialize(count = 1)
|
8
|
-
if count == 1
|
9
|
-
ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::Event instead.")
|
10
|
-
else
|
11
|
-
ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::CountDownLatch instead.")
|
12
|
-
end
|
13
|
-
|
14
|
-
@inner = Concurrent::CountDownLatch.new(count)
|
15
|
-
end
|
16
|
-
|
17
|
-
def release
|
18
|
-
@inner.count_down
|
19
|
-
end
|
20
|
-
|
21
|
-
def await
|
22
|
-
@inner.wait(nil)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|