activesupport 2.0.2 → 2.0.4

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,6 +1,18 @@
1
- *SVN*
1
+ *2.0.4* (2nd September 2008)
2
2
 
3
- * Ruby 1.9 compatibility. #1689, #10466, #10468 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper]
3
+ * Fixed the rexml vulnerability disclosed at http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/ [koz]
4
+
5
+ * Remove :nodoc: entries around the ActiveSupport test/unit assertions. #10946 [dancroak, jamesh]
6
+
7
+ * Fixed String#titleize to work for strings with 's too #10571 [trek]
8
+
9
+ * Changed the implementation of Enumerable#group_by to use a double array approach instead of a hash such that the insert order is honored [DHH/Marcel]
10
+
11
+ * remove multiple enumerations from ActiveSupport::JSON#convert_json_to_yaml when dealing with date/time values. [rick]
12
+
13
+ * Hash#symbolize_keys skips keys that can't be symbolized. #10500 [Brad Greenlee]
14
+
15
+ * Ruby 1.9 compatibility. #1689, #10466, #10468, #10554 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink]
4
16
 
5
17
  * TimeZone#to_s uses UTC rather than GMT. #1689 [Cheah Chu Yeow]
6
18
 
@@ -45,5 +45,7 @@ require 'active_support/json'
45
45
 
46
46
  require 'active_support/multibyte'
47
47
 
48
+ require 'active_support/base64'
49
+
48
50
  require 'active_support/testing'
49
51
 
@@ -0,0 +1,17 @@
1
+ module ActiveSupport
2
+ if defined? ::Base64
3
+ Base64 = ::Base64
4
+ else
5
+ # Ruby 1.9 doesn't provide base64, so we wrap this here
6
+ module Base64
7
+
8
+ def self.encode64(data)
9
+ [data].pack("m")
10
+ end
11
+
12
+ def self.decode64(data)
13
+ data.unpack("m").first
14
+ end
15
+ end
16
+ end
17
+ end
@@ -90,7 +90,7 @@ module ActiveSupport
90
90
  end
91
91
 
92
92
  def flush
93
- @log.write(@buffer.slice!(0..-1).to_s) unless @buffer.empty?
93
+ @log.write(@buffer.slice!(0..-1).join) unless @buffer.empty?
94
94
  end
95
95
 
96
96
  def close
@@ -1,7 +1,7 @@
1
1
  module ActiveSupport #:nodoc:
2
2
  module CoreExtensions #:nodoc:
3
3
  module Date #:nodoc:
4
- # Getting dates in different convenient string representations and other objects
4
+ # Converting dates to formatted strings, times, and datetimes.
5
5
  module Conversions
