Changeset 8817
- Timestamp:
- 02/07/08 21:50:46 (7 months ago)
- Files:
-
- trunk/activesupport/lib/active_support/base64.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/base64.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/base64/encoding.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/hash/conversions.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/base64_ext_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/base64.rb
r8434 r8817 1 begin 2 require 'base64' 3 rescue LoadError 4 end 5 1 6 module ActiveSupport 2 7 if defined? ::Base64 trunk/activesupport/lib/active_support/core_ext/base64.rb
r8816 r8817 1 require 'base64' 2 1 require 'active_support/base64' 3 2 require 'active_support/core_ext/base64/encoding' 4 3 5 module Base64#:nodoc: 6 extend ActiveSupport::CoreExtensions::Base64::Encoding 7 end 4 ActiveSupport::Base64.extend ActiveSupport::CoreExtensions::Base64::Encoding trunk/activesupport/lib/active_support/core_ext/base64/encoding.rb
r8816 r8817 6 6 # or memcache keys without further processing. 7 7 def encode64s(value) 8 ::Base64.encode64(value).gsub(/\n/, '')8 encode64(value).gsub(/\n/, '') 9 9 end 10 10 end trunk/activesupport/lib/active_support/core_ext/hash/conversions.rb
r8579 r8817 78 78 "string" => Proc.new { |string| string.to_s }, 79 79 "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) }, 81 81 "file" => Proc.new do |file, entity| 82 f = StringIO.new( Base64.decode64(file))82 f = StringIO.new(ActiveSupport::Base64.decode64(file)) 83 83 f.extend(FileLike) 84 84 f.original_filename = entity['name'] trunk/activesupport/test/core_ext/base64_ext_test.rb
r8816 r8817 3 3 class Base64Test < Test::Unit::TestCase 4 4 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")) 7 7 end 8 8 end