Class: Vinz::Clortho::SSHKeyPathManager

Inherits:
Object
  • Object
show all
Defined in:
lib/vinz/clortho/ssh_key_path_manager.rb

Constant Summary collapse

DEFAULT_KEY_PATH =
'/Volumes/*/.ssh/id_rsa'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSSHKeyPathManager

Returns a new instance of SSHKeyPathManager.



21
22
23
24
25
26
27
28
29
30
# File 'lib/vinz/clortho/ssh_key_path_manager.rb', line 21

def initialize
  @key_paths = if git_authors_file.nil?
    Dir[DEFAULT_KEY_PATH].map { |path| KeyPathEntry.new(path) }
  else
    git_authors = YAML::load_file(git_authors_file)
    git_authors['sshkey_paths'].map do |initials, path|
      KeyPathEntry.new(path, initials)
    end
  end
end

Instance Attribute Details

#key_pathsObject (readonly)

Returns the value of attribute key_paths.



17
18
19
# File 'lib/vinz/clortho/ssh_key_path_manager.rb', line 17

def key_paths
  @key_paths
end

Instance Method Details

#key_path_for(initials) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
# File 'lib/vinz/clortho/ssh_key_path_manager.rb', line 32

def key_path_for(initials)
  raise ArgumentError.new('Committer initials are required') unless initials
  key_path = @key_paths.detect { |kp| kp.initials == initials }
  if key_path.nil?
    raise UserNotFoundError.new(user_not_found_msg)
  else
    key_path.path
  end
end