Sha256: b8ae54ab63fdfe1d2c534f4f2bfa3ca9eb9a684823139a26ca877898ef288e62

Contents?: true

Size: 956 Bytes

Versions: 16

Compression:

Stored size: 956 Bytes

Contents

# frozen_string_literal: true

module RubyGPG2
  module StatusLines
    class KeyConsidered
      FLAGS = {
        '0' => [],
        '1' => [:key_not_selected],
        '2' => [:all_subkeys_expired_or_revoked]
      }.freeze

      def self.parse(line)
        match = line.match(/^\[GNUPG:\] KEY_CONSIDERED (.*) (.*)$/)
        new(
          raw: line,
          key_fingerprint: match[1],
          flags: FLAGS[match[2]]
        )
      end

      attr_reader(
        :raw,
        :key_fingerprint,
        :flags
      )

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

      def type
        :key_considered
      end

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

      protected

      def state
        [
          @raw,
          @key_fingerprint,
          @flags
        ]
      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/key_considered.rb
ruby_gpg2-0.13.0.pre.3 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.13.0.pre.2 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.13.0.pre.1 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.12.0 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.11.0.pre.7 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.11.0.pre.6 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.11.0.pre.5 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.11.0.pre.4 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.11.0.pre.3 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.11.0.pre.2 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.11.0.pre.1 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.10.0 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.9.0.pre.9 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.9.0.pre.8 lib/ruby_gpg2/status_lines/key_considered.rb
ruby_gpg2-0.9.0.pre.7 lib/ruby_gpg2/status_lines/key_considered.rb