Sha256: 482257168bf71ada48afb351856de95f8ee359b59b76e84744311b8be3e88943

Contents?: true

Size: 1.54 KB

Versions: 195

Compression:

Stored size: 1.54 KB

Contents

require 'active_support/deprecation'

begin
  require 'base64'
rescue LoadError
  # The Base64 module isn't available in earlier versions of 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

unless Base64.respond_to?(:strict_encode64)
  # Included in Ruby 1.9
  def Base64.strict_encode64(value)
    encode64(value).gsub(/\n/, '')
  end
end

module ActiveSupport
  module Base64
    def self.encode64(value)
      ActiveSupport::Deprecation.warn "ActiveSupport::Base64.encode64 " \
        "is deprecated. Use Base64.encode64 instead", caller
      ::Base64.encode64(value)
    end

    def self.decode64(value)
      ActiveSupport::Deprecation.warn "ActiveSupport::Base64.decode64 " \
        "is deprecated. Use Base64.decode64 instead", caller
      ::Base64.decode64(value)
    end

    def self.encode64s(value)
      ActiveSupport::Deprecation.warn "ActiveSupport::Base64.encode64s " \
        "is deprecated. Use Base64.strict_encode64 instead", caller
      ::Base64.strict_encode64(value)
    end
  end
end

Version data entries

195 entries across 156 versions & 24 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/base64.rb
activesupport-3.2.22.5 lib/active_support/base64.rb
activesupport-3.2.22.4 lib/active_support/base64.rb
activesupport-3.2.22.3 lib/active_support/base64.rb
activesupport-3.2.22.2 lib/active_support/base64.rb
activesupport-3.2.22.1 lib/active_support/base64.rb
classiccms-0.7.5 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/base64.rb
classiccms-0.7.4 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/base64.rb
classiccms-0.7.3 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/base64.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/base64.rb
activesupport-3.2.22 lib/active_support/base64.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.12/lib/active_support/base64.rb
activesupport-3.2.21 lib/active_support/base64.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/base64.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/base64.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/base64.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/base64.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/base64.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/base64.rb
activesupport-3.2.20 lib/active_support/base64.rb