6
6
  DATE_FORMATS = {
7
7
  :short => "%e %b",
@@ -26,10 +26,9 @@ module ActiveSupport #:nodoc:
26
26
  end
27
27
  end
28
28
 
29
- # Convert to a formatted string - see DATE_FORMATS for predefined formats.
30
- # You can also add your own formats to the DATE_FORMATS constant and use them with this method.
29
+ # Convert to a formatted string. See DATE_FORMATS for predefined formats.
31
30
  #
32
- # This method is also aliased as <tt>to_s</tt>.
31
+ # This method is aliased to <tt>to_s</tt>.
33
32
  #
34
33
  # ==== Examples:
35
34
  # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
@@ -41,6 +40,15 @@ module ActiveSupport #:nodoc:
41
40
  # date.to_formatted_s(:long) # => "November 10, 2007"
42
41
  # date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
43
42
  # date.to_formatted_s(:rfc822) # => "10 Nov 2007"
43
+ #
44
+ # == Adding your own time formats to to_formatted_s
45
+ # You can add your own formats to the Date::DATE_FORMATS hash.
46
+ # Use the format name as the hash key and either a strftime string
47
+ # or Proc instance that takes a date argument as the value.
48
+ #
49
+ # # config/initializers/time_formats.rb
50
+ # Date::DATE_FORMATS[:month_and_year] = "%B %Y"
51
+ # Date::DATE_FORMATS[:short_ordinal] = lambda { |date| date.strftime("%B #{date.day.ordinalize}") }
44
52
  def to_formatted_s(format = :default)
45
53
  if formatter = DATE_FORMATS[format]
46
54
  if formatter.respond_to?(:call)
@@ -1,9 +1,9 @@
1
1
  module ActiveSupport #:nodoc:
2
2
  module CoreExtensions #:nodoc:
3
3
  module DateTime #:nodoc:
4
- # Getting datetimes in different convenient string representations and other objects
4
+ # Converting datetimes to formatted strings, dates, and times.
5
5
  module Conversions
6
- def self.included(base)
6
+ def self.included(base) #:nodoc:
7
7
  base.class_eval do
8
8
  alias_method :to_datetime_default_s, :to_s
9
9
  alias_method :to_s, :to_formatted_s
@@ -15,11 +15,10 @@ module ActiveSupport #:nodoc:
15
15
  remove_method :to_time if base.instance_methods.include?(:to_time)
16
16
  end
17
17
  end
18
-
19
- # Convert to a formatted string - see DATE_FORMATS for predefined formats.
20
- # You can also add your own formats to the DATE_FORMATS constant and use them with this method.
18
+
19
+ # Convert to a formatted string. See Time::DATE_FORMATS for predefined formats.
21
20
  #
22
- # This method is also aliased as <tt>to_s</tt>.
21
+ # This method is aliased to <tt>to_s</tt>.
23
22
  #
24
23
  # === Examples:
25
24
  # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000
@@ -31,6 +30,16 @@ module ActiveSupport #:nodoc:
31
30
  # datetime.to_formatted_s(:long) # => "December 04, 2007 00:00"
32
31
  # datetime.to_formatted_s(:long_ordinal) # => "December 4th, 2007 00:00"
33
32
  # datetime.to_formatted_s(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000"
33
+ #
34
+ # == Adding your own datetime formats to to_formatted_s
35
+ # DateTime formats are shared with Time. You can add your own to the
36
+ # Time::DATE_FORMATS hash. Use the format name as the hash key and
37
+ # either a strftime string or Proc instance that takes a time or
38
+ # datetime argument as the value.
39
+ #
40
+ # # config/initializers/time_formats.rb
41
+ # Time::DATE_FORMATS[:month_and_year] = "%B %Y"
42
+ # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
34
43
  def to_formatted_s(format = :default)
35
44
  if formatter = ::Time::DATE_FORMATS[format]
36
45
  if formatter.respond_to?(:call)
@@ -15,9 +15,9 @@ module Enumerable
15
15
  # "2006-02-24 -> Transcript, Transcript"
16
16
  # "2006-02-23 -> Transcript"
17
17
  def group_by
18
- inject({}) do |groups, element|
19
- (groups[yield(element)] ||= []) << element
20
- groups
18
+ inject ActiveSupport::OrderedHash.new do |grouped, element|
19
+ (grouped[yield(element)] ||= []) << element
20
+ grouped
21
21
  end
22
22
  end if RUBY_VERSION < '1.9'
23
23
 
@@ -59,5 +59,4 @@ module Enumerable
59
59
  accum
60
60
  end
61
61
  end
62
-
63
62
  end
@@ -1,6 +1,5 @@
1
1
  require 'date'
2
2
  require 'cgi'
3
- require 'base64'
4
3
  require 'builder'
5
4
  require 'xmlsimple'
6
5
 
@@ -46,7 +45,7 @@ module ActiveSupport #:nodoc:
46
45
  "symbol" => Proc.new { |symbol| symbol.to_s },
47
46
  "date" => Proc.new { |date| date.to_s(:db) },
48
47
  "datetime" => Proc.new { |time| time.xmlschema },
49
- "binary" => Proc.new { |binary| Base64.encode64(binary) },
48
+ "binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) },
50
49
  "yaml" => Proc.new { |yaml| yaml.to_yaml }
51
50
  } unless defined?(XML_FORMATTING)
52
51
 
@@ -13,10 +13,7 @@ module ActiveSupport #:nodoc:
13
13
  # Destructively convert all keys to strings.
14
14
  def stringify_keys!
15
15
  keys.each do |key|
16
- unless key.class.to_s == "String" # weird hack to make the tests run when string_ext_test.rb is also running
17
- self[key.to_s] = self[key]
18
- delete(key)
19
- end
16
+ self[key.to_s] = delete(key)
20
17
  end
21
18
  self
22
19
  end
@@ -24,7 +21,7 @@ module ActiveSupport #:nodoc:
24
21
  # Return a new hash with all keys converted to symbols.
25
22
  def symbolize_keys
26
23
  inject({}) do |options, (key, value)|
27
- options[key.to_sym || key] = value
24
+ options[(key.to_sym rescue key) || key] = value
28
25
  options
