Class: Leeloo::GpgLocalFileSystemSecret

Inherits:
LocalFileSystemSecret show all
Defined in:
lib/leeloo/secret.rb

Instance Attribute Summary

Attributes inherited from LocalFileSystemSecret

#pathname

Attributes inherited from Secret

#name

Instance Method Summary collapse

Methods inherited from LocalFileSystemSecret

#erase

Methods inherited from Secret

#==, #erase

Constructor Details

#initialize(pathname, name, recipients) ⇒ GpgLocalFileSystemSecret

Returns a new instance of GpgLocalFileSystemSecret.



57
58
59
60
61
# File 'lib/leeloo/secret.rb', line 57

def initialize pathname, name, recipients
  super pathname, name
  @recipients = recipients
  @crypto = GPGME::Crypto.new :always_trust => true
end

Instance Method Details

#readObject



63
64
65
# File 'lib/leeloo/secret.rb', line 63

def read
  @crypto.decrypt File.open(@pathname)
end

#write(phrase) ⇒ Object



67
68
69
70
71
72
# File 'lib/leeloo/secret.rb', line 67

def write phrase
  FileUtils.mkdir_p File.dirname @pathname
  @crypto.encrypt phrase,
    :output => File.open(@pathname,"w+"),
    :recipients => @recipients
end