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.

@@ -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(:expire_in => 5.minutes)
214
- # cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry
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 unver heavy load. If a cache expires and due to heavy load
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
@@ -18,6 +18,10 @@ class BigDecimal
18
18
  end
19
19
  end
20
20
 
21
+ def to_d
22
+ self
23
+ end
24
+
21
25
  DEFAULT_STRING_FORMAT = 'F'
22
26
  def to_formatted_s(format = DEFAULT_STRING_FORMAT)
23
27
  _original_to_s(format)
@@ -1,5 +1,5 @@
1
1
  require 'date'
2
- require 'active_support/inflector'
2
+ require 'active_support/inflector/methods'
3
3
  require 'active_support/core_ext/date/zones'
4
4
 
5
5
  class Date
@@ -1,4 +1,4 @@
1
- require 'active_support/inflector'
1
+ require 'active_support/inflector/methods'
2
2
  require 'active_support/core_ext/time/conversions'
3
3
  require 'active_support/core_ext/date_time/calculations'
4
4
  require 'active_support/values/time_zone'
@@ -1,3 +1,4 @@
1
+ require 'thread'
1
2
  require 'active_support/core_ext/module/aliasing'
2
3
  require 'active_support/core_ext/array/extract_options'
3
4
 
@@ -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
- # This method is also aliased as <tt>j</tt>.
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
@@ -1,4 +1,4 @@
1
- require 'active_support/inflector'
1
+ require 'active_support/inflector/methods'
2
2
  require 'active_support/core_ext/time/publicize_conversion_methods'
3
3
  require 'active_support/values/time_zone'
4
4
 
@@ -331,7 +331,7 @@ module ActiveSupport #:nodoc:
331
331
  if load?
332
332
  log "loading #{file_name}"
333
333
 
334
- # Enable warnings iff this file has not been loaded before and
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?
@@ -1,4 +1,4 @@
1
- require 'active_support/inflector'
1
+ require 'active_support/inflector/methods'
2
2
 
3
3
  module ActiveSupport
4
4
  module Deprecation
@@ -138,11 +138,10 @@ module ActiveSupport
138
138
  end
139
139
 
140
140
  def convert_value(value)
141
- case value
142
- when Hash
141
+ if value.class == Hash
143
142
  self.class.new_from_hash_copying_default(value)
144
- when Array
145
- value.collect { |e| e.is_a?(Hash) ? self.class.new_from_hash_copying_default(e) : e }
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 =~ /#{inflection}\Z/i }
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) }
@@ -2,8 +2,9 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 3
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
5
+ TINY = 4
6
+ PRE = "rc1"
7
+
8
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
8
9
  end
9
10
  end
@@ -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: 1
5
- prerelease: false
4
+ hash: 977940590
5
+ prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 3
10
- version: 3.0.3
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: 2010-11-16 00:00:00 -06:00
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: 3
266
+ hash: 25
266
267
  segments:
267
- - 0
268
- version: "0"
268
+ - 1
269
+ - 3
270
+ - 1
271
+ version: 1.3.1
269
272
  requirements: []
270
273
 
271
274
  rubyforge_project: activesupport