29
26
  end
30
27
  end
@@ -38,11 +35,12 @@ module ActiveSupport #:nodoc:
38
35
  alias_method :to_options!, :symbolize_keys!
39
36
 
40
37
  # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch.
41
- # Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbol
38
+ # Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbols
42
39
  # as keys, this will fail.
43
- # examples:
40
+ #
41
+ # ==== Examples:
44
42
  # { :name => "Rob", :years => "28" }.assert_valid_keys(:name, :age) # => raises "ArgumentError: Unknown key(s): years"
45
- # { :name => "Rob", :age => "28" }.assert_valid_keys("name", "age") # => raises "ArgumentError: Unknown key(s): years, name"
43
+ # { :name => "Rob", :age => "28" }.assert_valid_keys("name", "age") # => raises "ArgumentError: Unknown key(s): name, age"
46
44
  # { :name => "Rob", :age => "28" }.assert_valid_keys(:name, :age) # => passes, raises nothing
47
45
  def assert_valid_keys(*valid_keys)
48
46
  unknown_keys = keys - [valid_keys].flatten
@@ -32,4 +32,10 @@ class Module
32
32
  ! inherited.key?(const) || inherited[const].object_id != const_get(const).object_id
33
33
  end
34
34
  end
35
+
36
+ # Returns the names of the constants defined locally rather than the
37
+ # constants themselves. See <tt>local_constants</tt>.
38
+ def local_constant_names
39
+ local_constants.map(&:to_s)
40
+ end
35
41
  end
@@ -7,12 +7,22 @@ module ActiveSupport #:nodoc:
7
7
  base.alias_method_chain :step, :blockless
8
8
  end
9
9
 
10
- def step_with_blockless(value, &block)
11
- if block_given?
12
- step_without_blockless(value, &block)
13
- else
14
- returning [] do |array|
15
- step_without_blockless(value) { |step| array << step }
10
+ if RUBY_VERSION < '1.9'
11
+ def step_with_blockless(value, &block)
12
+ if block_given?
13
+ step_without_blockless(value, &block)
14
+ else
15
+ returning [] do |array|
16
+ step_without_blockless(value) { |step| array << step }
17
+ end
18
+ end
19
+ end
20
+ else
21
+ def step_with_blockless(value, &block)
22
+ if block_given?
23
+ step_without_blockless(value, &block)
24
+ else
25
+ step_without_blockless(value).to_a
16
26
  end
17
27
  end
18
28
  end
@@ -0,0 +1,35 @@
1
+ require 'rexml/document'
2
+ require 'rexml/entity'
3
+
4
+ # Fixes the rexml vulnerability disclosed at:
5
+ # http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
6
+ # This fix is identical to rexml-expansion-fix version 1.0.1
7
+
8
+ unless REXML::VERSION > "3.1.7.2"
9
+ module REXML
10
+ class Entity < Child
11
+ undef_method :unnormalized
12
+ def unnormalized
13
+ document.record_entity_expansion! if document
14
+ v = value()
15
+ return nil if v.nil?
16
+ @unnormalized = Text::unnormalize(v, parent)
17
+ @unnormalized
18
+ end
19
+ end
20
+ class Document < Element
21
+ @@entity_expansion_limit = 10_000
22
+ def self.entity_expansion_limit= val
23
+ @@entity_expansion_limit = val
24
+ end
25
+
26
+ def record_entity_expansion!
27
+ @number_of_expansions ||= 0
28
+ @number_of_expansions += 1
29
+ if @number_of_expansions > @@entity_expansion_limit
30
+ raise "Number of entity expansions exceeded, processing aborted."
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -104,13 +104,16 @@ module ActiveSupport #:nodoc:
104
104
  Inflector.tableize(self)
105
105
  end
106
106
 
107
- # Create a class name from a table name like Rails does for table names to models.
107
+ # Create a class name from a plural table name like Rails does for table names to models.
108
108
  # Note that this returns a string and not a Class. (To convert to an actual class
109
109
  # follow classify with constantize.)
110
110
  #
111
111
  # Examples
112
112
  # "egg_and_hams".classify #=> "EggAndHam"
113
- # "post".classify #=> "Post"
113
+ # "posts".classify #=> "Post"
114
+ #
115
+ # Singular names are not handled correctly
116
+ # "business".classify #=> "Busines"
114
117
  def classify
115
118
  Inflector.classify(self)
116
119
  end
