Class: Leeloo::LocalFileSystemSecret

Inherits:
Secret
  • Object
show all
Defined in:
lib/leeloo/secret.rb

Direct Known Subclasses

GpgLocalFileSystemSecret

Instance Attribute Summary collapse

Attributes inherited from Secret

#name

Instance Method Summary collapse

Methods inherited from Secret

#==

Constructor Details

#initialize(pathname, name) ⇒ LocalFileSystemSecret

Returns a new instance of LocalFileSystemSecret.



39
40
41
42
# File 'lib/leeloo/secret.rb', line 39

def initialize pathname, name
  super name
  @pathname = pathname
end

Instance Attribute Details

#pathnameObject (readonly)

Returns the value of attribute pathname.



37
38
39
# File 'lib/leeloo/secret.rb', line 37

def pathname
  @pathname
end

Instance Method Details

#eraseObject



53
54
55
# File 'lib/leeloo/secret.rb', line 53

def erase
  File.delete @pathname
end

#footprintObject



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

def footprint
  secret = File.read @pathname
  md5 = Digest::MD5.new
  md5 << secret
  md5.hexdigest
end

#readObject



44
45
46
# File 'lib/leeloo/secret.rb', line 44

def read
  File.read @pathname
end

#write(phrase) ⇒ Object



48
49
50
51
# File 'lib/leeloo/secret.rb', line 48

def write phrase
  FileUtils.mkdir_p File.dirname @pathname
  File.write @pathname, phrase
end