Sha256: 59f7303fb36b9776d7a5266465952cdf38a2e622324759be0383061354366e17

Contents?: true

Size: 1.12 KB

Versions: 22

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
module Mail::Parsers
  class MimeVersionParser
    include Mail::Utilities

    def parse(s)
      if Mail::Utilities.blank?(s)
        return MimeVersionStruct.new("", nil)
      end

      mime_version = MimeVersionStruct.new

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

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

        # Major Digits
        when :major_digits_s then major_digits_s = p
        when :major_digits_e
          mime_version.major = s[major_digits_s..(p-1)]

        # Minor Digits
        when :minor_digits_s then minor_digits_s = p
        when :minor_digits_e
          mime_version.minor = s[minor_digits_s..(p-1)]

        when :comment_e, :comment_s then nil

        else
          raise Mail::Field::ParseError.new(Mail::MimeVersionElement, s, "Failed to process unknown action: #{action}")
        end
      end
      mime_version
    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/mime_version_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.6/lib/mail/parsers/mime_version_parser.rb
mail-2.6.6 lib/mail/parsers/mime_version_parser.rb
mail-2.6.6.rc1 lib/mail/parsers/mime_version_parser.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/mail-2.6.5/lib/mail/parsers/mime_version_parser.rb
mail-2.6.5 lib/mail/parsers/mime_version_parser.rb
mail-2.6.5.rc1 lib/mail/parsers/mime_version_parser.rb
tdiary-5.0.4 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
abaci-0.3.0 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
tdiary-5.0.2 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb
tdiary-5.0.1 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/mime_version_parser.rb