Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 310

Show
Ignore:
Timestamp:
01/02/05 15:16:59 (4 years ago)
Author:
david
Message:

Added test cases and rakefile to Active Support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/misc.rb

    r273 r310  
    11def silence_warnings 
    22  old_verbose, $VERBOSE = $VERBOSE, nil 
    3   result = yield 
    4   $VERBOSE = old_verbose 
    5   return result 
     3  begin 
     4    yield 
     5  ensure 
     6    $VERBOSE = old_verbose 
     7  end 
    68end 
     9 
     10class Hash 
     11  # Return a new hash with all keys converted to symbols. 
     12  def symbolize_keys 
     13    inject({}) do |options, (key, value)| 
     14      options[key.to_sym] = value 
     15      options 
     16    end 
     17  end 
     18 
     19  # Destructively convert all keys to symbols. 
     20  def symbolize_keys! 
     21    keys.each do |key| 
     22      unless key.is_a?(Symbol) 
     23        self[key.to_sym] = self[key] 
     24        delete(key) 
     25      end 
     26    end 
     27    self 
     28  end 
     29 
     30  alias_method :to_options,  :symbolize_keys 
     31  alias_method :to_options!, :symbolize_keys! 
     32end 
  • trunk/activesupport/test/dependencies_test.rb

    r273 r310  
    1 require File.dirname(__FILE__) + '/../abstract_unit' 
    2 require 'action_controller/support/dependencies' 
     1require 'test/unit' 
     2$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' 
     3require 'misc' 
     4require 'dependencies' 
    35 
    4 $LOAD_PATH << File.dirname(__FILE__) + '/../fixtures/dependencies' 
     6$LOAD_PATH.unshift File.dirname(__FILE__) + '/dependencies' 
    57 
    68class DependenciesTest < Test::Unit::TestCase 
  • trunk/activesupport/test/inflector_test.rb

    r273 r310  
    1 require 'abstract_unit' 
     1require 'test/unit' 
     2require File.dirname(__FILE__) + '/../lib/inflector' 
    23 
    34class InflectorTest < Test::Unit::TestCase