module Keybase::Local::Config

Methods and constants related to a local Keybase installation.

Constants

CONFIG_DIR

The Keybase configuration directory.

CONFIG_FILE

The Keybase configuration file. @note This is not guaranteed to exist on disk.

KBFS_MOUNT

The mountpoint for KBFS.

STATUS_HASH

The Keybase status hash, obtained from `keybase status -j`.

Public Instance Methods

current_user() click to toggle source

@return [String] the currently logged-in user

# File lib/keybase/local/config.rb, line 29
def current_user
  STATUS_HASH["Username"]
end
logged_in?() click to toggle source
# File lib/keybase/local/config.rb, line 57
def logged_in?
  STATUS_HASH["LoggedIn"]
end
private_dir() click to toggle source

@return [String] the user's private KBFS directory

# File lib/keybase/local/config.rb, line 34
def private_dir
  File.join(KBFS_MOUNT, "private", current_user)
end
public_dir() click to toggle source

@return [String] the user's public KBFS directory

# File lib/keybase/local/config.rb, line 39
def public_dir
  File.join(KBFS_MOUNT, "public", current_user)
end
running?() click to toggle source

@return [Boolean] whether or not Keybase is currently running

# File lib/keybase/local/config.rb, line 44
def running?
  if Gem.win_platform?
    !`tasklist | find "keybase.exe"`.empty?
  elsif RUBY_PLATFORM =~ /darwin/
    !`pgrep keybase`.empty?
  else
    # is there a more efficient way to do this that doesn't involve an exec?
    Dir["/proc/[0-9]*/comm"].any? do |comm|
      File.read(comm).chomp == "keybase" rescue false # hooray for TOCTOU
    end
  end
end
running_version() click to toggle source

@return [String] the running Keybase's version string @raise [Exceptions::KeybaseNotRunningError] if Keybase is not running

# File lib/keybase/local/config.rb, line 63
def running_version
  raise Exceptions::KeybaseNotRunningError unless running?
  `keybase --version`.split[2]
end