Module: Keybase::Local::Config
- Included in:
- Keybase::Local
- Defined in:
- lib/keybase/local/config.rb
Overview
Methods and constants related to a local Keybase installation.
Constant Summary collapse
- CONFIG_DIR =
The Keybase configuration directory.
if Gem.win_platform? File.("#{ENV["LOCALAPPDATA"]}/Keybase").freeze elsif RUBY_PLATFORM =~ /darwin/ File.("~/Library/Application Support/Keybase").freeze else File.("~/.config/keybase").freeze end
- CONFIG_FILE =
The Keybase configuration file.
File.join(CONFIG_DIR, "config.json").freeze
- CONFIG_HASH =
The hash from Keybase's configuration file.
JSON.parse(File.read(CONFIG_FILE)).freeze
- KBFS_MOUNT =
The mountpoint for KBFS.
"/keybase"
Instance Method Summary collapse
-
#current_user ⇒ String
The currently logged-in user.
-
#local_users ⇒ Array<Keybase::Local::User>
A list of all local users known to Keybase.
-
#private_dir ⇒ String
The user's private KBFS directory.
-
#public_dir ⇒ String
The user's public KBFS directory.
-
#running? ⇒ Boolean
Whether or not Keybase is currently running.
-
#running_version ⇒ String
The running Keybase's version string.
Instance Method Details
#current_user ⇒ String
Returns the currently logged-in user.
31 32 33 |
# File 'lib/keybase/local/config.rb', line 31 def current_user CONFIG_HASH["current_user"] end |
#local_users ⇒ Array<Keybase::Local::User>
Returns a list of all local users known to Keybase.
37 38 39 |
# File 'lib/keybase/local/config.rb', line 37 def local_users CONFIG_HASH["users"].map { |_, v| User.new(v) } end |
#private_dir ⇒ String
Returns the user's private KBFS directory.
42 43 44 |
# File 'lib/keybase/local/config.rb', line 42 def private_dir File.join(KBFS_MOUNT, "private", current_user) end |
#public_dir ⇒ String
Returns the user's public KBFS directory.
47 48 49 |
# File 'lib/keybase/local/config.rb', line 47 def public_dir File.join(KBFS_MOUNT, "public", current_user) end |
#running? ⇒ Boolean
Returns whether or not Keybase is currently running.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/keybase/local/config.rb', line 52 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 ⇒ String
Returns the running Keybase's version string.
67 68 69 70 |
# File 'lib/keybase/local/config.rb', line 67 def running_version raise Exceptions::KeybaseNotRunningError unless running? `keybase --version`.split[2] end |