Class: KBSecret::Config
- Inherits:
-
Object
- Object
- KBSecret::Config
- Defined in:
- lib/kbsecret/config.rb
Overview
Global and per-session configuration for kbsecret.
Constant Summary collapse
- CONFIG_DIR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
the configuration directory
File.("~/.config/kbsecret").freeze
- CONFIG_FILE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
the configuration file
File.join(CONFIG_DIR, "config.yml").freeze
- DEFAULT_CONFIG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
configuration defaults
{ mount: "/keybase", sessions: { default: { users: [Keybase.current_user], root: "kbsecret", } } }.freeze
- @@config =
DEFAULT_CONFIG.merge(user_config)
Class Method Summary collapse
-
.[](key) ⇒ Object
Retrieve a configured value.
-
.configure_session(label, hsh) ⇒ Object
Configure a session.
-
.session(sess) ⇒ Hash
Retrieve a session's configuration.
-
.session?(sess) ⇒ Boolean
Whether or not the given session is configured.
-
.session_labels ⇒ Array<Symbol>
All configured session labels.
Class Method Details
.[](key) ⇒ Object
Retrieve a configured value.
31 32 33 |
# File 'lib/kbsecret/config.rb', line 31 def self.[](key) @@config[key] end |
.configure_session(label, hsh) ⇒ Object
Configure a session.
56 57 58 59 |
# File 'lib/kbsecret/config.rb', line 56 def self.configure_session(label, hsh) @@config[:sessions][label.to_sym] = hsh File.open(CONFIG_FILE, "w") { |io| io.write @@config.to_yaml } end |
.session(sess) ⇒ Hash
Retrieve a session's configuration.
38 39 40 |
# File 'lib/kbsecret/config.rb', line 38 def self.session(sess) @@config[:sessions][sess] end |
.session?(sess) ⇒ Boolean
Returns whether or not the given session is configured.
49 50 51 |
# File 'lib/kbsecret/config.rb', line 49 def self.session?(sess) session_labels.include?(sess.to_sym) end |
.session_labels ⇒ Array<Symbol>
Returns all configured session labels.
43 44 45 |
# File 'lib/kbsecret/config.rb', line 43 def self.session_labels @@config[:sessions].keys end |