Sha256: e6f16237ab876f1cdae697c4a6ec6ce4ebb6bd20f417ff60219087c3b59d4086

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module RubyGPG2
  module StatusLines
    class ImportProblem
      REASONS = {
        0 => :no_reason_given,
        1 => :invalid_certificate,
        2 => :issuer_certificate_missing,
        3 => :certificate_chain_too_long,
        4 => :error_storing_certificate
      }.freeze

      def self.parse(line)
        match = line.match(/^\[GNUPG:\] IMPORT_PROBLEM (\d+) (.*)$/)
        new(
          raw: line,
          reason: REASONS[match[1].to_i],
          key_fingerprint: match[2]
        )
      end

      attr_reader(
        :raw,
        :reason,
        :key_fingerprint
      )

      def initialize(opts)
        @raw = opts[:raw]
        @reason = opts[:reason]
        @key_fingerprint = opts[:key_fingerprint]
      end

      def type
        :import_problem
      end

      def ==(other)
        other.class == self.class && other.state == state
      end

      protected

      def state
        [
          @raw,
          @reason,
          @key_fingerprint
        ]
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_gpg2-0.13.0.pre.4 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.13.0.pre.3 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.13.0.pre.2 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.13.0.pre.1 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.12.0 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.11.0.pre.7 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.11.0.pre.6 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.11.0.pre.5 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.11.0.pre.4 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.11.0.pre.3 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.11.0.pre.2 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.11.0.pre.1 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.10.0 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.9.0.pre.9 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.9.0.pre.8 lib/ruby_gpg2/status_lines/import_problem.rb
ruby_gpg2-0.9.0.pre.7 lib/ruby_gpg2/status_lines/import_problem.rb