Sha256: 660bff34584c5d0c7bd372383316bedeba656d4ecd2e63d214d3b55a51e6e40c

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

require 'dkim/header'
require 'dkim/tag_value_list'
require 'dkim/encodings'

module Dkim
  class DkimHeader < Header
    attr_reader :list
    def initialize values={}
      self.key = 'DKIM-Signature'
      @list = TagValueList.new values
    end
    def value
      " #{@list}"
    end
    def [] k
      encoder_for(k).decode(@list[k])
    end
    def []= k, v
      @list[k] = encoder_for(k).encode(v)
    end

    private
    def encoder_for key
      case key
      when *%w{v a c d h l q s t x}
        Encodings::PlainText
      when *%w{i z}
        Encodings::DkimQuotedPrintable
      when *%w{b bh}
        Encodings::Base64
      else
        raise "unknown key: #{key}"
      end.new
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dkim-1.1.0 lib/dkim/dkim_header.rb
dkim-1.0.1 lib/dkim/dkim_header.rb
dkim-1.0.0 lib/dkim/dkim_header.rb