activesupport 3.1.12 → 3.2.0.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.
- data/CHANGELOG.md +1539 -30
- data/README.rdoc +2 -2
- data/lib/active_support.rb +1 -1
- data/lib/active_support/benchmarkable.rb +13 -18
- data/lib/active_support/buffered_logger.rb +43 -55
- data/lib/active_support/cache.rb +109 -115
- data/lib/active_support/cache/file_store.rb +6 -17
- data/lib/active_support/cache/mem_cache_store.rb +10 -2
- data/lib/active_support/cache/null_store.rb +44 -0
- data/lib/active_support/cache/strategy/local_cache.rb +2 -2
- data/lib/active_support/callbacks.rb +38 -35
- data/lib/active_support/concern.rb +5 -10
- data/lib/active_support/core_ext/array.rb +1 -0
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/prepend_and_append.rb +7 -0
- data/lib/active_support/core_ext/array/wrap.rb +1 -1
- data/lib/active_support/core_ext/class.rb +0 -1
- data/lib/active_support/core_ext/class/attribute_accessors.rb +3 -2
- data/lib/active_support/core_ext/date/calculations.rb +37 -14
- data/lib/active_support/core_ext/date/freeze.rb +6 -4
- data/lib/active_support/core_ext/date_time/calculations.rb +1 -1
- data/lib/active_support/core_ext/enumerable.rb +25 -8
- data/lib/active_support/core_ext/file/atomic.rb +1 -2
- data/lib/active_support/core_ext/hash/conversions.rb +7 -25
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -1
- data/lib/active_support/core_ext/io.rb +15 -0
- data/lib/active_support/core_ext/kernel.rb +0 -1
- data/lib/active_support/core_ext/kernel/agnostics.rb +2 -2
- data/lib/active_support/core_ext/kernel/debugger.rb +1 -7
- data/lib/active_support/core_ext/module.rb +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +6 -2
- data/lib/active_support/core_ext/module/delegation.rb +32 -21
- data/lib/active_support/core_ext/module/qualified_const.rb +64 -0
- data/lib/active_support/core_ext/module/reachable.rb +1 -3
- data/lib/active_support/core_ext/module/synchronization.rb +2 -0
- data/lib/active_support/core_ext/object/blank.rb +14 -2
- data/lib/active_support/core_ext/object/inclusion.rb +17 -7
- data/lib/active_support/core_ext/object/to_json.rb +2 -2
- data/lib/active_support/core_ext/range/conversions.rb +1 -1
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/inflections.rb +44 -6
- data/lib/active_support/core_ext/string/multibyte.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +22 -25
- data/lib/active_support/core_ext/time/calculations.rb +66 -12
- data/lib/active_support/dependencies.rb +51 -52
- data/lib/active_support/file_update_checker.rb +100 -15
- data/lib/active_support/hash_with_indifferent_access.rb +5 -1
- data/lib/active_support/i18n.rb +1 -1
- data/lib/active_support/i18n_railtie.rb +9 -4
- data/lib/active_support/inflections.rb +3 -3
- data/lib/active_support/inflector/inflections.rb +53 -92
- data/lib/active_support/inflector/methods.rb +173 -9
- data/lib/active_support/json/decoding.rb +3 -17
- data/lib/active_support/json/encoding.rb +11 -14
- data/lib/active_support/memoizable.rb +12 -1
- data/lib/active_support/message_encryptor.rb +52 -20
- data/lib/active_support/message_verifier.rb +15 -4
- data/lib/active_support/notifications.rb +87 -14
- data/lib/active_support/notifications/instrumenter.rb +1 -2
- data/lib/active_support/ordered_hash.rb +7 -3
- data/lib/active_support/tagged_logging.rb +63 -0
- data/lib/active_support/testing/assertions.rb +1 -1
- data/lib/active_support/testing/mochaing.rb +2 -2
- data/lib/active_support/testing/performance/ruby.rb +1 -1
- data/lib/active_support/testing/setup_and_teardown.rb +4 -12
- data/lib/active_support/time_with_zone.rb +6 -3
- data/lib/active_support/values/time_zone.rb +3 -7
- data/lib/active_support/version.rb +3 -3
- data/lib/active_support/xml_mini.rb +3 -3
- data/lib/active_support/xml_mini/jdom.rb +4 -10
- metadata +28 -21
- checksums.yaml +0 -7
- data/lib/active_support/cache/compressed_mem_cache_store.rb +0 -13
- data/lib/active_support/cache/synchronized_memory_store.rb +0 -11
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +0 -178
- data/lib/active_support/core_ext/kernel/requires.rb +0 -28
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +0 -31
- data/lib/active_support/secure_random.rb +0 -6
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 1e0afcd05d61c6d756671a65f45e15b09adb660f
|
4
|
-
data.tar.gz: 60507a2d7e6dda78bfa58f2553f2e6522afce85e
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: f74760e3517b2e80069e44c59de85694faa7c600c93946dda10ec6595c9359d485b32b80f81d87dd20e98a82ef7d2147beb68a48ca0345d855e561bc37ac9eaf
|
7
|
-
data.tar.gz: 94ea313909073c851292b47df2d458c527b222a6a6ba386c1955f45da75f146caa2d8a0cb310c8b648bfe88368ec4c443fc993d278a1bcebe5cb99b63b2a0dad
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ActiveSupport
|
2
|
-
module Cache
|
3
|
-
class CompressedMemCacheStore < MemCacheStore
|
4
|
-
def initialize(*args)
|
5
|
-
ActiveSupport::Deprecation.warn('ActiveSupport::Cache::CompressedMemCacheStore has been deprecated in favor of ActiveSupport::Cache::MemCacheStore(:compress => true).', caller)
|
6
|
-
addresses = args.dup
|
7
|
-
options = addresses.extract_options!
|
8
|
-
args = addresses + [options.merge(:compress => true)]
|
9
|
-
super(*args)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module ActiveSupport
|
2
|
-
module Cache
|
3
|
-
# Like MemoryStore, but thread-safe.
|
4
|
-
class SynchronizedMemoryStore < MemoryStore
|
5
|
-
def initialize(*args)
|
6
|
-
ActiveSupport::Deprecation.warn('ActiveSupport::Cache::SynchronizedMemoryStore has been deprecated in favor of ActiveSupport::Cache::MemoryStore.', caller)
|
7
|
-
super
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/duplicable'
|
2
|
-
require 'active_support/core_ext/array/extract_options'
|
3
|
-
require 'active_support/deprecation'
|
4
|
-
|
5
|
-
# Retained for backward compatibility. Methods are now included in Class.
|
6
|
-
module ClassInheritableAttributes # :nodoc:
|
7
|
-
DEPRECATION_WARNING_MESSAGE = "class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first"
|
8
|
-
end
|
9
|
-
|
10
|
-
# It is recommended to use <tt>class_attribute</tt> over methods defined in this file. Please
|
11
|
-
# refer to documentation for <tt>class_attribute</tt> for more information. Officially it is not
|
12
|
-
# deprecated but <tt>class_attribute</tt> is faster.
|
13
|
-
#
|
14
|
-
# Allows attributes to be shared within an inheritance hierarchy. Each descendant gets a copy of
|
15
|
-
# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements
|
16
|
-
# to, for example, an array without those additions being shared with either their parent, siblings, or
|
17
|
-
# children. This is unlike the regular class-level attributes that are shared across the entire hierarchy.
|
18
|
-
#
|
19
|
-
# The copies of inheritable parent attributes are added to subclasses when they are created, via the
|
20
|
-
# +inherited+ hook.
|
21
|
-
#
|
22
|
-
# class Person
|
23
|
-
# class_inheritable_accessor :hair_colors
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# Person.hair_colors = [:brown, :black, :blonde, :red]
|
27
|
-
# Person.hair_colors # => [:brown, :black, :blonde, :red]
|
28
|
-
# Person.new.hair_colors # => [:brown, :black, :blonde, :red]
|
29
|
-
#
|
30
|
-
# To opt out of the instance writer method, pass :instance_writer => false.
|
31
|
-
# To opt out of the instance reader method, pass :instance_reader => false.
|
32
|
-
#
|
33
|
-
# class Person
|
34
|
-
# class_inheritable_accessor :hair_colors :instance_writer => false, :instance_reader => false
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# Person.new.hair_colors = [:brown] # => NoMethodError
|
38
|
-
# Person.new.hair_colors # => NoMethodError
|
39
|
-
class Class # :nodoc:
|
40
|
-
def class_inheritable_reader(*syms)
|
41
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
42
|
-
options = syms.extract_options!
|
43
|
-
syms.each do |sym|
|
44
|
-
next if sym.is_a?(Hash)
|
45
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
46
|
-
def self.#{sym} # def self.after_add
|
47
|
-
read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:after_add)
|
48
|
-
end # end
|
49
|
-
#
|
50
|
-
#{" #
|
51
|
-
def #{sym} # def after_add
|
52
|
-
self.class.#{sym} # self.class.after_add
|
53
|
-
end # end
|
54
|
-
" unless options[:instance_reader] == false } # # the reader above is generated unless options[:instance_reader] == false
|
55
|
-
EOS
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def class_inheritable_writer(*syms)
|
60
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
61
|
-
options = syms.extract_options!
|
62
|
-
syms.each do |sym|
|
63
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
64
|
-
def self.#{sym}=(obj) # def self.color=(obj)
|
65
|
-
write_inheritable_attribute(:#{sym}, obj) # write_inheritable_attribute(:color, obj)
|
66
|
-
end # end
|
67
|
-
#
|
68
|
-
#{" #
|
69
|
-
def #{sym}=(obj) # def color=(obj)
|
70
|
-
self.class.#{sym} = obj # self.class.color = obj
|
71
|
-
end # end
|
72
|
-
" unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
|
73
|
-
EOS
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def class_inheritable_array_writer(*syms)
|
78
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
79
|
-
options = syms.extract_options!
|
80
|
-
syms.each do |sym|
|
81
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
82
|
-
def self.#{sym}=(obj) # def self.levels=(obj)
|
83
|
-
write_inheritable_array(:#{sym}, obj) # write_inheritable_array(:levels, obj)
|
84
|
-
end # end
|
85
|
-
#
|
86
|
-
#{" #
|
87
|
-
def #{sym}=(obj) # def levels=(obj)
|
88
|
-
self.class.#{sym} = obj # self.class.levels = obj
|
89
|
-
end # end
|
90
|
-
" unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
|
91
|
-
EOS
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def class_inheritable_hash_writer(*syms)
|
96
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
97
|
-
options = syms.extract_options!
|
98
|
-
syms.each do |sym|
|
99
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
100
|
-
def self.#{sym}=(obj) # def self.nicknames=(obj)
|
101
|
-
write_inheritable_hash(:#{sym}, obj) # write_inheritable_hash(:nicknames, obj)
|
102
|
-
end # end
|
103
|
-
#
|
104
|
-
#{" #
|
105
|
-
def #{sym}=(obj) # def nicknames=(obj)
|
106
|
-
self.class.#{sym} = obj # self.class.nicknames = obj
|
107
|
-
end # end
|
108
|
-
" unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
|
109
|
-
EOS
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def class_inheritable_accessor(*syms)
|
114
|
-
class_inheritable_reader(*syms)
|
115
|
-
class_inheritable_writer(*syms)
|
116
|
-
end
|
117
|
-
|
118
|
-
def class_inheritable_array(*syms)
|
119
|
-
class_inheritable_reader(*syms)
|
120
|
-
class_inheritable_array_writer(*syms)
|
121
|
-
end
|
122
|
-
|
123
|
-
def class_inheritable_hash(*syms)
|
124
|
-
class_inheritable_reader(*syms)
|
125
|
-
class_inheritable_hash_writer(*syms)
|
126
|
-
end
|
127
|
-
|
128
|
-
def inheritable_attributes
|
129
|
-
@inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES
|
130
|
-
end
|
131
|
-
|
132
|
-
def write_inheritable_attribute(key, value)
|
133
|
-
if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
|
134
|
-
@inheritable_attributes = {}
|
135
|
-
end
|
136
|
-
inheritable_attributes[key] = value
|
137
|
-
end
|
138
|
-
|
139
|
-
def write_inheritable_array(key, elements)
|
140
|
-
write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil?
|
141
|
-
write_inheritable_attribute(key, read_inheritable_attribute(key) + elements)
|
142
|
-
end
|
143
|
-
|
144
|
-
def write_inheritable_hash(key, hash)
|
145
|
-
write_inheritable_attribute(key, {}) if read_inheritable_attribute(key).nil?
|
146
|
-
write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash))
|
147
|
-
end
|
148
|
-
|
149
|
-
def read_inheritable_attribute(key)
|
150
|
-
inheritable_attributes[key]
|
151
|
-
end
|
152
|
-
|
153
|
-
def reset_inheritable_attributes
|
154
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
155
|
-
@inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
|
156
|
-
end
|
157
|
-
|
158
|
-
private
|
159
|
-
# Prevent this constant from being created multiple times
|
160
|
-
EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze
|
161
|
-
|
162
|
-
def inherited_with_inheritable_attributes(child)
|
163
|
-
inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)
|
164
|
-
|
165
|
-
if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
|
166
|
-
new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
|
167
|
-
else
|
168
|
-
new_inheritable_attributes = Hash[inheritable_attributes.map do |(key, value)|
|
169
|
-
[key, value.duplicable? ? value.dup : value]
|
170
|
-
end]
|
171
|
-
end
|
172
|
-
|
173
|
-
child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)
|
174
|
-
end
|
175
|
-
|
176
|
-
alias inherited_without_inheritable_attributes inherited
|
177
|
-
alias inherited inherited_with_inheritable_attributes
|
178
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/kernel/reporting'
|
2
|
-
require 'active_support/core_ext/module/deprecation'
|
3
|
-
|
4
|
-
module Kernel
|
5
|
-
# Require a library with fallback to RubyGems. Warnings during library
|
6
|
-
# loading are silenced to increase signal/noise for application warnings.
|
7
|
-
def require_library_or_gem(library_name)
|
8
|
-
silence_warnings do
|
9
|
-
begin
|
10
|
-
require library_name
|
11
|
-
rescue LoadError => cannot_require
|
12
|
-
# 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
|
13
|
-
begin
|
14
|
-
require 'rubygems'
|
15
|
-
rescue LoadError # => rubygems_not_installed
|
16
|
-
raise cannot_require
|
17
|
-
end
|
18
|
-
# 2. Rubygems is installed and loaded. Try to load the library again
|
19
|
-
begin
|
20
|
-
require library_name
|
21
|
-
rescue LoadError # => gem_not_installed
|
22
|
-
raise cannot_require
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
deprecate :require_library_or_gem
|
28
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
class Module
|
2
|
-
# Declare an attribute accessor with an initial default return value.
|
3
|
-
#
|
4
|
-
# To give attribute <tt>:age</tt> the initial value <tt>25</tt>:
|
5
|
-
#
|
6
|
-
# class Person
|
7
|
-
# attr_accessor_with_default :age, 25
|
8
|
-
# end
|
9
|
-
#
|
10
|
-
# person = Person.new
|
11
|
-
# person.age # => 25
|
12
|
-
#
|
13
|
-
# person.age = 26
|
14
|
-
# person.age # => 26
|
15
|
-
#
|
16
|
-
# To give attribute <tt>:element_name</tt> a dynamic default value, evaluated
|
17
|
-
# in scope of self:
|
18
|
-
#
|
19
|
-
# attr_accessor_with_default(:element_name) { name.underscore }
|
20
|
-
#
|
21
|
-
def attr_accessor_with_default(sym, default = Proc.new)
|
22
|
-
ActiveSupport::Deprecation.warn "attr_accessor_with_default is deprecated. Use Ruby instead!"
|
23
|
-
define_method(sym, block_given? ? default : Proc.new { default })
|
24
|
-
module_eval(<<-EVAL, __FILE__, __LINE__ + 1)
|
25
|
-
def #{sym}=(value) # def age=(value)
|
26
|
-
class << self; attr_accessor :#{sym} end # class << self; attr_accessor :age end
|
27
|
-
@#{sym} = value # @age = value
|
28
|
-
end # end
|
29
|
-
EVAL
|
30
|
-
end
|
31
|
-
end
|