class Relaton::Cli::RelatonDb

Constants

DBCONF

Public Instance Methods

db(dir) click to toggle source

@param dir [String, nil] @return [Relaton::Db]

# File lib/relaton/cli.rb, line 19
def db(dir)
  if dir
    File.write DBCONF, dir, encoding: "UTF-8"
    @db = Relaton::Db.new dir, nil
  else
    @db ||= Relaton::Db.new dbpath, nil
  end
end

Private Instance Methods

dbpath() click to toggle source

@return [String] path to DB

# File lib/relaton/cli.rb, line 31
def dbpath
  if File.exist?(DBCONF)
    File.read(DBCONF, encoding: "UTF-8")
  else "#{Dir.home}/.relaton/cache"
  end
end