module Localhost::State
def self.path(env = ENV)
compliant directory.
directory (~/.localhost/) exists, it is moved into the new XDG Basedir
Ensures that the directory to store the certificate exists. If the legacy
of $XDG_STATE_HOME, or ~/.local/state/ when that's not defined.
Where to store the key pair on the filesystem. This is a subdirectory
def self.path(env = ENV) path = File.expand_path("localhost.rb", env.fetch("XDG_STATE_HOME", "~/.local/state")) unless File.directory?(path) FileUtils.mkdir_p(path, mode: 0700) end return path end
def self.purge(env = ENV)
Delete the directory where the key pair is stored.
def self.purge(env = ENV) path = self.path(env) FileUtils.rm_rf(path) end