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

Changeset 8817

Show
Ignore:
Timestamp:
02/07/08 21:50:46 (7 months ago)
Author:
bitsweat
Message:

ActiveSupport::Base64.encode64s since Base64 is deprecated

Files:

Legend:

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

    r8434 r8817  
     1begin 
     2  require 'base64' 
     3rescue LoadError 
     4end 
     5 
    16module ActiveSupport 
    27  if defined? ::Base64 
  • trunk/activesupport/lib/active_support/core_ext/base64.rb

    r8816 r8817  
    1 require 'base64' 
    2  
     1require 'active_support/base64' 
    32require 'active_support/core_ext/base64/encoding' 
    43 
    5 module Base64#:nodoc: 
    6   extend ActiveSupport::CoreExtensions::Base64::Encoding 
    7 end 
     4ActiveSupport::Base64.extend ActiveSupport::CoreExtensions::Base64::Encoding 
  • trunk/activesupport/lib/active_support/core_ext/base64/encoding.rb

    r8816 r8817  
    66        # or memcache keys without further processing. 
    77        def encode64s(value) 
    8           ::Base64.encode64(value).gsub(/\n/, '') 
     8          encode64(value).gsub(/\n/, '') 
    99        end 
    1010      end 
  • trunk/activesupport/lib/active_support/core_ext/hash/conversions.rb

    r8579 r8817  
    7878            "string"       => Proc.new  { |string|  string.to_s }, 
    7979            "yaml"         => Proc.new  { |yaml|    YAML::load(yaml) rescue yaml }, 
    80             "base64Binary" => Proc.new  { |bin|     Base64.decode64(bin) }, 
     80            "base64Binary" => Proc.new  { |bin|     ActiveSupport::Base64.decode64(bin) }, 
    8181            "file"         => Proc.new do |file, entity| 
    82               f = StringIO.new(Base64.decode64(file)) 
     82              f = StringIO.new(ActiveSupport::Base64.decode64(file)) 
    8383              f.extend(FileLike) 
    8484              f.original_filename = entity['name'] 
  • trunk/activesupport/test/core_ext/base64_ext_test.rb

    r8816 r8817  
    33class Base64Test < Test::Unit::TestCase 
    44  def test_no_newline_in_encoded_value 
    5     assert_match /\n/,    Base64.encode64("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64"
    6     assert_no_match /\n/, Base64.encode64s("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64"
     5    assert_match(/\n/,    ActiveSupport::Base64.encode64("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64")
     6    assert_no_match(/\n/, ActiveSupport::Base64.encode64s("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64")
    77  end 
    88end