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.

Files changed (210) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +215 -820
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/active_support.rb +8 -4
  6. data/lib/active_support/all.rb +3 -3
  7. data/lib/active_support/array_inquirer.rb +7 -5
  8. data/lib/active_support/backtrace_cleaner.rb +4 -4
  9. data/lib/active_support/benchmarkable.rb +3 -3
  10. data/lib/active_support/builder.rb +1 -1
  11. data/lib/active_support/cache.rb +42 -49
  12. data/lib/active_support/cache/file_store.rb +12 -21
  13. data/lib/active_support/cache/mem_cache_store.rb +30 -40
  14. data/lib/active_support/cache/memory_store.rb +11 -13
  15. data/lib/active_support/cache/null_store.rb +4 -4
  16. data/lib/active_support/cache/strategy/local_cache.rb +16 -25
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +8 -9
  18. data/lib/active_support/callbacks.rb +647 -584
  19. data/lib/active_support/concurrency/share_lock.rb +20 -21
  20. data/lib/active_support/configurable.rb +5 -5
  21. data/lib/active_support/core_ext.rb +1 -2
  22. data/lib/active_support/core_ext/array.rb +7 -7
  23. data/lib/active_support/core_ext/array/access.rb +1 -1
  24. data/lib/active_support/core_ext/array/conversions.rb +15 -15
  25. data/lib/active_support/core_ext/array/grouping.rb +1 -1
  26. data/lib/active_support/core_ext/array/inquiry.rb +1 -1
  27. data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
  28. data/lib/active_support/core_ext/benchmark.rb +1 -1
  29. data/lib/active_support/core_ext/big_decimal.rb +1 -1
  30. data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
  31. data/lib/active_support/core_ext/class.rb +2 -2
  32. data/lib/active_support/core_ext/class/attribute.rb +5 -5
  33. data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
  34. data/lib/active_support/core_ext/class/subclasses.rb +18 -4
  35. data/lib/active_support/core_ext/date.rb +5 -5
  36. data/lib/active_support/core_ext/date/acts_like.rb +1 -1
  37. data/lib/active_support/core_ext/date/blank.rb +1 -1
  38. data/lib/active_support/core_ext/date/calculations.rb +8 -8
  39. data/lib/active_support/core_ext/date/conversions.rb +12 -12
  40. data/lib/active_support/core_ext/date/zones.rb +2 -2
  41. data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
  42. data/lib/active_support/core_ext/date_and_time/compatibility.rb +9 -1
  43. data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
  44. data/lib/active_support/core_ext/date_time.rb +5 -5
  45. data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
  46. data/lib/active_support/core_ext/date_time/blank.rb +1 -1
  47. data/lib/active_support/core_ext/date_time/calculations.rb +9 -9
  48. data/lib/active_support/core_ext/date_time/compatibility.rb +2 -13
  49. data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
  50. data/lib/active_support/core_ext/digest/uuid.rb +4 -4
  51. data/lib/active_support/core_ext/enumerable.rb +46 -57
  52. data/lib/active_support/core_ext/file.rb +1 -1
  53. data/lib/active_support/core_ext/file/atomic.rb +4 -4
  54. data/lib/active_support/core_ext/hash.rb +9 -9
  55. data/lib/active_support/core_ext/hash/compact.rb +12 -9
  56. data/lib/active_support/core_ext/hash/conversions.rb +36 -37
  57. data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
  58. data/lib/active_support/core_ext/hash/keys.rb +8 -8
  59. data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
  60. data/lib/active_support/core_ext/hash/slice.rb +4 -4
  61. data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
  62. data/lib/active_support/core_ext/integer.rb +3 -3
  63. data/lib/active_support/core_ext/integer/inflections.rb +1 -1
  64. data/lib/active_support/core_ext/integer/time.rb +2 -2
  65. data/lib/active_support/core_ext/kernel.rb +4 -4
  66. data/lib/active_support/core_ext/kernel/concern.rb +1 -1
  67. data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
  68. data/lib/active_support/core_ext/load_error.rb +1 -18
  69. data/lib/active_support/core_ext/marshal.rb +2 -2
  70. data/lib/active_support/core_ext/module.rb +11 -12
  71. data/lib/active_support/core_ext/module/aliasing.rb +3 -48
  72. data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
  73. data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -5
  74. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +20 -13
  75. data/lib/active_support/core_ext/module/concerning.rb +1 -1
  76. data/lib/active_support/core_ext/module/delegation.rb +82 -16
  77. data/lib/active_support/core_ext/module/introspection.rb +3 -11
  78. data/lib/active_support/core_ext/module/reachable.rb +2 -2
  79. data/lib/active_support/core_ext/numeric.rb +4 -4
  80. data/lib/active_support/core_ext/numeric/conversions.rb +3 -9
  81. data/lib/active_support/core_ext/numeric/inquiry.rb +21 -21
  82. data/lib/active_support/core_ext/numeric/time.rb +5 -5
  83. data/lib/active_support/core_ext/object.rb +12 -12
  84. data/lib/active_support/core_ext/object/blank.rb +3 -1
  85. data/lib/active_support/core_ext/object/conversions.rb +4 -4
  86. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  87. data/lib/active_support/core_ext/object/duplicable.rb +24 -4
  88. data/lib/active_support/core_ext/object/inclusion.rb +1 -1
  89. data/lib/active_support/core_ext/object/json.rb +26 -12
  90. data/lib/active_support/core_ext/object/to_param.rb +1 -1
  91. data/lib/active_support/core_ext/object/to_query.rb +4 -4
  92. data/lib/active_support/core_ext/object/try.rb +1 -1
  93. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  94. data/lib/active_support/core_ext/range.rb +4 -4
  95. data/lib/active_support/core_ext/range/conversions.rb +1 -1
  96. data/lib/active_support/core_ext/regexp.rb +4 -0
  97. data/lib/active_support/core_ext/securerandom.rb +3 -3
  98. data/lib/active_support/core_ext/string.rb +13 -13
  99. data/lib/active_support/core_ext/string/access.rb +6 -6
  100. data/lib/active_support/core_ext/string/conversions.rb +2 -2
  101. data/lib/active_support/core_ext/string/filters.rb +3 -3
  102. data/lib/active_support/core_ext/string/indent.rb +4 -4
  103. data/lib/active_support/core_ext/string/inflections.rb +10 -14
  104. data/lib/active_support/core_ext/string/inquiry.rb +1 -1
  105. data/lib/active_support/core_ext/string/multibyte.rb +1 -1
  106. data/lib/active_support/core_ext/string/output_safety.rb +19 -20
  107. data/lib/active_support/core_ext/string/strip.rb +1 -1
  108. data/lib/active_support/core_ext/string/zones.rb +2 -2
  109. data/lib/active_support/core_ext/time.rb +5 -5
  110. data/lib/active_support/core_ext/time/acts_like.rb +1 -1
  111. data/lib/active_support/core_ext/time/calculations.rb +23 -29
  112. data/lib/active_support/core_ext/time/compatibility.rb +1 -10
  113. data/lib/active_support/core_ext/time/conversions.rb +12 -12
  114. data/lib/active_support/core_ext/time/zones.rb +3 -3
  115. data/lib/active_support/core_ext/uri.rb +2 -2
  116. data/lib/active_support/dependencies.rb +45 -47
  117. data/lib/active_support/dependencies/interlock.rb +1 -1
  118. data/lib/active_support/deprecation.rb +8 -8
  119. data/lib/active_support/deprecation/behaviors.rb +3 -3
  120. data/lib/active_support/deprecation/instance_delegator.rb +2 -2
  121. data/lib/active_support/deprecation/method_wrappers.rb +3 -3
  122. data/lib/active_support/deprecation/proxy_wrappers.rb +6 -4
  123. data/lib/active_support/deprecation/reporting.rb +7 -7
  124. data/lib/active_support/duration.rb +30 -26
  125. data/lib/active_support/duration/iso8601_parser.rb +66 -65
  126. data/lib/active_support/duration/iso8601_serializer.rb +11 -9
  127. data/lib/active_support/evented_file_update_checker.rb +59 -60
  128. data/lib/active_support/execution_wrapper.rb +3 -3
  129. data/lib/active_support/executor.rb +1 -1
  130. data/lib/active_support/file_update_checker.rb +54 -50
  131. data/lib/active_support/gem_version.rb +3 -3
  132. data/lib/active_support/gzip.rb +5 -5
  133. data/lib/active_support/hash_with_indifferent_access.rb +10 -20
  134. data/lib/active_support/i18n.rb +5 -5
  135. data/lib/active_support/i18n_railtie.rb +11 -10
  136. data/lib/active_support/inflections.rb +11 -11
  137. data/lib/active_support/inflector.rb +5 -5
  138. data/lib/active_support/inflector/inflections.rb +11 -9
  139. data/lib/active_support/inflector/methods.rb +51 -50
  140. data/lib/active_support/inflector/transliterate.rb +8 -11
  141. data/lib/active_support/json.rb +2 -2
  142. data/lib/active_support/json/decoding.rb +3 -3
  143. data/lib/active_support/json/encoding.rb +8 -7
  144. data/lib/active_support/key_generator.rb +17 -17
  145. data/lib/active_support/lazy_load_hooks.rb +12 -30
  146. data/lib/active_support/log_subscriber.rb +5 -5
  147. data/lib/active_support/log_subscriber/test_helper.rb +9 -9
  148. data/lib/active_support/logger.rb +3 -3
  149. data/lib/active_support/logger_silence.rb +3 -3
  150. data/lib/active_support/logger_thread_safe_level.rb +1 -1
  151. data/lib/active_support/message_encryptor.rb +72 -35
  152. data/lib/active_support/message_verifier.rb +7 -7
  153. data/lib/active_support/multibyte.rb +2 -2
  154. data/lib/active_support/multibyte/chars.rb +23 -21
  155. data/lib/active_support/multibyte/unicode.rb +68 -89
  156. data/lib/active_support/notifications.rb +5 -5
  157. data/lib/active_support/notifications/fanout.rb +3 -3
  158. data/lib/active_support/notifications/instrumenter.rb +5 -5
  159. data/lib/active_support/number_helper.rb +4 -4
  160. data/lib/active_support/number_helper/number_converter.rb +11 -11
  161. data/lib/active_support/number_helper/number_to_currency_converter.rb +3 -3
  162. data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -2
  163. data/lib/active_support/number_helper/number_to_human_converter.rb +6 -6
  164. data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -11
  165. data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
  166. data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -3
  167. data/lib/active_support/number_helper/number_to_rounded_converter.rb +6 -6
  168. data/lib/active_support/option_merger.rb +1 -1
  169. data/lib/active_support/ordered_hash.rb +3 -3
  170. data/lib/active_support/ordered_options.rb +6 -4
  171. data/lib/active_support/per_thread_registry.rb +5 -5
  172. data/lib/active_support/rails.rb +12 -6
  173. data/lib/active_support/railtie.rb +3 -3
  174. data/lib/active_support/reloader.rb +1 -1
  175. data/lib/active_support/rescuable.rb +8 -14
  176. data/lib/active_support/security_utils.rb +1 -1
  177. data/lib/active_support/string_inquirer.rb +8 -2
  178. data/lib/active_support/subscriber.rb +9 -5
  179. data/lib/active_support/tagged_logging.rb +4 -4
  180. data/lib/active_support/test_case.rb +12 -29
  181. data/lib/active_support/testing/assertions.rb +100 -2
  182. data/lib/active_support/testing/autorun.rb +6 -2
  183. data/lib/active_support/testing/constant_lookup.rb +0 -1
  184. data/lib/active_support/testing/declarative.rb +1 -1
  185. data/lib/active_support/testing/deprecation.rb +3 -2
  186. data/lib/active_support/testing/isolation.rb +13 -22
  187. data/lib/active_support/testing/method_call_assertions.rb +1 -1
  188. data/lib/active_support/testing/setup_and_teardown.rb +2 -2
  189. data/lib/active_support/testing/stream.rb +28 -28
  190. data/lib/active_support/testing/tagged_logging.rb +1 -1
  191. data/lib/active_support/testing/time_helpers.rb +45 -12
  192. data/lib/active_support/time.rb +12 -12
  193. data/lib/active_support/time_with_zone.rb +16 -26
  194. data/lib/active_support/values/time_zone.rb +40 -46
  195. data/lib/active_support/values/unicode_tables.dat +0 -0
  196. data/lib/active_support/version.rb +1 -1
  197. data/lib/active_support/xml_mini.rb +34 -36
  198. data/lib/active_support/xml_mini/jdom.rb +112 -112
  199. data/lib/active_support/xml_mini/libxml.rb +15 -12
  200. data/lib/active_support/xml_mini/libxmlsax.rb +17 -15
  201. data/lib/active_support/xml_mini/nokogiri.rb +13 -11
  202. data/lib/active_support/xml_mini/nokogirisax.rb +15 -14
  203. data/lib/active_support/xml_mini/rexml.rb +9 -9
  204. metadata +8 -19
  205. data/lib/active_support/concurrency/latch.rb +0 -26
  206. data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
  207. data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
  208. data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
  209. data/lib/active_support/core_ext/struct.rb +0 -3
  210. data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -1,6 +1,6 @@
