Class: Sumodev::Commands::Push::AuthorizedKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/sumodev/commands/push.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_contents) ⇒ AuthorizedKeys

Returns a new instance of AuthorizedKeys.



105
106
107
# File 'lib/sumodev/commands/push.rb', line 105

def initialize(file_contents)
  @contents = parse!(file_contents)
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



103
104
105
# File 'lib/sumodev/commands/push.rb', line 103

def contents
  @contents
end

Instance Method Details

#add(key) ⇒ Object



109
110
111
# File 'lib/sumodev/commands/push.rb', line 109

def add key
  @contents[key[:key]] = key
end

#remove(key) ⇒ Object



113
114
115
# File 'lib/sumodev/commands/push.rb', line 113

def remove key
  @contents.delete(key[:key])
end

#to_ioObject



123
124
125
# File 'lib/sumodev/commands/push.rb', line 123

def to_io
  StringIO.new(to_s)
end

#to_sObject



117
118
119
120
121
# File 'lib/sumodev/commands/push.rb', line 117

def to_s
  @contents.collect do |identity, k|
    "#{k[:optional]}ssh-#{k[:protocol]} #{k[:key]} #{k[:identity]}\n"
  end.join
end