@@ -1,40 +1,59 @@
1
1
  module ActiveSupport #:nodoc:
2
2
  module CoreExtensions #:nodoc:
3
3
  module String #:nodoc:
4
- # Define methods for handling unicode data.
5
- module Unicode
6
- # +chars+ is a Unicode safe proxy for string methods. It creates and returns an instance of the
7
- # ActiveSupport::Multibyte::Chars class which encapsulates the original string. A Unicode safe version of all
8
- # the String methods are defined on this proxy class. Undefined methods are forwarded to String, so all of the
9
- # string overrides can also be called through the +chars+ proxy.
10
- #
11
- # name = 'Claus Müller'
12
- # name.reverse #=> "rell??M sualC"
13
- # name.length #=> 13
14
- #
15
- # name.chars.reverse.to_s #=> "rellüM sualC"
16
- # name.chars.length #=> 12
17
- #
18
- #
19
- # All the methods on the chars proxy which normally return a string will return a Chars object. This allows
20
- # method chaining on the result of any of these methods.
21
- #
22
- # name.chars.reverse.length #=> 12
23
- #
24
- # The Char object tries to be as interchangeable with String objects as possible: sorting and comparing between
25
- # String and Char work like expected. The bang! methods change the internal string representation in the Chars
26
- # object. Interoperability problems can be resolved easily with a +to_s+ call.
27
- #
28
- # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars and
29
- # ActiveSupport::Multibyte::Handlers::UTF8Handler
30
- def chars
31
- ActiveSupport::Multibyte::Chars.new(self)
4
+ if RUBY_VERSION < '1.9'
5
+ # Define methods for handling unicode data.
6
+ module Unicode
7
+ # +chars+ is a Unicode safe proxy for string methods. It creates and returns an instance of the
8
+ # ActiveSupport::Multibyte::Chars class which encapsulates the original string. A Unicode safe version of all
9
+ # the String methods are defined on this proxy class. Undefined methods are forwarded to String, so all of the
10
+ # string overrides can also be called through the +chars+ proxy.
11
+ #
12
+ # name = 'Claus Müller'
13
+ # name.reverse #=> "rell??M sualC"
14
+ # name.length #=> 13
15
+ #
16
+ # name.chars.reverse.to_s #=> "rellüM sualC"
17
+ # name.chars.length #=> 12
18
+ #
19
+ #
20
+ # All the methods on the chars proxy which normally return a string will return a Chars object. This allows
21
+ # method chaining on the result of any of these methods.
22
+ #
23
+ # name.chars.reverse.length #=> 12
24
+ #
25
+ # The Char object tries to be as interchangeable with String objects as possible: sorting and comparing between
26
+ # String and Char work like expected. The bang! methods change the internal string representation in the Chars
27
+ # object. Interoperability problems can be resolved easily with a +to_s+ call.
28
+ #
29
+ # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars and
30
+ # ActiveSupport::Multibyte::Handlers::UTF8Handler
31
+ def chars
32
+ ActiveSupport::Multibyte::Chars.new(self)
33
+ end
34
+
35
+ # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
36
+ # them), returns false otherwise.
37
+ def is_utf8?
38
+ ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)
39
+ end
32
40
  end
41
+ else
42
+ module Unicode #:nodoc:
43
+ def chars
44
+ self
45
+ end
33
46
 
34
- # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
35
- # them), returns false otherwise.
36
- def is_utf8?
37
- ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(self)
47
+ def is_utf8?
48
+ case encoding
49
+ when Encoding::UTF_8
50
+ valid_encoding?
51
+ when Encoding::ASCII_8BIT
52
+ dup.force_encoding('UTF-8').valid_encoding?
53
+ else
54
+ false
55
+ end
56
+ end
38
57
  end
39
58
  end
40
59
  end
@@ -1,7 +1,9 @@
1
- module Test #:nodoc:
2
- module Unit #:nodoc:
1
+ module Test
2
+ module Unit
3
+ #--
3
4
  # FIXME: no Proc#binding in Ruby 2, must change this API
4
- module Assertions #:nodoc:
5
+ #++
6
+ module Assertions
5
7
  # Test numeric difference between the return value of an expression as a result of what is evaluated
6
8
  # in the yielded block.
7
9
  #
@@ -1,7 +1,7 @@
1
1
  module ActiveSupport #:nodoc:
2
2
  module CoreExtensions #:nodoc:
3
3
  module Time #:nodoc:
