Sha256: e9d3e0148dc019e3dfe66ac4adb84cf3ccd97a5df5fdf0bba802d181d17285cb

Contents?: true

Size: 1010 Bytes

Versions: 17

Compression:

Stored size: 1010 Bytes

Contents

module RubyGPG2
  module StatusLines
    class KeyCreated
      KEY_TYPES = {
          'B' => :primary_and_subkey,
          'P' => :primary,
          'S' => :subkey
      }

      def self.parse(line)
        match = line.match(/^\[GNUPG:\] KEY_CREATED (.) (.*?)(?: (.*))?$/)
        new(
            raw: line,
            key_type: KEY_TYPES[match[1]],
            key_fingerprint: match[2],
            handle: match[3])
      end

      attr_reader(
          :raw,
          :key_type,
          :key_fingerprint,
          :handle)

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

      def type
        :key_created
      end

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

      protected

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ruby_gpg2-0.9.0.pre.6 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.9.0.pre.5 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.9.0.pre.4 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.9.0.pre.3 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.9.0.pre.2 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.9.0.pre.1 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.8.0 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.7.0.pre.1 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.6.0 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.5.0.pre.1 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.4.0 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.3.0.pre.2 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.3.0.pre.1 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.2.0 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.1.0.pre.27 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.1.0.pre.26 lib/ruby_gpg2/status_lines/key_created.rb
ruby_gpg2-0.1.0.pre.25 lib/ruby_gpg2/status_lines/key_created.rb