Sha256: bf0958590af5cae089f6fdb5eb609cd9b0f81d68493fccda06f3c01a0f40e6c4

Contents?: true

Size: 1.03 KB

Versions: 22

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true
module Mail::Parsers
  class MessageIdsParser
    def parse(s)
      if Mail::Utilities.blank?(s)
        return MessageIdsStruct.new
      end

      message_ids = MessageIdsStruct.new([])

      actions, error = Ragel.parse(:message_ids, s)
      if error
        raise Mail::Field::ParseError.new(Mail::MessageIdsElement, s, error)
      end

      msg_id_s = nil
      actions.each_slice(2) do |action_id, p|
        action = Mail::Parsers::Ragel::ACTIONS[action_id]
        case action

        # Message Ids
        when :msg_id_s then msg_id_s = p
        when :msg_id_e
          message_ids.message_ids << s[msg_id_s..(p-1)].rstrip

        when :domain_e, :domain_s, :local_dot_atom_e,
          :local_dot_atom_pre_comment_e,
          :local_dot_atom_pre_comment_s,
          :local_dot_atom_s

          # ignored actions

        else
          raise Mail::Field::ParseError.new(Mail::MessageIdsElement, s, "Failed to process unknown action: #{action}")
        end
      end
      message_ids
    end
  end
end

Version data entries

22 entries across 20 versions & 6 rubygems

Version Path
tdiary-5.0.6 vendor/bundle/gems/mail-2.6.6/lib/mail/parsers/message_ids_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.6/lib/mail/parsers/message_ids_parser.rb
mail-2.6.6 lib/mail/parsers/message_ids_parser.rb
mail-2.6.6.rc1 lib/mail/parsers/message_ids_parser.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/mail-2.6.5/lib/mail/parsers/message_ids_parser.rb
mail-2.6.5 lib/mail/parsers/message_ids_parser.rb
mail-2.6.5.rc1 lib/mail/parsers/message_ids_parser.rb
tdiary-5.0.4 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
abaci-0.3.0 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
tdiary-5.0.2 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb
tdiary-5.0.1 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/message_ids_parser.rb