Sha256: 8e5df4fe260078a279cdb641f6efca76ef26ab5e1523347c194d7d80fcf71a1f
Contents?: true
Size: 751 Bytes
Versions: 2
Compression:
Stored size: 751 Bytes
Contents
require "fileutils" module RPass def self.storage @storage ||= Storage.new("#{ENV["HOME"]}/.rpass") end class Storage attr_reader :path def initialize(path) @path = path end def write(name, value) File.write(file(name), value) end def delete(name) File.delete(file(name)) end def exists?(name) File.exists?(file(name)) end def read(name) exists?(name) ? File.read(file(name)) : nil end def [](name) read(name) end def []=(name, value) write(name, value) end private def file(name) "#{dir}/#{name}" end def dir @dir ||= path.tap do |path| FileUtils.mkdir_p path end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rpass-0.1.1 | lib/rpass/storage.rb |
rpass-0.1.0 | lib/rpass/storage.rb |