Class: Leeloo::LocalFileSystemSecret
- Defined in:
- lib/leeloo/secret.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
Attributes inherited from Secret
Instance Method Summary collapse
- #erase ⇒ Object
- #footprint ⇒ Object
-
#initialize(pathname, name) ⇒ LocalFileSystemSecret
constructor
A new instance of LocalFileSystemSecret.
- #read ⇒ Object
- #write(phrase) ⇒ Object
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
#pathname ⇒ Object (readonly)
Returns the value of attribute pathname.
37 38 39 |
# File 'lib/leeloo/secret.rb', line 37 def pathname @pathname end |
Instance Method Details
#erase ⇒ Object
53 54 55 |
# File 'lib/leeloo/secret.rb', line 53 def erase File.delete @pathname end |
#footprint ⇒ Object
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 |
#read ⇒ Object
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 |