activesupport 3.0.3 → 3.0.4.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/lib/active_support/cache.rb +3 -3
- data/lib/active_support/configurable.rb +13 -1
- data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -0
- data/lib/active_support/core_ext/date/conversions.rb +1 -1
- data/lib/active_support/core_ext/date_time/conversions.rb +1 -1
- data/lib/active_support/core_ext/module/synchronization.rb +1 -0
- data/lib/active_support/core_ext/string/output_safety.rb +14 -6
- data/lib/active_support/core_ext/time/conversions.rb +1 -1
- data/lib/active_support/dependencies.rb +1 -1
- data/lib/active_support/deprecation/proxy_wrappers.rb +1 -1
- data/lib/active_support/hash_with_indifferent_access.rb +3 -4
- data/lib/active_support/inflector/inflections.rb +1 -1
- data/lib/active_support/version.rb +4 -3
- data/lib/active_support/xml_mini/nokogirisax.rb +1 -2
- metadata +12 -9
data/lib/active_support/cache.rb
CHANGED
@@ -210,11 +210,11 @@ module ActiveSupport
|
|
210
210
|
# be specified as an option to the construction in which call all entries will be
|
211
211
|
# affected. Or it can be supplied to the +fetch+ or +write+ method for just one entry.
|
212
212
|
#
|
213
|
-
# cache = ActiveSupport::Cache::MemoryStore.new(:
|
214
|
-
# cache.write(key, value, :
|
213
|
+
# cache = ActiveSupport::Cache::MemoryStore.new(:expires_in => 5.minutes)
|
214
|
+
# cache.write(key, value, :expires_in => 1.minute) # Set a lower value for one entry
|
215
215
|
#
|
216
216
|
# Setting <tt>:race_condition_ttl</tt> is very useful in situations where a cache entry
|
217
|
-
# is used very frequently
|
217
|
+
# is used very frequently and is under heavy load. If a cache expires and due to heavy load
|
218
218
|
# seven different processes will try to read data natively and then they all will try to
|
219
219
|
# write to cache. To avoid that case the first process to find an expired cache entry will
|
220
220
|
# bump the cache expiration time by the value set in <tt>:race_condition_ttl</tt>. Yes
|
@@ -16,6 +16,18 @@ module ActiveSupport
|
|
16
16
|
yield config
|
17
17
|
end
|
18
18
|
|
19
|
+
# Allows you to add shortcut so that you don't have to refer to attribute through config.
|
20
|
+
# Also look at the example for config to contrast.
|
21
|
+
#
|
22
|
+
# class User
|
23
|
+
# include ActiveSupport::Configurable
|
24
|
+
# config_accessor :allowed_access
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# user = User.new
|
28
|
+
# user.allowed_access = true
|
29
|
+
# user.allowed_access # => true
|
30
|
+
#
|
19
31
|
def config_accessor(*names)
|
20
32
|
names.each do |name|
|
21
33
|
code, line = <<-RUBY, __LINE__ + 1
|
@@ -33,4 +45,4 @@ module ActiveSupport
|
|
33
45
|
@_config ||= ActiveSupport::InheritableOptions.new(self.class.config)
|
34
46
|
end
|
35
47
|
end
|
36
|
-
end
|
48
|
+
end
|
@@ -32,15 +32,23 @@ class ERB
|
|
32
32
|
singleton_class.send(:remove_method, :html_escape)
|
33
33
|
module_function :html_escape
|
34
34
|
|
35
|
-
# A utility method for escaping HTML entities in JSON strings
|
36
|
-
#
|
35
|
+
# A utility method for escaping HTML entities in JSON strings
|
36
|
+
# using \uXXXX JavaScript escape sequences for string literals:
|
37
|
+
#
|
38
|
+
# json_escape("is a > 0 & a < 10?")
|
39
|
+
# # => is a \u003E 0 \u0026 a \u003C 10?
|
40
|
+
#
|
41
|
+
# Note that after this operation is performed the output is not
|
42
|
+
# valid JSON. In particular double quotes are removed:
|
43
|
+
#
|
44
|
+
# json_escape('{"name":"john","created_at":"2010-04-28T01:39:31Z","id":1}')
|
45
|
+
# # => {name:john,created_at:2010-04-28T01:39:31Z,id:1}
|
46
|
+
#
|
47
|
+
# This method is also aliased as +j+, and available as a helper
|
48
|
+
# in Rails templates:
|
37
49
|
#
|
38
|
-
# In your ERb templates, use this method to escape any HTML entities:
|
39
50
|
# <%=j @person.to_json %>
|
40
51
|
#
|
41
|
-
# ==== Example:
|
42
|
-
# puts json_escape("is a > 0 & a < 10?")
|
43
|
-
# # => is a \u003E 0 \u0026 a \u003C 10?
|
44
52
|
def json_escape(s)
|
45
53
|
s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] }
|
46
54
|
end
|
@@ -331,7 +331,7 @@ module ActiveSupport #:nodoc:
|
|
331
331
|
if load?
|
332
332
|
log "loading #{file_name}"
|
333
333
|
|
334
|
-
# Enable warnings
|
334
|
+
# Enable warnings if this file has not been loaded before and
|
335
335
|
# warnings_on_first_load is set.
|
336
336
|
load_args = ["#{file_name}.rb"]
|
337
337
|
load_args << const_path unless const_path.nil?
|
@@ -138,11 +138,10 @@ module ActiveSupport
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def convert_value(value)
|
141
|
-
|
142
|
-
when Hash
|
141
|
+
if value.class == Hash
|
143
142
|
self.class.new_from_hash_copying_default(value)
|
144
|
-
|
145
|
-
value.
|
143
|
+
elsif value.is_a?(Array)
|
144
|
+
value.dup.replace(value.map { |e| convert_value(e) })
|
146
145
|
else
|
147
146
|
value
|
148
147
|
end
|
@@ -148,7 +148,7 @@ module ActiveSupport
|
|
148
148
|
def singularize(word)
|
149
149
|
result = word.to_s.dup
|
150
150
|
|
151
|
-
if inflections.uncountables.any? { |inflection| result =~
|
151
|
+
if inflections.uncountables.any? { |inflection| result =~ /\b(#{inflection})\Z/i }
|
152
152
|
result
|
153
153
|
else
|
154
154
|
inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
@@ -38,8 +38,7 @@ module ActiveSupport
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def start_element(name, attrs = [])
|
41
|
-
new_hash = { CONTENT_KEY => '' }
|
42
|
-
new_hash[attrs.shift] = attrs.shift while attrs.length > 0
|
41
|
+
new_hash = { CONTENT_KEY => '' }.merge(Hash[attrs])
|
43
42
|
new_hash[HASH_SIZE_KEY] = new_hash.size + 1
|
44
43
|
|
45
44
|
case current_hash[name]
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 977940590
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
|
9
|
+
- 4
|
10
|
+
- rc1
|
11
|
+
version: 3.0.4.rc1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- David Heinemeier Hansson
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
+
date: 2011-01-31 00:00:00 +13:00
|
19
20
|
default_executable:
|
20
21
|
dependencies: []
|
21
22
|
|
@@ -260,12 +261,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
260
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
262
|
none: false
|
262
263
|
requirements:
|
263
|
-
- - "
|
264
|
+
- - ">"
|
264
265
|
- !ruby/object:Gem::Version
|
265
|
-
hash:
|
266
|
+
hash: 25
|
266
267
|
segments:
|
267
|
-
-
|
268
|
-
|
268
|
+
- 1
|
269
|
+
- 3
|
270
|
+
- 1
|
271
|
+
version: 1.3.1
|
269
272
|
requirements: []
|
270
273
|
|
271
274
|
rubyforge_project: activesupport
|