activesupport 3.0.9 → 3.0.10.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 CHANGED
@@ -1,4 +1,11 @@
1
- *Rails 3.0.8 (unreleased)*
1
+ * Rails 3.0.10 (unreleased)
2
+
3
+ * Delayed backtrace scrubbing in `load_missing_constant` until we actually
4
+ raise the exception
5
+
6
+ *Rails 3.0.9 (June 16, 2011)*
7
+
8
+ *Rails 3.0.8 (June 7, 2011)*
2
9
 
3
10
  * No changes.
4
11
 
@@ -345,7 +345,7 @@ module ActiveSupport
345
345
  entry = read_entry(key, options)
346
346
  if entry
347
347
  if entry.expired?
348
- delete_entry(key)
348
+ delete_entry(key, options)
349
349
  else
350
350
  results[name] = entry.value
351
351
  end
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/kernel/singleton_class'
2
2
  require 'active_support/core_ext/module/remove_method'
3
+ require 'active_support/core_ext/array/extract_options'
3
4
 
4
5
  class Class
5
6
  # Declare a class-level attribute whose value is inheritable by subclasses.
@@ -56,11 +57,18 @@ class Class
56
57
  # object.setting # => false
57
58
  # Base.setting # => true
58
59
  #
60
+ # To opt out of the instance reader method, pass :instance_reader => false.
61
+ #
62
+ # object.setting # => NoMethodError
63
+ # object.setting? # => NoMethodError
64
+ #
59
65
  # To opt out of the instance writer method, pass :instance_writer => false.
60
66
  #
61
67
  # object.setting = false # => NoMethodError
62
68
  def class_attribute(*attrs)
63
- instance_writer = !attrs.last.is_a?(Hash) || attrs.pop[:instance_writer]
69
+ options = attrs.extract_options!
70
+ instance_reader = options.fetch(:instance_reader, true)
71
+ instance_writer = options.fetch(:instance_writer, true)
64
72
 
65
73
  attrs.each do |name|
66
74
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
@@ -75,12 +83,15 @@ class Class
75
83
  val
76
84
  end
77
85
 
