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, #footprint

Methods inherited from Secret

#==, #erase, #footprint

Constructor Details

#initialize(pathname, name, recipients) ⇒ GpgLocalFileSystemSecret

Returns a new instance of GpgLocalFileSystemSecret.



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

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

Instance Method Details

#readObject



74
75
76
# File 'lib/leeloo/secret.rb', line 74

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

#write(phrase) ⇒ Object



78
79
80
81
82
83
# File 'lib/leeloo/secret.rb', line 78

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