4
- # Getting times in different convenient string representations and other objects
4
+ # Converting times to formatted strings, dates, and datetimes.
5
5
  module Conversions
6
6
  DATE_FORMATS = {
7
7
  :db => "%Y-%m-%d %H:%M:%S",
@@ -12,17 +12,16 @@ module ActiveSupport #:nodoc:
12
12
  :rfc822 => "%a, %d %b %Y %H:%M:%S %z"
13
13
  }
14
14
 
15
- def self.included(base)
15
+ def self.included(base) #:nodoc:
16
16
  base.class_eval do
17
17
  alias_method :to_default_s, :to_s
18
18
  alias_method :to_s, :to_formatted_s
19
19
  end
20
20
  end
21
21
 
22
- # Convert to a formatted string - see DATE_FORMATS for predefined formats.
23
- # You can also add your own formats to the DATE_FORMATS constant and use them with this method.
22
+ # Convert to a formatted string. See DATE_FORMATS for builtin formats.
24
23
  #
25
- # This method is also aliased as <tt>to_s</tt>.
24
+ # This method is aliased to <tt>to_s</tt>.
26
25
  #
27
26
  # ==== Examples:
28
27
  # time = Time.now # => Thu Jan 18 06:10:17 CST 2007
@@ -35,6 +34,15 @@ module ActiveSupport #:nodoc:
35
34
  # time.to_formatted_s(:long) # => "January 18, 2007 06:10"
36
35
  # time.to_formatted_s(:long_ordinal) # => "January 18th, 2007 06:10"
37
36
  # time.to_formatted_s(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
37
+ #
38
+ # == Adding your own time formats to to_formatted_s
39
+ # You can add your own formats to the Time::DATE_FORMATS hash.
40
+ # Use the format name as the hash key and either a strftime string
41
+ # or Proc instance that takes a time argument as the value.
42
+ #
43
+ # # config/initializers/time_formats.rb
44
+ # Time::DATE_FORMATS[:month_and_year] = "%B %Y"
45
+ # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
38
46
  def to_formatted_s(format = :default)
39
47
  if formatter = DATE_FORMATS[format]
40
48
  if formatter.respond_to?(:call)
@@ -286,7 +286,7 @@ module Dependencies #:nodoc:
286
286
 
287
287
  # Will the provided constant descriptor be unloaded?
288
288
  def will_unload?(const_desc)
289
- autoloaded?(desc) ||
289
+ autoloaded?(const_desc) ||
290
290
  explicitly_unloadable_constants.include?(to_constant_name(const_desc))
291
291
  end
292
292
 
@@ -318,13 +318,13 @@ module Dependencies #:nodoc:
318
318
  watch_frames = descs.collect do |desc|
319
319
  if desc.is_a? Module
320
320
  mod_name = desc.name
321
- initial_constants = desc.local_constants
321
+ initial_constants = desc.local_constant_names
322
322
  elsif desc.is_a?(String) || desc.is_a?(Symbol)
323
323
  mod_name = desc.to_s
324
324
 
325
325
  # Handle the case where the module has yet to be defined.
326
326
  initial_constants = if qualified_const_defined?(mod_name)
327
- mod_name.constantize.local_constants
327
+ mod_name.constantize.local_constant_names
328
328
  else
329
329
  []
330
330
  end
@@ -349,7 +349,7 @@ module Dependencies #:nodoc:
349
349
 
350
350
  mod = mod_name.constantize
351
351
  next [] unless mod.is_a? Module
352
- new_constants = mod.local_constants - prior_constants
352
+ new_constants = mod.local_constant_names - prior_constants
353
353
 
354
354
  # Make sure no other frames takes credit for these constants.
355
355
  constant_watch_stack.each do |frame_name, constants|
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'delegate'
2
3
 
3
4
  module ActiveSupport
4
5
  module Deprecation #:nodoc:
@@ -175,6 +176,20 @@ module ActiveSupport
175
176
  ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack)
176
177
  end
177
178
  end
179
+
180
+ class DeprecatedInstanceVariable < Delegator
181
+ def initialize(value, method)
182
+ super(value)
183
+ @method = method
184
+ @value = value
185
+ end
186
+
187
+ def __getobj__
188
+ ActiveSupport::Deprecation.warn("Instance variable @#{@method} is deprecated! Call instance method #{@method} instead.")
189
+ @value
190
+ end
191
+ end
192
+
178
193
  end
179
194
  end
