aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-02-07 21:50:46 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-02-07 21:50:46 +0000
commit3335bd12c8b3fbfe33ceda4b4f2f33ef023571da (patch)
tree8e257d33eeaf92629c4c3435cee61347755245cb /activesupport
parentfbd7ec3c9f0b1a5327ead66e0ac11b1d1d509f70 (diff)
downloadrails-3335bd12c8b3fbfe33ceda4b4f2f33ef023571da.tar.gz
rails-3335bd12c8b3fbfe33ceda4b4f2f33ef023571da.tar.bz2
rails-3335bd12c8b3fbfe33ceda4b4f2f33ef023571da.zip
ActiveSupport::Base64.encode64s since Base64 is deprecated
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8817 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/base64.rb5
-rw-r--r--activesupport/lib/active_support/core_ext/base64.rb7
-rw-r--r--activesupport/lib/active_support/core_ext/base64/encoding.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb4
-rw-r--r--activesupport/test/core_ext/base64_ext_test.rb4
5 files changed, 13 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb
index 4fc8cd13a7..602eef06b2 100644
--- a/activesupport/lib/active_support/base64.rb
+++ b/activesupport/lib/active_support/base64.rb
@@ -1,3 +1,8 @@
+begin
+ require 'base64'
+rescue LoadError
+end
+
module ActiveSupport
if defined? ::Base64
Base64 = ::Base64
diff --git a/activesupport/lib/active_support/core_ext/base64.rb b/activesupport/lib/active_support/core_ext/base64.rb
index d8b1813851..235e2edf57 100644
--- a/activesupport/lib/active_support/core_ext/base64.rb
+++ b/activesupport/lib/active_support/core_ext/base64.rb
@@ -1,7 +1,4 @@
-require 'base64'
-
+require 'active_support/base64'
require 'active_support/core_ext/base64/encoding'
-module Base64#:nodoc:
- extend ActiveSupport::CoreExtensions::Base64::Encoding
-end
+ActiveSupport::Base64.extend ActiveSupport::CoreExtensions::Base64::Encoding
diff --git a/activesupport/lib/active_support/core_ext/base64/encoding.rb b/activesupport/lib/active_support/core_ext/base64/encoding.rb
index 19671992d2..1a40da8785 100644
--- a/activesupport/lib/active_support/core_ext/base64/encoding.rb
+++ b/activesupport/lib/active_support/core_ext/base64/encoding.rb
@@ -5,9 +5,9 @@ module ActiveSupport #:nodoc:
# 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.
def encode64s(value)
- ::Base64.encode64(value).gsub(/\n/, '')
+ encode64(value).gsub(/\n/, '')
end
end
end
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb
index 8e80f6e4ff..470537fe24 100644
--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -77,9 +77,9 @@ module ActiveSupport #:nodoc:
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
"string" => Proc.new { |string| string.to_s },
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
- "base64Binary" => Proc.new { |bin| Base64.decode64(bin) },
+ "base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) },
"file" => Proc.new do |file, entity|
- f = StringIO.new(Base64.decode64(file))
+ f = StringIO.new(ActiveSupport::Base64.decode64(file))
f.extend(FileLike)
f.original_filename = entity['name']
f.content_type = entity['content_type']
diff --git a/activesupport/test/core_ext/base64_ext_test.rb b/activesupport/test/core_ext/base64_ext_test.rb
index aafbbd8539..bd0e9f843d 100644
--- a/activesupport/test/core_ext/base64_ext_test.rb
+++ b/activesupport/test/core_ext/base64_ext_test.rb
@@ -2,7 +2,7 @@ require 'abstract_unit'
class Base64Test < Test::Unit::TestCase
def test_no_newline_in_encoded_value
- assert_match /\n/, Base64.encode64("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64")
- assert_no_match /\n/, Base64.encode64s("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64")
+ assert_match(/\n/, ActiveSupport::Base64.encode64("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64"))
+ assert_no_match(/\n/, ActiveSupport::Base64.encode64s("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64"))
end
end