78
- def #{name}
79
- defined?(@#{name}) ? @#{name} : singleton_class.#{name}
80
- end
86
+ if instance_reader
87
+ remove_possible_method :#{name}
88
+ def #{name}
89
+ defined?(@#{name}) ? @#{name} : singleton_class.#{name}
90
+ end
81
91
 
82
- def #{name}?
83
- !!#{name}
92
+ def #{name}?
93
+ !!#{name}
94
+ end
84
95
  end
85
96
  RUBY
86
97
 
@@ -75,10 +75,33 @@ end
75
75
  module ActiveSupport #:nodoc:
76
76
  class SafeBuffer < String
77
77
  UNSAFE_STRING_METHODS = ["capitalize", "chomp", "chop", "delete", "downcase", "gsub", "lstrip", "next", "reverse", "rstrip", "slice", "squeeze", "strip", "sub", "succ", "swapcase", "tr", "tr_s", "upcase"].freeze
78
- alias safe_concat concat
78
+
79
+ alias_method :original_concat, :concat
80
+ private :original_concat
81
+
82
+ class SafeConcatError < StandardError
83
+ def initialize
84
+ super "Could not concatenate to the buffer because it is not html safe."
85
+ end
86
+ end
87
+
88
+ def safe_concat(value)
89
+ raise SafeConcatError if dirty?
90
+ original_concat(value)
91
+ end
92
+
93
+ def initialize(*)
94
+ @dirty = false
95
+ super
96
+ end
97
+
98
+ def initialize_copy(other)
99
+ super
100
+ @dirty = other.dirty?
101
+ end
79
102
 
80
103
  def concat(value)
81
- if value.html_safe?
104
+ if dirty? || value.html_safe?
82
105
  super(value)
83
106
  else
84
107
  super(ERB::Util.h(value))
@@ -91,11 +114,7 @@ module ActiveSupport #:nodoc:
91
114
  end
92
115
 
93
116
  def html_safe?
94
- true
95
- end
96
-
97
- def html_safe
98
- self
117
+ !dirty?
99
118
  end
100
119
 
101
120
  def to_s
@@ -117,18 +136,21 @@ module ActiveSupport #:nodoc:
117
136
  end
118
137
 
119
138
  def #{unsafe_method}!(*args)
120
- raise TypeError, "Cannot modify SafeBuffer in place"
139
+ @dirty = true
140
+ super
121
141
  end
122
142
  EOT
123
143
  end
144
+
145
+ protected
146
+
147
+ def dirty?
148
+ @dirty
149
+ end
124
150
  end
125
151
  end
126
152
 
127
153
  class String
128
- def html_safe!
129
- raise "You can't call html_safe! on a String"
130
- end
131
-
132
154
  def html_safe
133
155
  ActiveSupport::SafeBuffer.new(self)
134
156
  end
@@ -481,10 +481,6 @@ module ActiveSupport #:nodoc:
481
481
  qualified_name = qualified_name_for from_mod, const_name
482
482
  path_suffix = qualified_name.underscore
483
483
 
484
- trace = caller.reject {|l| l =~ %r{#{Regexp.escape(__FILE__)}}}
485
- name_error = NameError.new("uninitialized constant #{qualified_name}")
486
- name_error.set_backtrace(trace)
487
-
488
484
  file_path = search_for_file(path_suffix)
489
485
 
490
486
  if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
@@ -503,11 +499,12 @@ module ActiveSupport #:nodoc:
503
499
  return parent.const_missing(const_name)
504
500
  rescue NameError => e
505
501
  raise unless e.missing_name? qualified_name_for(parent, const_name)
506
- raise name_error
507
502
  end
508
- else
509
- raise name_error
510
503
  end
504
+
505
+ raise NameError,
506
+ "uninitialized constant #{qualified_name}",
507
+ caller.reject {|l| l.starts_with? __FILE__ }
511
508
  end
512
509
 
513
510
  # Remove the constants that have been autoloaded, and those that have been
@@ -608,17 +605,6 @@ module ActiveSupport #:nodoc:
608
605
  return []
609
606
  end
610
607
 
611
- class LoadingModule #:nodoc:
612
- # Old style environment.rb referenced this method directly. Please note, it doesn't
613
- # actually *do* anything any more.
614
- def self.root(*args)
615
- if defined?(Rails) && Rails.logger
616
- Rails.logger.warn "Your environment.rb uses the old syntax, it may not continue to work in future releases."
617
- Rails.logger.warn "For upgrade instructions please see: http://manuals.rubyonrails.com/read/book/19"
618
- end
619
- end
620
- end
621
-
622
608
  # Convert the provided const desc to a qualified constant name (as a string).
623
609
  # A module, class, symbol, or string may be provided.
624
610
  def to_constant_name(desc) #:nodoc:
@@ -54,7 +54,9 @@ module ActiveSupport
54
54
  json.gsub(/\\([\\\/]|u[[:xdigit:]]{4})/) do
55
55
  ustr = $1
56
56
  if ustr.start_with?('u')
57
- [ustr[1..-1].to_i(16)].pack("U")
57
+ char = [ustr[1..-1].to_i(16)].pack("U")
58
+ # "\n" needs extra escaping due to yaml formatting
59
+ char == "\n" ? "\\n" : char
58
60
  elsif ustr == '\\'
59
61
  '\\\\'
60
62
  else
@@ -75,7 +77,9 @@ module ActiveSupport
75
77
  chunk.gsub!(/\\([\\\/]|u[[:xdigit:]]{4})/) do
76
78
  ustr = $1
77
79
  if ustr.start_with?('u')
78
- [ustr[1..-1].to_i(16)].pack("U")
80
+ char = [ustr[1..-1].to_i(16)].pack("U")
81
+ # "\n" needs extra escaping due to yaml formatting
82
+ char == "\n" ? "\\n" : char
79
83
  elsif ustr == '\\'
80
84
  '\\\\'
81
85
  else
@@ -2,8 +2,8 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 9
6
- PRE = nil
5
+ TINY = 10
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
4
+ prerelease: true
6
5
  segments:
7
6
  - 3
8
7
  - 0
9
- - 9
10
- version: 3.0.9
8
+ - 10
9
+ - rc1
10
+ version: 3.0.10.rc1
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Heinemeier Hansson
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-16 00:00:00 Z
18
+ date: 2011-08-04 00:00:00 -07:00
19
+ default_executable:
19
20
  dependencies: []
20
21
 
21
22
  description: A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing.
@@ -236,6 +237,7 @@ files:
236
237
  - lib/active_support/xml_mini/rexml.rb
237
238
  - lib/active_support/xml_mini.rb
238
239
  - lib/active_support.rb
240
+ has_rdoc: true
239
241
  homepage: http://www.rubyonrails.org
240
242
  licenses: []
241
243
 
@@ -245,29 +247,27 @@ rdoc_options: []
245
247
  require_paths:
246
248
  - lib
247
249
  required_ruby_version: !ruby/object:Gem::Requirement
248
- none: false
249
250
  requirements:
250
251
  - - ">="
251
252
  - !ruby/object:Gem::Version
252
- hash: 57
253
253
  segments:
254
254
  - 1
255
255
  - 8
256
256
  - 7
257
257
  version: 1.8.7
258
258
  required_rubygems_version: !ruby/object:Gem::Requirement
259
- none: false
260
259
  requirements:
261
- - - ">="
260
+ - - ">"
262
261
  - !ruby/object:Gem::Version
263
- hash: 3
264
262
  segments:
265
- - 0
266
- version: "0"
263
+ - 1
264
+ - 3
265
+ - 1
266
+ version: 1.3.1
267
267
  requirements: []
268
268
 
269
269
  rubyforge_project: activesupport
270
- rubygems_version: 1.8.2
270
+ rubygems_version: 1.3.6
271
271
  signing_key:
272
272
  specification_version: 3
273
273
  summary: A toolkit of support libraries and Ruby core extensions extracted from the Rails framework.