activesupport 4.1.0 → 4.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +209 -0
- data/lib/active_support/cache/strategy/local_cache.rb +1 -0
- data/lib/active_support/cache.rb +1 -1
- data/lib/active_support/callbacks.rb +118 -76
- data/lib/active_support/core_ext/date_time/calculations.rb +3 -1
- data/lib/active_support/core_ext/hash/deep_merge.rb +22 -11
- data/lib/active_support/core_ext/hash/keys.rb +38 -16
- data/lib/active_support/core_ext/object/duplicable.rb +10 -0
- data/lib/active_support/core_ext/object/json.rb +3 -3
- data/lib/active_support/core_ext/object/to_param.rb +1 -62
- data/lib/active_support/core_ext/object/to_query.rb +58 -7
- data/lib/active_support/core_ext/string/filters.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +7 -3
- data/lib/active_support/core_ext/time/zones.rb +1 -0
- data/lib/active_support/dependencies.rb +4 -4
- data/lib/active_support/duration.rb +5 -1
- data/lib/active_support/gem_version.rb +1 -1
- data/lib/active_support/hash_with_indifferent_access.rb +2 -1
- data/lib/active_support/i18n_railtie.rb +5 -1
- data/lib/active_support/inflector/methods.rb +1 -1
- data/lib/active_support/json/encoding.rb +4 -0
- data/lib/active_support/multibyte/unicode.rb +0 -1
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +3 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +2 -6
- data/lib/active_support/option_merger.rb +1 -1
- data/lib/active_support/subscriber.rb +10 -1
- data/lib/active_support/values/time_zone.rb +5 -2
- data/lib/active_support/xml_mini/jdom.rb +6 -5
- data/lib/active_support/xml_mini/rexml.rb +6 -5
- data/lib/active_support/xml_mini.rb +3 -0
- metadata +3 -3
@@ -72,6 +72,7 @@ module ActiveSupport
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def self.new_from_hash_copying_default(hash)
|
75
|
+
hash = hash.to_hash
|
75
76
|
new(hash).tap do |new_hash|
|
76
77
|
new_hash.default = hash.default
|
77
78
|
end
|
@@ -125,7 +126,7 @@ module ActiveSupport
|
|
125
126
|
if other_hash.is_a? HashWithIndifferentAccess
|
126
127
|
super(other_hash)
|
127
128
|
else
|
128
|
-
other_hash.each_pair do |key, value|
|
129
|
+
other_hash.to_hash.each_pair do |key, value|
|
129
130
|
if block_given? && key?(key)
|
130
131
|
value = yield(convert_key(key), self[key], value)
|
131
132
|
end
|
@@ -36,7 +36,11 @@ module I18n
|
|
36
36
|
# Avoid issues with setting the default_locale by disabling available locales
|
37
37
|
# check while configuring.
|
38
38
|
enforce_available_locales = app.config.i18n.delete(:enforce_available_locales)
|
39
|
-
|
39
|
+
|
40
|
+
if enforce_available_locales.nil?
|
41
|
+
enforce_available_locales = I18n.enforce_available_locales
|
42
|
+
end
|
43
|
+
|
40
44
|
I18n.enforce_available_locales = false
|
41
45
|
|
42
46
|
app.config.i18n.each do |setting, value|
|
@@ -154,7 +154,7 @@ module ActiveSupport
|
|
154
154
|
#
|
155
155
|
# Singular names are not handled correctly:
|
156
156
|
#
|
157
|
-
# '
|
157
|
+
# 'calculus'.classify # => "Calculu"
|
158
158
|
def classify(table_name)
|
159
159
|
# strip out any leading schema name
|
160
160
|
camelize(singularize(table_name.to_s.sub(/.*\./, '')))
|
@@ -42,7 +42,6 @@ module ActiveSupport
|
|
42
42
|
0x0085, # White_Space # Cc <control-0085>
|
43
43
|
0x00A0, # White_Space # Zs NO-BREAK SPACE
|
44
44
|
0x1680, # White_Space # Zs OGHAM SPACE MARK
|
45
|
-
0x180E, # White_Space # Zs MONGOLIAN VOWEL SEPARATOR
|
46
45
|
(0x2000..0x200A).to_a, # White_Space # Zs [11] EN QUAD..HAIR SPACE
|
47
46
|
0x2028, # White_Space # Zl LINE SEPARATOR
|
48
47
|
0x2029, # White_Space # Zp PARAGRAPH SEPARATOR
|
@@ -13,7 +13,9 @@ module ActiveSupport
|
|
13
13
|
|
14
14
|
def parts
|
15
15
|
left, right = number.to_s.split('.')
|
16
|
-
left.gsub!(DELIMITED_REGEX)
|
16
|
+
left.gsub!(DELIMITED_REGEX) do |digit_to_delimit|
|
17
|
+
"#{digit_to_delimit}#{options[:delimiter]}"
|
18
|
+
end
|
17
19
|
[left, right].compact
|
18
20
|
end
|
19
21
|
end
|
@@ -12,11 +12,7 @@ module ActiveSupport
|
|
12
12
|
when Float, String
|
13
13
|
@number = BigDecimal(number.to_s)
|
14
14
|
when Rational
|
15
|
-
|
16
|
-
@number = BigDecimal(number, digit_count(number.to_i) + precision)
|
17
|
-
else
|
18
|
-
@number = BigDecimal(number, precision)
|
19
|
-
end
|
15
|
+
@number = BigDecimal(number, digit_count(number.to_i) + precision)
|
20
16
|
else
|
21
17
|
@number = number.to_d
|
22
18
|
end
|
@@ -63,7 +59,7 @@ module ActiveSupport
|
|
63
59
|
end
|
64
60
|
|
65
61
|
def digit_count(number)
|
66
|
-
(Math.log10(absolute_number(number)) + 1).floor
|
62
|
+
number.zero? ? 1 : (Math.log10(absolute_number(number)) + 1).floor
|
67
63
|
end
|
68
64
|
|
69
65
|
def strip_insignificant_zeros
|
@@ -64,12 +64,21 @@ module ActiveSupport
|
|
64
64
|
def add_event_subscriber(event)
|
65
65
|
return if %w{ start finish }.include?(event.to_s)
|
66
66
|
|
67
|
-
|
67
|
+
pattern = "#{event}.#{namespace}"
|
68
|
+
|
69
|
+
# don't add multiple subscribers (eg. if methods are redefined)
|
70
|
+
return if subscriber.patterns.include?(pattern)
|
71
|
+
|
72
|
+
subscriber.patterns << pattern
|
73
|
+
notifier.subscribe(pattern, subscriber)
|
68
74
|
end
|
69
75
|
end
|
70
76
|
|
77
|
+
attr_reader :patterns # :nodoc:
|
78
|
+
|
71
79
|
def initialize
|
72
80
|
@queue_key = [self.class.name, object_id].join "-"
|
81
|
+
@patterns = []
|
73
82
|
super
|
74
83
|
end
|
75
84
|
|
@@ -111,9 +111,11 @@ module ActiveSupport
|
|
111
111
|
"Jerusalem" => "Asia/Jerusalem",
|
112
112
|
"Harare" => "Africa/Harare",
|
113
113
|
"Pretoria" => "Africa/Johannesburg",
|
114
|
+
"Kaliningrad" => "Europe/Kaliningrad",
|
114
115
|
"Moscow" => "Europe/Moscow",
|
115
116
|
"St. Petersburg" => "Europe/Moscow",
|
116
|
-
"Volgograd" => "Europe/
|
117
|
+
"Volgograd" => "Europe/Volgograd",
|
118
|
+
"Samara" => "Europe/Samara",
|
117
119
|
"Kuwait" => "Asia/Kuwait",
|
118
120
|
"Riyadh" => "Asia/Riyadh",
|
119
121
|
"Nairobi" => "Africa/Nairobi",
|
@@ -170,6 +172,7 @@ module ActiveSupport
|
|
170
172
|
"Guam" => "Pacific/Guam",
|
171
173
|
"Port Moresby" => "Pacific/Port_Moresby",
|
172
174
|
"Magadan" => "Asia/Magadan",
|
175
|
+
"Srednekolymsk" => "Asia/Srednekolymsk",
|
173
176
|
"Solomon Is." => "Pacific/Guadalcanal",
|
174
177
|
"New Caledonia" => "Pacific/Noumea",
|
175
178
|
"Fiji" => "Pacific/Fiji",
|
@@ -282,7 +285,7 @@ module ActiveSupport
|
|
282
285
|
#
|
283
286
|
# Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00
|
284
287
|
# Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
|
285
|
-
def parse(str, now=now)
|
288
|
+
def parse(str, now=now())
|
286
289
|
parts = Date._parse(str, false)
|
287
290
|
return if parts.empty?
|
288
291
|
|
@@ -46,7 +46,7 @@ module ActiveSupport
|
|
46
46
|
xml_string_reader = StringReader.new(data)
|
47
47
|
xml_input_source = InputSource.new(xml_string_reader)
|
48
48
|
doc = @dbf.new_document_builder.parse(xml_input_source)
|
49
|
-
merge_element!({CONTENT_KEY => ''}, doc.document_element)
|
49
|
+
merge_element!({CONTENT_KEY => ''}, doc.document_element, XmlMini.depth)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -58,9 +58,10 @@ module ActiveSupport
|
|
58
58
|
# Hash to merge the converted element into.
|
59
59
|
# element::
|
60
60
|
# XML element to merge into hash
|
61
|
-
def merge_element!(hash, element)
|
61
|
+
def merge_element!(hash, element, depth)
|
62
|
+
raise 'Document too deep!' if depth == 0
|
62
63
|
delete_empty(hash)
|
63
|
-
merge!(hash, element.tag_name, collapse(element))
|
64
|
+
merge!(hash, element.tag_name, collapse(element, depth))
|
64
65
|
end
|
65
66
|
|
66
67
|
def delete_empty(hash)
|
@@ -71,14 +72,14 @@ module ActiveSupport
|
|
71
72
|
#
|
72
73
|
# element::
|
73
74
|
# The document element to be collapsed.
|
74
|
-
def collapse(element)
|
75
|
+
def collapse(element, depth)
|
75
76
|
hash = get_attributes(element)
|
76
77
|
|
77
78
|
child_nodes = element.child_nodes
|
78
79
|
if child_nodes.length > 0
|
79
80
|
(0...child_nodes.length).each do |i|
|
80
81
|
child = child_nodes.item(i)
|
81
|
-
merge_element!(hash, child) unless child.node_type == Node.TEXT_NODE
|
82
|
+
merge_element!(hash, child, depth - 1) unless child.node_type == Node.TEXT_NODE
|
82
83
|
end
|
83
84
|
merge_texts!(hash, element) unless empty_content?(element)
|
84
85
|
hash
|
@@ -29,7 +29,7 @@ module ActiveSupport
|
|
29
29
|
doc = REXML::Document.new(data)
|
30
30
|
|
31
31
|
if doc.root
|
32
|
-
merge_element!({}, doc.root)
|
32
|
+
merge_element!({}, doc.root, XmlMini.depth)
|
33
33
|
else
|
34
34
|
raise REXML::ParseException,
|
35
35
|
"The document #{doc.to_s.inspect} does not have a valid root"
|
@@ -44,19 +44,20 @@ module ActiveSupport
|
|
44
44
|
# Hash to merge the converted element into.
|
45
45
|
# element::
|
46
46
|
# XML element to merge into hash
|
47
|
-
def merge_element!(hash, element)
|
48
|
-
|
47
|
+
def merge_element!(hash, element, depth)
|
48
|
+
raise REXML::ParseException, "The document is too deep" if depth == 0
|
49
|
+
merge!(hash, element.name, collapse(element, depth))
|
49
50
|
end
|
50
51
|
|
51
52
|
# Actually converts an XML document element into a data structure.
|
52
53
|
#
|
53
54
|
# element::
|
54
55
|
# The document element to be collapsed.
|
55
|
-
def collapse(element)
|
56
|
+
def collapse(element, depth)
|
56
57
|
hash = get_attributes(element)
|
57
58
|
|
58
59
|
if element.has_elements?
|
59
|
-
element.each_element {|child| merge_element!(hash, child) }
|
60
|
+
element.each_element {|child| merge_element!(hash, child, depth - 1) }
|
60
61
|
merge_texts!(hash, element) unless empty_content?(element)
|
61
62
|
hash
|
62
63
|
else
|
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.1.
|
4
|
+
version: 4.1.11
|
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-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -336,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
336
|
version: '0'
|
337
337
|
requirements: []
|
338
338
|
rubyforge_project:
|
339
|
-
rubygems_version: 2.
|
339
|
+
rubygems_version: 2.4.5
|
340
340
|
signing_key:
|
341
341
|
specification_version: 4
|
342
342
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|