Completed
Push — master ( fde2ba...d387dd )
by Fike
01:07
created

KeyPair.normalize()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285

1 Method

Rating   Name   Duplication   Size   Complexity  
A KeyPair.compute_private_key() 0 4 1
1
# frozen_string_literal: true
2
3
# rubocop:disable Style/Documentation
4
5
require_relative 'public_key'
6
require_relative 'private_key'
7
8
module AMA
9
  module Chef
10
    module SSHPrivateKeys
11
      module Model
12
        class KeyPair
13
          attr_accessor :type
14
          attr_accessor :public_key
15
          attr_accessor :private_key
16
          attr_accessor :passphrase
17
          attr_accessor :comment
18
19
          def compute_private_key
20
            klass = ::AMA::Chef::SSHPrivateKeys::Model::PrivateKey
21
            klass.new(private_key, passphrase)
22
          end
23
24
          def compute_public_key
25
            return nil unless public_key && type
26
            klass = ::AMA::Chef::SSHPrivateKeys::Model::PublicKey
27
            klass.new(type, public_key, comment)
28
          end
29
        end
30
      end
31
    end
32
  end
33
end
34