activesupport 4.2.2 → 4.2.3.rc1
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 +4 -4
- data/CHANGELOG.md +12 -1
- data/lib/active_support/cache.rb +1 -1
- data/lib/active_support/callbacks.rb +10 -16
- data/lib/active_support/concern.rb +1 -1
- data/lib/active_support/core_ext/big_decimal/yaml_conversions.rb +2 -0
- data/lib/active_support/core_ext/date/conversions.rb +6 -0
- data/lib/active_support/core_ext/date_and_time/calculations.rb +11 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +1 -1
- data/lib/active_support/core_ext/integer/time.rb +0 -15
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -0
- data/lib/active_support/core_ext/numeric/time.rb +0 -15
- data/lib/active_support/core_ext/object/json.rb +1 -1
- data/lib/active_support/core_ext/string/filters.rb +3 -2
- data/lib/active_support/core_ext/time/calculations.rb +1 -1
- data/lib/active_support/duration.rb +24 -0
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/json/encoding.rb +1 -0
- data/lib/active_support/multibyte/chars.rb +1 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb23685a8594f37879d919eafd4b00c53ce532a4
|
4
|
+
data.tar.gz: 7dc8755438f019239e11f45560fab7212f53c924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0683102ab2f30b13eb6486335f50e595f40144d300e74b85db5c615a3e903b706f1510ca0fa2f6d8b3432aaf8db9bf75a0206a05742c064e6a32763c56a25159
|
7
|
+
data.tar.gz: b11174967b7b8e8178f339e9646be47ec0b95476e99de7edd436c03a83ffc13b8b785af7696cd02d7bb1a26fdd6aae8f126be503e3aa19d117ebd1688d6ea4d3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## Rails 4.2.3 (June 22, 2015) ##
|
2
|
+
|
3
|
+
* Fix a range of values for parameters of the Time#change
|
4
|
+
|
5
|
+
*Nikolay Kondratyev*
|
6
|
+
|
7
|
+
* Add some missing `require 'active_support/deprecation'`
|
8
|
+
|
9
|
+
*Akira Matsuda*
|
10
|
+
|
11
|
+
|
1
12
|
## Rails 4.2.2 (June 16, 2015) ##
|
2
13
|
|
3
14
|
* Fix XSS vulnerability in `ActiveSupport::JSON.encode` method.
|
@@ -13,7 +24,7 @@
|
|
13
24
|
*Aaron Patterson*
|
14
25
|
|
15
26
|
|
16
|
-
## Rails 4.2.1 (March 19,
|
27
|
+
## Rails 4.2.1 (March 19, 2015) ##
|
17
28
|
|
18
29
|
* Fixed a problem where String#truncate_words would get stuck with a complex
|
19
30
|
string.
|
data/lib/active_support/cache.rb
CHANGED
@@ -562,7 +562,7 @@ module ActiveSupport
|
|
562
562
|
def handle_expired_entry(entry, key, options)
|
563
563
|
if entry && entry.expired?
|
564
564
|
race_ttl = options[:race_condition_ttl].to_i
|
565
|
-
if race_ttl && (Time.now.to_f - entry.expires_at <= race_ttl)
|
565
|
+
if (race_ttl > 0) && (Time.now.to_f - entry.expires_at <= race_ttl)
|
566
566
|
# When an entry has :race_condition_ttl defined, put the stale entry back into the cache
|
567
567
|
# for a brief period while the entry is begin recalculated.
|
568
568
|
entry.expires_at = Time.now + race_ttl
|
@@ -78,14 +78,10 @@ module ActiveSupport
|
|
78
78
|
# save
|
79
79
|
# end
|
80
80
|
def run_callbacks(kind, &block)
|
81
|
-
send
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
81
|
+
callbacks = send("_#{kind}_callbacks")
|
85
82
|
|
86
|
-
def _run_callbacks(callbacks, &block)
|
87
83
|
if callbacks.empty?
|
88
|
-
|
84
|
+
yield if block_given?
|
89
85
|
else
|
90
86
|
runner = callbacks.compile
|
91
87
|
e = Filters::Environment.new(self, false, nil, block)
|
@@ -93,6 +89,8 @@ module ActiveSupport
|
|
93
89
|
end
|
94
90
|
end
|
95
91
|
|
92
|
+
private
|
93
|
+
|
96
94
|
# A hook invoked every time a before callback is halted.
|
97
95
|
# This can be overridden in AS::Callback implementors in order
|
98
96
|
# to provide better debugging/logging.
|
@@ -636,10 +634,12 @@ module ActiveSupport
|
|
636
634
|
#
|
637
635
|
# ===== Options
|
638
636
|
#
|
639
|
-
# * <tt>:if</tt> - A symbol
|
640
|
-
#
|
641
|
-
#
|
642
|
-
#
|
637
|
+
# * <tt>:if</tt> - A symbol, a string or an array of symbols and strings,
|
638
|
+
# each naming an instance method or a proc; the callback will be called
|
639
|
+
# only when they all return a true value.
|
640
|
+
# * <tt>:unless</tt> - A symbol, a string or an array of symbols and
|
641
|
+
# strings, each naming an instance method or a proc; the callback will
|
642
|
+
# be called only when they all return a false value.
|
643
643
|
# * <tt>:prepend</tt> - If +true+, the callback will be prepended to the
|
644
644
|
# existing chain rather than appended.
|
645
645
|
def set_callback(name, *filter_list, &block)
|
@@ -770,12 +770,6 @@ module ActiveSupport
|
|
770
770
|
names.each do |name|
|
771
771
|
class_attribute "_#{name}_callbacks"
|
772
772
|
set_callbacks name, CallbackChain.new(name, options)
|
773
|
-
|
774
|
-
module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
775
|
-
def _run_#{name}_callbacks(&block)
|
776
|
-
_run_callbacks(_#{name}_callbacks, &block)
|
777
|
-
end
|
778
|
-
RUBY
|
779
773
|
end
|
780
774
|
end
|
781
775
|
|
@@ -132,7 +132,7 @@ module ActiveSupport
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def class_methods(&class_methods_module_definition)
|
135
|
-
mod = const_defined?(:ClassMethods) ?
|
135
|
+
mod = const_defined?(:ClassMethods, false) ?
|
136
136
|
const_get(:ClassMethods) :
|
137
137
|
const_set(:ClassMethods, Module.new)
|
138
138
|
|
@@ -35,6 +35,7 @@ class Date
|
|
35
35
|
# date.to_s(:db) # => "2007-11-10"
|
36
36
|
#
|
37
37
|
# date.to_formatted_s(:short) # => "10 Nov"
|
38
|
+
# date.to_formatted_s(:number) # => "20071110"
|
38
39
|
# date.to_formatted_s(:long) # => "November 10, 2007"
|
39
40
|
# date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
|
40
41
|
# date.to_formatted_s(:rfc822) # => "10 Nov 2007"
|
@@ -82,6 +83,11 @@ class Date
|
|
82
83
|
::Time.send(form, year, month, day)
|
83
84
|
end
|
84
85
|
|
86
|
+
# Returns a string which represents the time in used time zone as DateTime
|
87
|
+
# defined by XML Schema:
|
88
|
+
#
|
89
|
+
# date = Date.new(2015, 05, 23) # => Sat, 23 May 2015
|
90
|
+
# date.xmlschema # => "2015-05-23T00:00:00+04:00"
|
85
91
|
def xmlschema
|
86
92
|
in_time_zone.xmlschema
|
87
93
|
end
|
@@ -109,9 +109,20 @@ module DateAndTime
|
|
109
109
|
alias :at_beginning_of_year :beginning_of_year
|
110
110
|
|
111
111
|
# Returns a new date/time representing the given day in the next week.
|
112
|
+
#
|
113
|
+
# today = Date.today # => Thu, 07 May 2015
|
114
|
+
# today.next_week # => Mon, 11 May 2015
|
115
|
+
#
|
112
116
|
# The +given_day_in_next_week+ defaults to the beginning of the week
|
113
117
|
# which is determined by +Date.beginning_of_week+ or +config.beginning_of_week+
|
118
|
+
#
|
119
|
+
# today = Date.today # => Thu, 07 May 2015
|
120
|
+
# today.next_week(:friday) # => Fri, 15 May 2015
|
121
|
+
#
|
114
122
|
# when set. +DateTime+ objects have their time set to 0:00.
|
123
|
+
#
|
124
|
+
# now = Time.current # => Thu, 07 May 2015 13:31:16 UTC +00:00
|
125
|
+
# now.next_week # => Mon, 11 May 2015 00:00:00 UTC +00:00
|
115
126
|
def next_week(given_day_in_next_week = Date.beginning_of_week)
|
116
127
|
first_hour(weeks_since(1).beginning_of_week.days_since(days_span(given_day_in_next_week)))
|
117
128
|
end
|
@@ -17,21 +17,6 @@ class Integer
|
|
17
17
|
#
|
18
18
|
# # equivalent to Time.now.advance(months: 4, years: 5)
|
19
19
|
# (4.months + 5.years).from_now
|
20
|
-
#
|
21
|
-
# While these methods provide precise calculation when used as in the examples
|
22
|
-
# above, care should be taken to note that this is not true if the result of
|
23
|
-
# +months+, +years+, etc is converted before use:
|
24
|
-
#
|
25
|
-
# # equivalent to 30.days.to_i.from_now
|
26
|
-
# 1.month.to_i.from_now
|
27
|
-
#
|
28
|
-
# # equivalent to 365.25.days.to_f.from_now
|
29
|
-
# 1.year.to_f.from_now
|
30
|
-
#
|
31
|
-
# In such cases, Ruby's core
|
32
|
-
# Date[http://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html] and
|
33
|
-
# Time[http://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html] should be used for precision
|
34
|
-
# date and time arithmetic.
|
35
20
|
def months
|
36
21
|
ActiveSupport::Duration.new(self * 30.days, [[:months, self]])
|
37
22
|
end
|
@@ -16,21 +16,6 @@ class Numeric
|
|
16
16
|
#
|
17
17
|
# # equivalent to Time.current.advance(months: 4, years: 5)
|
18
18
|
# (4.months + 5.years).from_now
|
19
|
-
#
|
20
|
-
# While these methods provide precise calculation when used as in the examples above, care
|
21
|
-
# should be taken to note that this is not true if the result of `months', `years', etc is
|
22
|
-
# converted before use:
|
23
|
-
#
|
24
|
-
# # equivalent to 30.days.to_i.from_now
|
25
|
-
# 1.month.to_i.from_now
|
26
|
-
#
|
27
|
-
# # equivalent to 365.25.days.to_f.from_now
|
28
|
-
# 1.year.to_f.from_now
|
29
|
-
#
|
30
|
-
# In such cases, Ruby's core
|
31
|
-
# Date[http://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html] and
|
32
|
-
# Time[http://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html] should be used for precision
|
33
|
-
# date and time arithmetic.
|
34
19
|
def seconds
|
35
20
|
ActiveSupport::Duration.new(self, [[:seconds, self]])
|
36
21
|
end
|
@@ -28,7 +28,7 @@ require 'active_support/core_ext/module/aliasing'
|
|
28
28
|
# should give exactly the same results with or without active support.
|
29
29
|
[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass, Enumerable].each do |klass|
|
30
30
|
klass.class_eval do
|
31
|
-
def to_json_with_active_support_encoder(options = nil)
|
31
|
+
def to_json_with_active_support_encoder(options = nil) # :nodoc:
|
32
32
|
if options.is_a?(::JSON::State)
|
33
33
|
# Called from JSON.{generate,dump}, forward it to JSON gem's to_json
|
34
34
|
self.to_json_without_active_support_encoder(options)
|
@@ -26,6 +26,7 @@ class String
|
|
26
26
|
# Returns a new string with all occurrences of the patterns removed.
|
27
27
|
# str = "foo bar test"
|
28
28
|
# str.remove(" test") # => "foo bar"
|
29
|
+
# str.remove(" test", /bar/) # => "foo "
|
29
30
|
# str # => "foo bar test"
|
30
31
|
def remove(*patterns)
|
31
32
|
dup.remove!(*patterns)
|
@@ -33,8 +34,8 @@ class String
|
|
33
34
|
|
34
35
|
# Alters the string by removing all occurrences of the patterns.
|
35
36
|
# str = "foo bar test"
|
36
|
-
# str.remove!(" test")
|
37
|
-
# str
|
37
|
+
# str.remove!(" test", /bar/) # => "foo "
|
38
|
+
# str # => "foo "
|
38
39
|
def remove!(*patterns)
|
39
40
|
patterns.each do |pattern|
|
40
41
|
gsub! pattern, ""
|
@@ -94,7 +94,7 @@ class Time
|
|
94
94
|
elsif zone
|
95
95
|
::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
|
96
96
|
else
|
97
|
-
raise ArgumentError, 'argument out of range' if new_usec
|
97
|
+
raise ArgumentError, 'argument out of range' if new_usec >= 1000000
|
98
98
|
::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec + (new_usec.to_r / 1000000), utc_offset)
|
99
99
|
end
|
100
100
|
end
|
@@ -56,6 +56,30 @@ module ActiveSupport
|
|
56
56
|
@value.to_s
|
57
57
|
end
|
58
58
|
|
59
|
+
# Returns the number of seconds that this Duration represents.
|
60
|
+
#
|
61
|
+
# 1.minute.to_i # => 60
|
62
|
+
# 1.hour.to_i # => 3600
|
63
|
+
# 1.day.to_i # => 86400
|
64
|
+
#
|
65
|
+
# Note that this conversion makes some assumptions about the
|
66
|
+
# duration of some periods, e.g. months are always 30 days
|
67
|
+
# and years are 365.25 days:
|
68
|
+
#
|
69
|
+
# # equivalent to 30.days.to_i
|
70
|
+
# 1.month.to_i # => 2592000
|
71
|
+
#
|
72
|
+
# # equivalent to 365.25.days.to_i
|
73
|
+
# 1.year.to_i # => 31557600
|
74
|
+
#
|
75
|
+
# In such cases, Ruby's core
|
76
|
+
# Date[http://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html] and
|
77
|
+
# Time[http://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html] should be used for precision
|
78
|
+
# date and time arithmetic.
|
79
|
+
def to_i
|
80
|
+
@value.to_i
|
81
|
+
end
|
82
|
+
|
59
83
|
# Returns +true+ if +other+ is also a Duration instance, which has the
|
60
84
|
# same parts as this one.
|
61
85
|
def eql?(other)
|
@@ -86,7 +86,7 @@ module ActiveSupport #:nodoc:
|
|
86
86
|
@wrapped_string.split(*args).map { |i| self.class.new(i) }
|
87
87
|
end
|
88
88
|
|
89
|
-
# Works like
|
89
|
+
# Works like <tt>String#slice!</tt>, but returns an instance of
|
90
90
|
# Chars, or nil if the string was not modified.
|
91
91
|
def slice!(*args)
|
92
92
|
chars(@wrapped_string.slice!(*args))
|
@@ -23,7 +23,7 @@ module ActiveSupport
|
|
23
23
|
precision = 0 if precision < 0 # don't let it be negative
|
24
24
|
else
|
25
25
|
rounded_number = number.round(precision)
|
26
|
-
rounded_number = rounded_number.to_i if precision == 0
|
26
|
+
rounded_number = rounded_number.to_i if precision == 0 && rounded_number.finite?
|
27
27
|
rounded_number = rounded_number.abs if rounded_number.zero? # prevent showing negative zeros
|
28
28
|
end
|
29
29
|
|
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.2.
|
4
|
+
version: 4.2.3.rc1
|
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: 2015-06-
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -334,9 +334,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
334
334
|
version: 1.9.3
|
335
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
336
336
|
requirements:
|
337
|
-
- - "
|
337
|
+
- - ">"
|
338
338
|
- !ruby/object:Gem::Version
|
339
|
-
version:
|
339
|
+
version: 1.3.1
|
340
340
|
requirements: []
|
341
341
|
rubyforge_project:
|
342
342
|
rubygems_version: 2.4.5
|