Module: Dotsync::SyncMappings
- Included in:
- PullActionConfig, PushActionConfig
- Defined in:
- lib/dotsync/config/concerns/sync_mappings.rb
Overview
SyncMappings provides bidirectional mapping support. It reads [sync] section mappings and converts them to push or pull format.
The [sync] section supports multiple sub-types:
-
Explicit mappings with [[sync.mappings]]: [[sync.mappings]] local = "$XDG_CONFIG_HOME/nvim" remote = "$XDG_CONFIG_HOME_MIRROR/nvim" force = true ignore = ["lazy-lock.json"]
-
XDG shorthand mappings that auto-expand environment variables: [[sync.xdg_config]] path = "nvim" force = true
Expands to: local=$XDG_CONFIG_HOME/nvim, remote=$XDG_CONFIG_HOME_MIRROR/nvim
Supported shorthands:
- sync.home: $HOME <-> $HOME_MIRROR
- sync.xdg_config: $XDG_CONFIG_HOME <-> $XDG_CONFIG_HOME_MIRROR
- sync.xdg_data: $XDG_DATA_HOME <-> $XDG_DATA_HOME_MIRROR
- sync.xdg_cache: $XDG_CACHE_HOME <-> $XDG_CACHE_HOME_MIRROR
- sync.xdg_bin: $XDG_BIN_HOME <-> $XDG_BIN_HOME_MIRROR
- sync.mappings: explicit local/remote mappings
For push: local → remote (src=local, dest=remote) For pull: remote → local (src=remote, dest=local)
Constant Summary collapse
- SYNC_SECTION =
"sync"- MAPPINGS_KEY =
"mappings"- SHORTHANDS =
Shorthand type definitions mapping to local/remote base paths
{ "home" => { local: "$HOME", remote: "$HOME_MIRROR" }, "xdg_config" => { local: "$XDG_CONFIG_HOME", remote: "$XDG_CONFIG_HOME_MIRROR" }, "xdg_data" => { local: "$XDG_DATA_HOME", remote: "$XDG_DATA_HOME_MIRROR" }, "xdg_cache" => { local: "$XDG_CACHE_HOME", remote: "$XDG_CACHE_HOME_MIRROR" }, "xdg_bin" => { local: "$XDG_BIN_HOME", remote: "$XDG_BIN_HOME_MIRROR" } }.freeze
Instance Method Summary collapse
Instance Method Details
#has_sync_mappings? ⇒ Boolean
53 54 55 56 57 |
# File 'lib/dotsync/config/concerns/sync_mappings.rb', line 53 def has_sync_mappings? return false unless sync_section.is_a?(Hash) explicit_mappings_raw.any? || shorthand_mappings_raw.any? end |
#sync_mappings_for_pull ⇒ Object
49 50 51 |
# File 'lib/dotsync/config/concerns/sync_mappings.rb', line 49 def sync_mappings_for_pull all_sync_mappings(:pull) end |
#sync_mappings_for_push ⇒ Object
45 46 47 |
# File 'lib/dotsync/config/concerns/sync_mappings.rb', line 45 def sync_mappings_for_push all_sync_mappings(:push) end |