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

Changeset 2179

Show
Ignore:
Timestamp:
09/11/05 04:58:27 (3 years ago)
Author:
david
Message:

Added Kernel#silence_warnings and puts it into use throughout the framework

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/lib/action_mailer.rb

    r2130 r2179  
    4949end 
    5050 
    51 old_verbose, $VERBOSE = $VERBOSE, nil 
    52 TMail::Encoder.const_set("MAX_LINE_LEN", 200) 
    53 $VERBOSE = old_verbose 
     51silence_warnings { TMail::Encoder.const_set("MAX_LINE_LEN", 200) } 
  • trunk/actionpack/test/controller/helper_test.rb

    r1425 r2179  
    122122 
    123123    def test_helper=(helper_module) 
    124       old_verbose, $VERBOSE = $VERBOSE, nil 
    125       self.class.const_set('TestHelper', helper_module) 
    126       $VERBOSE = old_verbose 
     124      silence_warnings { self.class.const_set('TestHelper', helper_module) } 
    127125    end 
    128126end 
  • trunk/actionpack/test/template/form_helper_test.rb

    r1789 r2179  
    77  include ActionView::Helpers::FormHelper 
    88 
    9   old_verbose, $VERBOSE = $VERBOSE, nil 
    10   Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on, :cost) 
    11   Post.class_eval do 
    12     alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) 
    13     alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) 
    14     alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) 
     9  silence_warnings do 
     10    Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on, :cost) 
     11    Post.class_eval do 
     12      alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) 
     13      alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) 
     14      alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) 
     15    end 
    1516  end 
    16   $VERBOSE = old_verbose 
    1717 
    1818  def setup 
  • trunk/actionpack/test/template/form_options_helper_test.rb

    r1646 r2179  
    2626  include ActionView::Helpers::FormOptionsHelper 
    2727 
    28   old_verbose, $VERBOSE = $VERBOSE, nil 
    29   Post      = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin) 
    30   Continent = Struct.new('Continent', :continent_name, :countries) 
    31   Country   = Struct.new('Country', :country_id, :country_name) 
    32   Firm      = Struct.new('Firm', :time_zone) 
    33   $VERBOSE = old_verbose 
     28  silence_warnings do 
     29    Post      = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin) 
     30    Continent = Struct.new('Continent', :continent_name, :countries) 
     31    Country   = Struct.new('Country', :country_id, :country_name) 
     32    Firm      = Struct.new('Firm', :time_zone) 
     33  end 
    3434 
    3535  def test_collection_options 
  • trunk/activesupport/CHANGELOG

    r2171 r2179  
    11*SVN* 
     2 
     3* Added Kernel#silence_warnings to turn off warnings temporarily for the passed block 
    24 
    35* Added String#starts_with? and String#ends_with? #2118 [thijs@vandervossen.net] 
  • trunk/activesupport/lib/active_support.rb

    r838 r2179  
    3030require 'active_support/core_ext' 
    3131require 'active_support/clean_logger' 
    32 require 'active_support/misc' 
    3332require 'active_support/dependencies' 
    3433 
  • trunk/activesupport/lib/active_support/core_ext/kernel.rb

    r1207 r2179  
    1515    value 
    1616  end 
     17   
     18  # Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards. 
     19  # 
     20  #   silence_warnings do 
     21  #     noisy_call # no warning voiced 
     22  #   end 
     23  # 
     24  #   noisy_call # warning voiced 
     25  def silence_warnings 
     26    old_verbose, $VERBOSE = $VERBOSE, nil 
     27    yield 
     28  ensure 
     29    $VERBOSE = old_verbose 
     30  end 
    1731end 
  • trunk/activesupport/test/core_ext/kernel_test.rb

    r624 r2179  
    11require 'test/unit' 
    2 require File.dirname(__FILE__) + '/../lib/active_support/misc
     2require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/kernel
    33 
    4 class MiscTest < Test::Unit::TestCase 
     4class KernelTest < Test::Unit::TestCase 
    55  def test_silence_warnings 
    66    silence_warnings { assert_nil $VERBOSE } 
  • trunk/activesupport/test/core_ext/string_ext_test.rb

    r2171 r2179  
    11require 'test/unit' 
     2require 'date' 
    23require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/string' 
    3 require File.dirname(__FILE__) + '/../../lib/active_support/misc
     4require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/kernel
    45 
    56silence_warnings do 
  • trunk/activesupport/test/dependencies_test.rb

    r624 r2179  
    11require 'test/unit' 
    22$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/active_support/' 
    3 require 'misc' 
    43require 'dependencies' 
    54 
  • trunk/railties/lib/initializer.rb

    r2134 r2179  
    7777      end 
    7878       
    79       old_verbose, $VERBOSE = $VERBOSE, nil 
    80       Object.const_set "RAILS_DEFAULT_LOGGER", logger 
    81       $VERBOSE = old_verbose 
     79      silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger } 
    8280    end 
    8381