activesupport 4.0.0.rc1 → 4.0.0.rc2
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 +13 -16
- data/lib/active_support/callbacks.rb +2 -21
- data/lib/active_support/core_ext/array/wrap.rb +6 -6
- data/lib/active_support/core_ext/date.rb +0 -1
- data/lib/active_support/core_ext/date/calculations.rb +11 -0
- data/lib/active_support/core_ext/date_time.rb +0 -1
- data/lib/active_support/core_ext/date_time/calculations.rb +7 -0
- data/lib/active_support/core_ext/marshal.rb +2 -0
- data/lib/active_support/core_ext/numeric.rb +0 -1
- data/lib/active_support/core_ext/object/inclusion.rb +9 -8
- data/lib/active_support/core_ext/range/include_range.rb +2 -0
- data/lib/active_support/core_ext/time.rb +0 -1
- data/lib/active_support/core_ext/time/calculations.rb +12 -0
- data/lib/active_support/deprecation/proxy_wrappers.rb +3 -3
- data/lib/active_support/hash_with_indifferent_access.rb +16 -6
- data/lib/active_support/notifications/fanout.rb +7 -0
- data/lib/active_support/testing/isolation.rb +4 -0
- data/lib/active_support/version.rb +1 -1
- metadata +3 -8
- data/lib/active_support/core_ext/date/infinite_comparable.rb +0 -5
- data/lib/active_support/core_ext/date_time/infinite_comparable.rb +0 -5
- data/lib/active_support/core_ext/infinite_comparable.rb +0 -35
- data/lib/active_support/core_ext/numeric/infinite_comparable.rb +0 -9
- data/lib/active_support/core_ext/time/infinite_comparable.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50394a5dde9dbcdf47f30b09e2114d00c746e661
|
4
|
+
data.tar.gz: 05b98599f6d9846bb6bd90950e916cf7bcfee450
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff1d8f80f99c75b2396df78f4f8cca93c5de6a62ecc6e40b4144f9f90992a5a754de2157d1f1d74a841fa2b461afb4cc2275e42822cda8c0961306ba24370424
|
7
|
+
data.tar.gz: 01bce3c3e5d91185ca68a5c15858f6cd1107278e5e10f400d59ecb2daf846b8ae5cbd945946495b9b02fb1f6178709a50bd2c1ccb13cd244b0d386c3de076a41
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
-
|
1
|
+
* Override `Time.at` to support the passing of Time-like values when called with a single argument.
|
2
|
+
|
3
|
+
*Andrew White*
|
4
|
+
|
5
|
+
* Allow Date to be compared with Time (like it was possible to compare Time with Date).
|
6
|
+
|
7
|
+
*DHH*
|
8
|
+
|
9
|
+
* Deprecate multiple parameters support of `Object#in?`.
|
10
|
+
|
11
|
+
*Brian Morearty + Carlos Antonio da Silva*
|
2
12
|
|
3
|
-
* Fix skipping of filters defined by objects in `ActiveSupport::Callbacks::Callback`.
|
4
13
|
|
5
|
-
|
14
|
+
## Rails 4.0.0.rc1 (April 29, 2013) ##
|
6
15
|
|
7
16
|
* An `ActiveSupport::Subscriber` class has been extracted from
|
8
17
|
`ActiveSupport::LogSubscriber`, allowing you to use the event attachment
|
@@ -32,6 +41,7 @@
|
|
32
41
|
|
33
42
|
*Charles Jones*
|
34
43
|
|
44
|
+
|
35
45
|
## Rails 4.0.0.beta1 (February 25, 2013) ##
|
36
46
|
|
37
47
|
* Improve singularizing a singular for multiple cases.
|
@@ -134,19 +144,6 @@
|
|
134
144
|
|
135
145
|
*Kelly Stannard*
|
136
146
|
|
137
|
-
* It's now possible to compare `Date`, `DateTime`, `Time` and `TimeWithZone`
|
138
|
-
with `Float::INFINITY`. This allows to create date/time ranges with one infinite bound.
|
139
|
-
Example:
|
140
|
-
|
141
|
-
range = Range.new(Date.today, Float::INFINITY)
|
142
|
-
|
143
|
-
Also it's possible to check inclusion of date/time in range with conversion.
|
144
|
-
|
145
|
-
range.include?(Time.now + 1.year) # => true
|
146
|
-
range.include?(DateTime.now + 1.year) # => true
|
147
|
-
|
148
|
-
*Alexander Grebennik*
|
149
|
-
|
150
147
|
* Remove meaningless `ActiveSupport::FrozenObjectError`, which was just an alias of `RuntimeError`.
|
151
148
|
|
152
149
|
*Akira Matsuda*
|
@@ -133,13 +133,7 @@ module ActiveSupport
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def matches?(_kind, _filter)
|
136
|
-
|
137
|
-
_filter_matches = @filter.to_s.start_with?(_method_name_for_object_filter(_kind, _filter, false))
|
138
|
-
else
|
139
|
-
_filter_matches = (@filter == _filter)
|
140
|
-
end
|
141
|
-
|
142
|
-
@kind == _kind && _filter_matches
|
136
|
+
@kind == _kind && @filter == _filter
|
143
137
|
end
|
144
138
|
|
145
139
|
def duplicates?(other)
|
@@ -242,16 +236,6 @@ module ActiveSupport
|
|
242
236
|
@compiled_options = conditions.flatten.join(" && ")
|
243
237
|
end
|
244
238
|
|
245
|
-
def _method_name_for_object_filter(kind, filter, append_next_id = true)
|
246
|
-
class_name = filter.kind_of?(Class) ? filter.to_s : filter.class.to_s
|
247
|
-
class_name.gsub!(/<|>|#/, '')
|
248
|
-
class_name.gsub!(/\/|:/, "_")
|
249
|
-
|
250
|
-
method_name = "_callback_#{kind}_#{class_name}"
|
251
|
-
method_name << "_#{next_id}" if append_next_id
|
252
|
-
method_name
|
253
|
-
end
|
254
|
-
|
255
239
|
# Filters support:
|
256
240
|
#
|
257
241
|
# Arrays:: Used in conditions. This is used to specify
|
@@ -273,8 +257,6 @@ module ActiveSupport
|
|
273
257
|
# a method is created that calls the before_foo method
|
274
258
|
# on the object.
|
275
259
|
def _compile_filter(filter)
|
276
|
-
@_is_object_filter = false
|
277
|
-
|
278
260
|
case filter
|
279
261
|
when Array
|
280
262
|
filter.map {|f| _compile_filter(f)}
|
@@ -289,8 +271,7 @@ module ActiveSupport
|
|
289
271
|
|
290
272
|
method_name << (filter.arity == 1 ? "(self)" : " self, Proc.new ")
|
291
273
|
else
|
292
|
-
method_name =
|
293
|
-
@_is_object_filter = true
|
274
|
+
method_name = "_callback_#{@kind}_#{next_id}"
|
294
275
|
@klass.send(:define_method, "#{method_name}_object") { filter }
|
295
276
|
|
296
277
|
_normalize_legacy_filter(kind, filter)
|
@@ -15,12 +15,12 @@ class Array
|
|
15
15
|
#
|
16
16
|
# * If the argument responds to +to_ary+ the method is invoked. <tt>Kernel#Array</tt>
|
17
17
|
# moves on to try +to_a+ if the returned value is +nil+, but <tt>Array.wrap</tt> returns
|
18
|
-
#
|
18
|
+
# +nil+ right away.
|
19
19
|
# * If the returned value from +to_ary+ is neither +nil+ nor an +Array+ object, <tt>Kernel#Array</tt>
|
20
20
|
# raises an exception, while <tt>Array.wrap</tt> does not, it just returns the value.
|
21
|
-
# * It does not call +to_a+ on the argument,
|
21
|
+
# * It does not call +to_a+ on the argument, but returns an empty array if argument is +nil+.
|
22
22
|
#
|
23
|
-
# The
|
23
|
+
# The second point is easily explained with some enumerables:
|
24
24
|
#
|
25
25
|
# Array(foo: :bar) # => [[:foo, :bar]]
|
26
26
|
# Array.wrap(foo: :bar) # => [{:foo=>:bar}]
|
@@ -29,10 +29,10 @@ class Array
|
|
29
29
|
#
|
30
30
|
# [*object]
|
31
31
|
#
|
32
|
-
# which
|
32
|
+
# which returns <tt>[]</tt> for +nil+, but calls to <tt>Array(object)</tt> otherwise.
|
33
33
|
#
|
34
|
-
#
|
35
|
-
#
|
34
|
+
# The differences with <tt>Kernel#Array</tt> explained above
|
35
|
+
# apply to the rest of <tt>object</tt>s.
|
36
36
|
def self.wrap(object)
|
37
37
|
if object.nil?
|
38
38
|
[]
|
@@ -119,4 +119,15 @@ class Date
|
|
119
119
|
options.fetch(:day, day)
|
120
120
|
)
|
121
121
|
end
|
122
|
+
|
123
|
+
# Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there.
|
124
|
+
def compare_with_coercion(other)
|
125
|
+
if other.is_a?(Time)
|
126
|
+
self.to_datetime <=> other
|
127
|
+
else
|
128
|
+
compare_without_coercion(other)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
alias_method :compare_without_coercion, :<=>
|
132
|
+
alias_method :<=>, :compare_with_coercion
|
122
133
|
end
|
@@ -2,4 +2,3 @@ require 'active_support/core_ext/date_time/acts_like'
|
|
2
2
|
require 'active_support/core_ext/date_time/calculations'
|
3
3
|
require 'active_support/core_ext/date_time/conversions'
|
4
4
|
require 'active_support/core_ext/date_time/zones'
|
5
|
-
require 'active_support/core_ext/date_time/infinite_comparable'
|
@@ -154,4 +154,11 @@ class DateTime
|
|
154
154
|
def utc_offset
|
155
155
|
(offset * 86400).to_i
|
156
156
|
end
|
157
|
+
|
158
|
+
# Layers additional behavior on DateTime#<=> so that Time and
|
159
|
+
# ActiveSupport::TimeWithZone instances can be compared with a DateTime.
|
160
|
+
def <=>(other)
|
161
|
+
super other.to_datetime
|
162
|
+
end
|
163
|
+
|
157
164
|
end
|
@@ -1,17 +1,18 @@
|
|
1
|
+
require 'active_support/deprecation'
|
2
|
+
|
1
3
|
class Object
|
2
|
-
# Returns true if this object is included in the argument
|
3
|
-
# any object which responds to +#include
|
4
|
+
# Returns true if this object is included in the argument. Argument must be
|
5
|
+
# any object which responds to +#include?+. Usage:
|
4
6
|
#
|
5
|
-
# characters = [
|
6
|
-
#
|
7
|
+
# characters = ["Konata", "Kagami", "Tsukasa"]
|
8
|
+
# "Konata".in?(characters) # => true
|
7
9
|
#
|
8
|
-
#
|
9
|
-
# character.in?('Konata', 'Kagami', 'Tsukasa') # => true
|
10
|
-
#
|
11
|
-
# This will throw an ArgumentError if a single argument is passed in and it doesn't respond
|
10
|
+
# This will throw an ArgumentError if the argument doesn't respond
|
12
11
|
# to +#include?+.
|
13
12
|
def in?(*args)
|
14
13
|
if args.length > 1
|
14
|
+
ActiveSupport::Deprecation.warn "Calling #in? with multiple arguments is" \
|
15
|
+
" deprecated, please pass in an object that responds to #include? instead."
|
15
16
|
args.include? self
|
16
17
|
else
|
17
18
|
another_object = args.first
|
@@ -65,6 +65,18 @@ class Time
|
|
65
65
|
def current
|
66
66
|
::Time.zone ? ::Time.zone.now : ::Time.now
|
67
67
|
end
|
68
|
+
|
69
|
+
# Layers additional behavior on Time.at so that ActiveSupport::TimeWithZone and DateTime
|
70
|
+
# instances can be used when called with a single argument
|
71
|
+
def at_with_coercion(*args)
|
72
|
+
if args.size == 1 && args.first.acts_like?(:time)
|
73
|
+
at_without_coercion(args.first.to_i)
|
74
|
+
else
|
75
|
+
at_without_coercion(*args)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
alias_method :at_without_coercion, :at
|
79
|
+
alias_method :at, :at_with_coercion
|
68
80
|
end
|
69
81
|
|
70
82
|
# Seconds since midnight: Time.now.seconds_since_midnight
|
@@ -25,7 +25,7 @@ module ActiveSupport
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
# This DeprecatedObjectProxy transforms object to
|
28
|
+
# This DeprecatedObjectProxy transforms object to deprecated object.
|
29
29
|
#
|
30
30
|
# @old_object = DeprecatedObjectProxy.new(Object.new, "Don't use this object anymore!")
|
31
31
|
# @old_object = DeprecatedObjectProxy.new(Object.new, "Don't use this object anymore!", deprecator_instance)
|
@@ -52,7 +52,7 @@ module ActiveSupport
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# This DeprecatedInstanceVariableProxy transforms instance variable to
|
55
|
-
#
|
55
|
+
# deprecated instance variable.
|
56
56
|
#
|
57
57
|
# class Example
|
58
58
|
# def initialize(deprecator)
|
@@ -93,7 +93,7 @@ module ActiveSupport
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
# This DeprecatedConstantProxy transforms constant to
|
96
|
+
# This DeprecatedConstantProxy transforms constant to deprecated constant.
|
97
97
|
#
|
98
98
|
# OLD_CONST = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('OLD_CONST', 'NEW_CONST')
|
99
99
|
# OLD_CONST = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('OLD_CONST', 'NEW_CONST', deprecator_instance)
|
@@ -91,7 +91,7 @@ module ActiveSupport
|
|
91
91
|
#
|
92
92
|
# This value can be later fetched using either +:key+ or +'key'+.
|
93
93
|
def []=(key, value)
|
94
|
-
regular_writer(convert_key(key), convert_value(value))
|
94
|
+
regular_writer(convert_key(key), convert_value(value, for: :assignment))
|
95
95
|
end
|
96
96
|
|
97
97
|
alias_method :store, :[]=
|
@@ -229,7 +229,11 @@ module ActiveSupport
|
|
229
229
|
|
230
230
|
# Convert to a regular hash with string keys.
|
231
231
|
def to_hash
|
232
|
-
|
232
|
+
_new_hash= {}
|
233
|
+
each do |key, value|
|
234
|
+
_new_hash[convert_key(key)] = convert_value(value, for: :to_hash)
|
235
|
+
end
|
236
|
+
Hash.new(default).merge!(_new_hash)
|
233
237
|
end
|
234
238
|
|
235
239
|
protected
|
@@ -237,12 +241,18 @@ module ActiveSupport
|
|
237
241
|
key.kind_of?(Symbol) ? key.to_s : key
|
238
242
|
end
|
239
243
|
|
240
|
-
def convert_value(value)
|
244
|
+
def convert_value(value, options = {})
|
241
245
|
if value.is_a? Hash
|
242
|
-
|
246
|
+
if options[:for] == :to_hash
|
247
|
+
value.to_hash
|
248
|
+
else
|
249
|
+
value.nested_under_indifferent_access
|
250
|
+
end
|
243
251
|
elsif value.is_a?(Array)
|
244
|
-
|
245
|
-
|
252
|
+
unless options[:for] == :assignment
|
253
|
+
value = value.dup
|
254
|
+
end
|
255
|
+
value.map! { |e| convert_value(e, options) }
|
246
256
|
else
|
247
257
|
value
|
248
258
|
end
|
@@ -79,6 +79,13 @@ module ActiveSupport
|
|
79
79
|
def initialize(pattern, delegate)
|
80
80
|
@pattern = pattern
|
81
81
|
@delegate = delegate
|
82
|
+
@can_publish = delegate.respond_to?(:publish)
|
83
|
+
end
|
84
|
+
|
85
|
+
def publish(name, *args)
|
86
|
+
if @can_publish
|
87
|
+
@delegate.publish name, *args
|
88
|
+
end
|
82
89
|
end
|
83
90
|
|
84
91
|
def start(name, id, payload)
|
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.0.0.
|
4
|
+
version: 4.0.0.rc2
|
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: 2013-
|
11
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -132,14 +132,12 @@ files:
|
|
132
132
|
- lib/active_support/core_ext/date/acts_like.rb
|
133
133
|
- lib/active_support/core_ext/date/calculations.rb
|
134
134
|
- lib/active_support/core_ext/date/conversions.rb
|
135
|
-
- lib/active_support/core_ext/date/infinite_comparable.rb
|
136
135
|
- lib/active_support/core_ext/date/zones.rb
|
137
136
|
- lib/active_support/core_ext/date.rb
|
138
137
|
- lib/active_support/core_ext/date_and_time/calculations.rb
|
139
138
|
- lib/active_support/core_ext/date_time/acts_like.rb
|
140
139
|
- lib/active_support/core_ext/date_time/calculations.rb
|
141
140
|
- lib/active_support/core_ext/date_time/conversions.rb
|
142
|
-
- lib/active_support/core_ext/date_time/infinite_comparable.rb
|
143
141
|
- lib/active_support/core_ext/date_time/zones.rb
|
144
142
|
- lib/active_support/core_ext/date_time.rb
|
145
143
|
- lib/active_support/core_ext/enumerable.rb
|
@@ -154,7 +152,6 @@ files:
|
|
154
152
|
- lib/active_support/core_ext/hash/reverse_merge.rb
|
155
153
|
- lib/active_support/core_ext/hash/slice.rb
|
156
154
|
- lib/active_support/core_ext/hash.rb
|
157
|
-
- lib/active_support/core_ext/infinite_comparable.rb
|
158
155
|
- lib/active_support/core_ext/integer/inflections.rb
|
159
156
|
- lib/active_support/core_ext/integer/multiple.rb
|
160
157
|
- lib/active_support/core_ext/integer/time.rb
|
@@ -181,7 +178,6 @@ files:
|
|
181
178
|
- lib/active_support/core_ext/name_error.rb
|
182
179
|
- lib/active_support/core_ext/numeric/bytes.rb
|
183
180
|
- lib/active_support/core_ext/numeric/conversions.rb
|
184
|
-
- lib/active_support/core_ext/numeric/infinite_comparable.rb
|
185
181
|
- lib/active_support/core_ext/numeric/time.rb
|
186
182
|
- lib/active_support/core_ext/numeric.rb
|
187
183
|
- lib/active_support/core_ext/object/acts_like.rb
|
@@ -223,7 +219,6 @@ files:
|
|
223
219
|
- lib/active_support/core_ext/time/acts_like.rb
|
224
220
|
- lib/active_support/core_ext/time/calculations.rb
|
225
221
|
- lib/active_support/core_ext/time/conversions.rb
|
226
|
-
- lib/active_support/core_ext/time/infinite_comparable.rb
|
227
222
|
- lib/active_support/core_ext/time/marshal.rb
|
228
223
|
- lib/active_support/core_ext/time/zones.rb
|
229
224
|
- lib/active_support/core_ext/time.rb
|
@@ -326,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
321
|
version: 1.3.1
|
327
322
|
requirements: []
|
328
323
|
rubyforge_project:
|
329
|
-
rubygems_version: 2.0.
|
324
|
+
rubygems_version: 2.0.2
|
330
325
|
signing_key:
|
331
326
|
specification_version: 4
|
332
327
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
require 'active_support/core_ext/module/aliasing'
|
3
|
-
require 'active_support/core_ext/object/try'
|
4
|
-
|
5
|
-
module InfiniteComparable
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
alias_method_chain :<=>, :infinity
|
10
|
-
end
|
11
|
-
|
12
|
-
define_method :'<=>_with_infinity' do |other|
|
13
|
-
if other.class == self.class
|
14
|
-
public_send :'<=>_without_infinity', other
|
15
|
-
else
|
16
|
-
infinite = try(:infinite?)
|
17
|
-
other_infinite = other.try(:infinite?)
|
18
|
-
|
19
|
-
# inf <=> inf
|
20
|
-
if infinite && other_infinite
|
21
|
-
infinite <=> other_infinite
|
22
|
-
# not_inf <=> inf
|
23
|
-
elsif other_infinite
|
24
|
-
-other_infinite
|
25
|
-
# inf <=> not_inf
|
26
|
-
elsif infinite
|
27
|
-
infinite
|
28
|
-
else
|
29
|
-
conversion = "to_#{self.class.name.downcase}"
|
30
|
-
other = other.public_send(conversion) if other.respond_to?(conversion)
|
31
|
-
public_send :'<=>_without_infinity', other
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|