180
195
 
@@ -162,7 +162,7 @@ module Inflector
162
162
  # "man from the boondocks".titleize #=> "Man From The Boondocks"
163
163
  # "x-men: the last stand".titleize #=> "X Men: The Last Stand"
164
164
  def titleize(word)
165
- humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize }
165
+ humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize }
166
166
  end
167
167
 
168
168
  # The reverse of +camelize+. Makes an underscored form from the expression in the string.
@@ -218,13 +218,16 @@ module Inflector
218
218
  pluralize(underscore(class_name))
219
219
  end
220
220
 
221
- # Create a class name from a table name like Rails does for table names to models.
221
+ # Create a class name from a plural table name like Rails does for table names to models.
222
222
  # Note that this returns a string and not a Class. (To convert to an actual class
223
223
  # follow classify with constantize.)
224
224
  #
225
225
  # Examples
226
226
  # "egg_and_hams".classify #=> "EggAndHam"
227
- # "post".classify #=> "Post"
227
+ # "posts".classify #=> "Post"
228
+ #
229
+ # Singular names are not handled correctly
230
+ # "business".classify #=> "Busines"
228
231
  def classify(table_name)
229
232
  # strip out any leading schema name
230
233
  camelize(singularize(table_name.to_s.sub(/.*\./, '')))
@@ -45,11 +45,14 @@ module ActiveSupport
45
45
  if marks.empty?
46
46
  json.gsub(/\\\//, '/')
47
47
  else
48
- # FIXME: multiple slow enumerations
49
- output = ([0] + marks.map(&:succ)).
50
- zip(marks + [json.length]).
51
- map { |left, right| json[left..right] }.
52
- join(" ")
48
+ left_pos = [-1].push(*marks)
49
+ right_pos = marks << json.length
50
+ output = []
51
+ left_pos.each_with_index do |left, i|
52
+ output << json[left.succ..right_pos[i]]
53
+ end
54
+ output = output * " "
55
+
53
56
  times.each { |i| output[i-1] = ' ' }
54
57
  output.gsub!(/\\\//, '/')
55
58
  output
@@ -119,14 +119,8 @@ module ActiveSupport::Multibyte #:nodoc:
119
119
 
120
120
  # +utf8_pragma+ checks if it can send this string to the handlers. It makes sure @string isn't nil and $KCODE is
121
121
  # set to 'UTF8'.
122
- if RUBY_VERSION < '1.9'
123
- def utf8_pragma?
124
- !@string.nil? && ($KCODE == 'UTF8')
125
- end
126
- else
127
- def utf8_pragma?
128
- !@string.nil? && (Encoding.default_external == Encoding::UTF_8)
129
- end
122
+ def utf8_pragma?
123
+ !@string.nil? && ($KCODE == 'UTF8')
130
124
  end
131
125
  end
132
126
  end
@@ -26,6 +26,12 @@ module ActiveSupport
26
26
  def values
27
27
  collect { |key, value| value }
28
28
  end
29
+
30
+ def to_hash
31
+ returning({}) do |hash|
32
+ each { |array| hash[array[0]] = array[1] }
33
+ end
34
+ end
29
35
  end
30
36
  end
31
37
  end
@@ -2,7 +2,7 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-12-20 00:00:00 -06:00
12
+ date: 2008-09-03 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,6 +25,7 @@ files:
25
25
  - CHANGELOG
26
26
  - README
27
27
  - lib/active_support
28
+ - lib/active_support/base64.rb
28
29
  - lib/active_support/basic_object.rb
29
30
  - lib/active_support/buffered_logger.rb
30
31
  - lib/active_support/clean_logger.rb
@@ -118,6 +119,7 @@ files:
118
119
  - lib/active_support/core_ext/range/include_range.rb
119
120
  - lib/active_support/core_ext/range/overlaps.rb
120
121
  - lib/active_support/core_ext/range.rb
122
+ - lib/active_support/core_ext/rexml.rb
121
123
  - lib/active_support/core_ext/string
122
124
  - lib/active_support/core_ext/string/access.rb
123
125
  - lib/active_support/core_ext/string/conversions.rb
@@ -220,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  requirements: []
221
223
 
222
224
  rubyforge_project: activesupport
223
- rubygems_version: 1.0.0
225
+ rubygems_version: 1.2.0
224
226
  signing_key:
225
227
  specification_version: 2
226
228
  summary: Support and utility classes used by the Rails framework.