Sha256: 475fb5a95fb5bd6d310abe5446dfdd4287e5054c315f27d4182638e7d5cbd14c

Contents?: true

Size: 829 Bytes

Versions: 16

Compression:

Stored size: 829 Bytes

Contents

module Mail::Parsers
  class PhraseListsParser

    def parse(s)
      actions, error = Ragel.parse(:phrase_lists, s)
      if error
        raise Mail::Field::ParseError.new(Mail::PhraseList, s, error)
      end

      phrase_lists = PhraseListsStruct.new([])

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

        # Phrase
        when :phrase_s then phrase_s = p
        when :phrase_e
          phrase_lists.phrases << s[phrase_s..(p-1)] if phrase_s
          phrase_s = nil

        when :comment_e, :comment_s, :qstr_s, :qstr_e then nil

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

      phrase_lists
    end
  end
end

Version data entries

16 entries across 15 versions & 7 rubygems

Version Path
mail-2.6.4.rc2 lib/mail/parsers/phrase_lists_parser.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
mail-2.6.4.rc1 lib/mail/parsers/phrase_lists_parser.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/mail-2.6.3/lib/mail/parsers/phrase_lists_parser.rb
mail-2.6.3 lib/mail/parsers/phrase_lists_parser.rb
mail-portertech-2.6.2.edge lib/mail/parsers/phrase_lists_parser.rb
mail-2.6.1 lib/mail/parsers/phrase_lists_parser.rb
mail-2.6.0 lib/mail/parsers/phrase_lists_parser.rb