1
- require 'libxml'
2
- require 'active_support/core_ext/object/blank'
3
- require 'stringio'
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
- if data.eof?
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 = '__content__'.freeze
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
- when Array then hash[name] << node_hash
48
- when Hash then hash[name] = [hash[name], node_hash]
49
- when nil then hash[name] = node_hash
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 'libxml'
2
- require 'active_support/core_ext/object/blank'
3
- require 'stringio'
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 = '__content__'.freeze
16
- HASH_SIZE_KEY = '__hash_size__'.freeze
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 => '' }.merge!(attrs)
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
- when Array then current_hash[name] << new_hash
40
- when Hash then current_hash[name] = [current_hash[name], new_hash]
41
- when nil then current_hash[name] = new_hash
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
- if data.eof?
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 = self.document_class.new
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 'nokogiri'
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 'active_support/core_ext/object/blank'
8
- require 'stringio'
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
- if data.eof?
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 = '__content__'.freeze
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
- when Array then hash[name] << node_hash
51
- when Hash then hash[name] = [hash[name], node_hash]
52
- when nil then hash[name] = node_hash
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 'nokogiri'
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 'active_support/core_ext/object/blank'
8
- require 'stringio'
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
- CONTENT_KEY = '__content__'.freeze
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 => '' }.merge!(Hash[attrs])
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
- when Array then current_hash[name] << new_hash
46
- when Hash then current_hash[name] = [current_hash[name], new_hash]
47
- when nil then current_hash[name] = new_hash
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
- if data.eof?
74
+ char = data.getc
75
+ if char.nil?
76
76
  {}
77
77
  else
78
- document = self.document_class.new
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 'active_support/core_ext/kernel/reporting'
2
- require 'active_support/core_ext/object/blank'
3
- require 'stringio'
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 = '__content__'.freeze
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 'rexml/document' } unless defined?(REXML::Document)
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.7.2
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: 2019-03-13 00:00:00.000000000 Z
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: '0'
330
+ version: 1.3.1
343
331
  requirements: []
344
- rubygems_version: 3.0.1
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