Module: Tempest::AccountPaths
- Defined in:
- lib/tempest/account_paths.rb
Overview
Centralizes filesystem layout for tempest’s per-account storage.
Legacy paths (‘legacy_*`) honor `TEMPEST_SESSION_PATH` / `TEMPEST_CURSOR_PATH` / `TEMPEST_TIMELINE_PATH` for migration purposes only; the new per-DID paths cannot be overridden via env.
Class Method Summary collapse
- .account_dir(env = ENV, did:) ⇒ Object
- .accounts_dir(env = ENV) ⇒ Object
- .accounts_json_path(env = ENV) ⇒ Object
- .config_base(env = ENV) ⇒ Object
- .cursor_path(env = ENV, did:) ⇒ Object
- .legacy_cursor_path(env = ENV) ⇒ Object
- .legacy_session_path(env = ENV) ⇒ Object
- .legacy_timeline_path(env = ENV) ⇒ Object
- .session_path(env = ENV, did:) ⇒ Object
- .timeline_path(env = ENV, did:) ⇒ Object
Class Method Details
.account_dir(env = ENV, did:) ⇒ Object
40 41 42 |
# File 'lib/tempest/account_paths.rb', line 40 def account_dir(env = ENV, did:) File.join(accounts_dir(env), did) end |
.accounts_dir(env = ENV) ⇒ Object
36 37 38 |
# File 'lib/tempest/account_paths.rb', line 36 def accounts_dir(env = ENV) File.join(config_base(env), "accounts") end |
.accounts_json_path(env = ENV) ⇒ Object
56 57 58 |
# File 'lib/tempest/account_paths.rb', line 56 def accounts_json_path(env = ENV) File.join(config_base(env), "accounts.json") end |
.config_base(env = ENV) ⇒ Object
12 13 14 15 16 |
# File 'lib/tempest/account_paths.rb', line 12 def config_base(env = ENV) base = env["XDG_CONFIG_HOME"] base = File.join(env["HOME"].to_s, ".config") if base.nil? || base.empty? File.join(base, "tempest") end |
.cursor_path(env = ENV, did:) ⇒ Object
48 49 50 |
# File 'lib/tempest/account_paths.rb', line 48 def cursor_path(env = ENV, did:) File.join(account_dir(env, did: did), "cursor.json") end |
.legacy_cursor_path(env = ENV) ⇒ Object
24 25 26 27 28 |
# File 'lib/tempest/account_paths.rb', line 24 def legacy_cursor_path(env = ENV) explicit = env["TEMPEST_CURSOR_PATH"] return explicit if explicit && !explicit.empty? File.join(config_base(env), "cursor.json") end |
.legacy_session_path(env = ENV) ⇒ Object
18 19 20 21 22 |
# File 'lib/tempest/account_paths.rb', line 18 def legacy_session_path(env = ENV) explicit = env["TEMPEST_SESSION_PATH"] return explicit if explicit && !explicit.empty? File.join(config_base(env), "session.json") end |
.legacy_timeline_path(env = ENV) ⇒ Object
30 31 32 33 34 |
# File 'lib/tempest/account_paths.rb', line 30 def legacy_timeline_path(env = ENV) explicit = env["TEMPEST_TIMELINE_PATH"] return explicit if explicit && !explicit.empty? File.join(config_base(env), "timeline.json") end |
.session_path(env = ENV, did:) ⇒ Object
44 45 46 |
# File 'lib/tempest/account_paths.rb', line 44 def session_path(env = ENV, did:) File.join(account_dir(env, did: did), "session.json") end |
.timeline_path(env = ENV, did:) ⇒ Object
52 53 54 |
# File 'lib/tempest/account_paths.rb', line 52 def timeline_path(env = ENV, did:) File.join(account_dir(env, did: did), "timeline.json") end |