diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-21 01:47:17 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-21 01:47:17 -0800 |
commit | 08dcd84b42475c06fd618db52390759e265c3d45 (patch) | |
tree | 44df79db1ed651169587276ef9013024bf9b3f41 | |
parent | afea8c794829535d5f2b721b484022a7318d9fff (diff) | |
parent | 55943873cdfc44aa55090d34602c2e1529d87590 (diff) | |
download | rails-08dcd84b42475c06fd618db52390759e265c3d45.tar.gz rails-08dcd84b42475c06fd618db52390759e265c3d45.tar.bz2 rails-08dcd84b42475c06fd618db52390759e265c3d45.zip |
Merge pull request #4089 from lest/remove-1-8-code
remove dead code as ruby 1.9.3 has Base64 module
-rw-r--r-- | activesupport/lib/active_support/base64.rb | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb index 35014cb3d5..b43d2ce9a3 100644 --- a/activesupport/lib/active_support/base64.rb +++ b/activesupport/lib/active_support/base64.rb @@ -1,35 +1,7 @@ -begin - require 'base64' -rescue LoadError -end +require 'base64' module ActiveSupport - if defined? ::Base64 - Base64 = ::Base64 - else - # Base64 provides utility methods for encoding and de-coding binary data - # using a base 64 representation. A base 64 representation of binary data - # consists entirely of printable US-ASCII characters. The Base64 module - # is included in Ruby 1.8, but has been removed in Ruby 1.9. - module Base64 - # Encodes a string to its base 64 representation. Each 60 characters of - # output is separated by a newline character. - # - # ActiveSupport::Base64.encode64("Original unencoded string") - # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n" - def self.encode64(data) - [data].pack("m") - end - - # Decodes a base 64 encoded string to its original representation. - # - # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==") - # # => "Original unencoded string" - def self.decode64(data) - data.unpack("m").first - end - end - end + Base64 = ::Base64 # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters # or memcache keys without further processing. |