dotsync 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b51df7b5c764f6c18fa189f842101b4169b212d357cc2ee91f650d71a5dea9e
4
- data.tar.gz: ebce99be5e27ba45c07d879699f08310212b2f39ebae931775bd273d8c9908f3
3
+ metadata.gz: 3499c4ca658689253d20ed6408821dfdc997cb5e9c31aaacb23c4027945c7d57
4
+ data.tar.gz: 1f2d711a45e9e508a57533a0bd0e4a7479f83b52a81afe807895b41bd2408970
5
5
  SHA512:
6
- metadata.gz: f5957200742a5f72530bfc940a5e38315c93d1cd1ed32c1b858843c29abecea5c6a4e7b4c3faaa48ade180fd25b9777df4a4b1ff2940054f6620989185d9911c
7
- data.tar.gz: 333dd782f60dc3eb81b7b6de1334e94424ec001cd20dc42d56742b4c0f71ef04cbe3171472b3f6cd7ab995754764bdcd02fb57680262714dccab71149e5e9a28
6
+ metadata.gz: ac05c1125d6a5843e70d7510c7f0717625a3a616932bee521be80d793ce918b8871e92a85975e61a1c7d63e9a929cf25c26c91f1fedd212d0d24c637549a1fce
7
+ data.tar.gz: 316fb8fe0723d26d6646ea8370124744fc1f2596185c1239bef12a737f0c1b89a7d6531b0bac02b12e5e47407206c0809d2ddacd598e8d6bbe0e6ae93a89c459
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # 0.1.9
2
+
3
+ - Exe: improved banner with options
4
+ - Options: added "--apply"
5
+ - Options: added "--environment-variables"
6
+ - Differ: show full path using original mapping paths
7
+ - Readme: add gem version badge
8
+ - Readme: add requirements section
9
+
10
+ # 0.1.8
11
+
12
+ - Show full relative path on diff
13
+ - Show Diff section header
14
+
1
15
  # 0.1.7
2
16
 
3
17
  - Fixes broken runner
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dotsync (0.1.7)
4
+ dotsync (0.1.9)
5
5
  fileutils (~> 1.7.3)
6
6
  find (~> 0.2.0)
7
7
  listen (~> 3.9.0)
data/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # Dotsync
2
2
 
3
- **⚠️ Warning: This gem is under active development. You can expect new changes that may not be backward-compatible.**
4
-
3
+ [![Gem Version](https://badge.fury.io/rb/sidekiq.svg)](https://rubygems.org/gems/sidekiq)
5
4
  [![Ruby Gem Test Status](https://github.com/dsaenztagarro/dotsync/actions/workflows/gem-push.yml/badge.svg)](https://github.com/dsaenztagarro/dotsync/actions)
6
5
 
6
+ > [!WARNING]
7
+ > This gem is under active development. You can expect new changes that may not be backward-compatible.
8
+
7
9
  Welcome to Dotsync! This gem helps you manage and synchronize your dotfiles effortlessly. Below you'll find information on installation, usage, and some tips for getting started.
8
10
 
11
+ ## Requirements
12
+ - Ruby: MRI 3.2+
13
+
9
14
  ## Installation
10
15
 
11
16
  Add this line to your application's Gemfile:
@@ -55,25 +60,42 @@ Dotsync provides the following commands to manage your dotfiles:
55
60
  The configuration file uses a `mappings` structure to define the source and destination of your dotfiles. Here is an example:
56
61
 
57
62
  ```toml
58
- [pull]
59
- mappings = [
60
- { src = "$DOTFILES_DIR/config/", dest = "$XDG_CONFIG_HOME", force = false },
61
- { src = "$DOTFILES_DIR/home/.zshenv", dest = "$HOME" }
62
- ]
63
-
64
- [push]
65
- mappings = [
66
- { src = "$HOME/.zshenv", dest = "$DOTFILES_DIR/home/.zshenv" },
67
- { src = "$XDG_CONFIG_HOME/alacritty", dest = "$DOTFILES_DIR/config/alacritty" }
68
- ]
69
-
70
- [watch]
71
- mappings = [
72
- { src = "$HOME/.zshenv", dest = "$DOTFILES_DIR/home/.zshenv" },
73
- { src = "$XDG_CONFIG_HOME/alacritty", dest = "$DOTFILES_DIR/config/alacritty" }
74
- ]
63
+ [[pull.mappings]]
64
+ src = "$XDG_CONFIG_HOME_MIRROR"
65
+ dest = "$XDG_CONFIG_HOME"
66
+
67
+ [[pull.mappings]]
68
+ src = "$HOME_MIRROR/.zshenv"
69
+ dest = "$HOME" }
70
+
71
+
72
+ [[push.mappings]]
73
+ src = "$HOME/.zshenv"
74
+ src = "$HOME_MIRROR/.zshenv"
75
+
76
+ [[push.mappings]]
77
+ src = "$XDG_CONFIG_HOME/alacritty"
78
+ dest = "$DOTFILES_DIR/config/alacritty"
79
+ force = true # it forces the deletion of destination folder
80
+ ignore = ["themes/rose-pine.toml"] # use relative paths to "dest" to ignore files and folders
81
+
82
+
83
+ [[watch.mappings]]
84
+ src = "$HOME/.zshenv"
85
+ src = "$HOME_MIRROR/.zshenv"
86
+
87
+ [[watch.mappings]]
88
+ src = "$XDG_CONFIG_HOME/alacritty"
89
+ dest = "$DOTFILES_DIR/config/alacritty"
75
90
  ```
76
91
 
92
+ > [!TIP]
93
+ > I use mirror environment variables to cleaner configuration
94
+ >
95
+ > ```bash
96
+ > export XDG_CONFIG_HOME_MIRROR="$HOME/Code/dotfiles/xdg_config_home"
97
+ > ```
98
+
77
99
  #### `force` and `ignore` Options in Mappings
78
100
 
79
101
  Each mapping entry supports the following options:
data/exe/dotsync CHANGED
@@ -4,7 +4,7 @@
4
4
  require_relative "../lib/dotsync"
5
5
  require "optparse"
6
6
 
7
- {}
7
+ options = { apply: false }
8
8
 
9
9
  opt_parser = OptionParser.new do |opts|
10
10
  opts.banner = <<~BANNER
@@ -16,10 +16,18 @@ opt_parser = OptionParser.new do |opts|
16
16
  pull Download remote changes to the local
17
17
  watch Continuously monitor and sync changes
18
18
  setup Initialize a default configuration file
19
+
20
+ Options:
21
+ -a, --apply Apply changes (push or pull)
22
+ -h, --help Show this help message
19
23
  BANNER
20
24
 
25
+ opts.on("-a", "--apply", "Apply changes (push or pull)") do
26
+ options[:apply] = true
27
+ end
28
+
21
29
  opts.on("-h", "--help", "Show this help message") do
22
- puts opts
30
+ puts opt_parser.banner
23
31
  exit
24
32
  end
25
33
  end
@@ -30,9 +38,9 @@ command = ARGV.shift
30
38
 
31
39
  case command
32
40
  when "push"
33
- Dotsync::Runner.new.run(:push)
41
+ Dotsync::Runner.new.run(:push, options)
34
42
  when "pull"
35
- Dotsync::Runner.new.run(:pull)
43
+ Dotsync::Runner.new.run(:pull, options)
36
44
  when "watch"
37
45
  Dotsync::Runner.new.run(:watch)
38
46
  when "setup"
@@ -18,5 +18,14 @@ module Dotsync
18
18
  def execute
19
19
  raise NotImplementedError
20
20
  end
21
+
22
+ private
23
+ def show_options(options)
24
+ info("Options:", icon: :options)
25
+ logger.log(" Apply: #{options[:apply] ? "TRUE" : "FALSE"}")
26
+ end
27
+
28
+ def show_env_vars
29
+ end
21
30
  end
22
31
  end
@@ -6,8 +6,18 @@ module Dotsync
6
6
 
7
7
  def_delegator :@config, :mappings
8
8
 
9
+ def show_env_vars
10
+ env_vars = mappings_env_vars
11
+ return unless env_vars.any?
12
+
13
+ info("Environment variables:", icon: :env_vars)
14
+ env_vars.each do |env_var|
15
+ logger.log(" #{env_var}: #{ENV[env_var]}")
16
+ end
17
+ end
18
+
9
19
  def show_mappings
10
- info("Mappings:", icon: :config,)
20
+ info("Mappings:", icon: :config)
11
21
 
12
22
  mappings.each do |mapping|
13
23
  logger.log(" #{mapping}")
@@ -18,14 +28,17 @@ module Dotsync
18
28
  diffs = valid_mappings.map do |mapping|
19
29
  Dotsync::DirectoryDiffer.new(mapping).diff
20
30
  end
21
- diffs.flat_map(&:additions).sort.each do |path|
22
- logger.log(" #{path}", color: Dotsync::Colors.diff_additions)
23
- end
24
- diffs.flat_map(&:modifications).sort.each do |path|
25
- logger.log(" #{path}", color: Dotsync::Colors.diff_modifications)
26
- end
27
- diffs.flat_map(&:removals).sort.each do |path|
28
- logger.log(" #{path}", color: Dotsync::Colors.diff_removals)
31
+ if diffs.any?
32
+ info("Diff:", icon: :diff)
33
+ diffs.flat_map(&:additions).sort.each do |path|
34
+ logger.log(" #{path}", color: Dotsync::Colors.diff_additions)
35
+ end
36
+ diffs.flat_map(&:modifications).sort.each do |path|
37
+ logger.log(" #{path}", color: Dotsync::Colors.diff_modifications)
38
+ end
39
+ diffs.flat_map(&:removals).sort.each do |path|
40
+ logger.log(" #{path}", color: Dotsync::Colors.diff_removals)
41
+ end
29
42
  end
30
43
  end
31
44
 
@@ -35,8 +48,17 @@ module Dotsync
35
48
  end
36
49
  end
37
50
 
38
- def valid_mappings
39
- mappings.select(&:valid?)
40
- end
51
+ private
52
+ def mappings_env_vars
53
+ paths = mappings.flat_map do |mapping|
54
+ [mapping.original_src, mapping.original_dest]
55
+ end
56
+
57
+ paths.flat_map { |path| extract_env_vars(path) }.uniq
58
+ end
59
+
60
+ def valid_mappings
61
+ mappings.select(&:valid?)
62
+ end
41
63
  end
42
64
  end
@@ -6,27 +6,23 @@ module Dotsync
6
6
 
7
7
  def_delegator :@config, :backups_root
8
8
 
9
- def execute
10
- show_config
9
+ def execute(options = {})
10
+ show_options(options)
11
+ show_env_vars
12
+ show_mappings
11
13
  show_changes
14
+ return unless options[:apply]
15
+
12
16
  if create_backup
13
17
  show_backup
14
18
  purge_old_backups
15
19
  end
16
- pull_dotfiles
20
+
21
+ transfer_mappings
22
+ action("Dotfiles pulled")
17
23
  end
18
24
 
19
25
  private
20
- def show_config
21
- show_mappings
22
- end
23
-
24
- def pull_dotfiles
25
- transfer_mappings
26
-
27
- action("Dotfiles pulled")
28
- end
29
-
30
26
  def show_backup
31
27
  action("Backup created:")
32
28
  logger.log(" #{backup_root_path}")
@@ -4,21 +4,15 @@ module Dotsync
4
4
  class PushAction < BaseAction
5
5
  include MappingsTransfer
6
6
 
7
- def execute
8
- show_config
7
+ def execute(options = {})
8
+ show_options(options)
9
+ show_env_vars
10
+ show_mappings
9
11
  show_changes
10
- push_dotfiles
11
- end
12
-
13
- private
14
- def show_config
15
- show_mappings
16
- end
12
+ return unless options[:apply]
17
13
 
18
- def push_dotfiles
19
- transfer_mappings
20
-
21
- action("Dotfiles pushed", icon: :copy)
22
- end
14
+ transfer_mappings
15
+ action("Dotfiles pushed", icon: :copy)
16
+ end
23
17
  end
24
18
  end
@@ -2,20 +2,20 @@
2
2
 
3
3
  module Dotsync
4
4
  # https://specifications.freedesktop.org/basedir-spec/latest/
5
- module XDGBaseDirectorySpec
5
+ module XDGBaseDirectory
6
6
  def xdg_data_home
7
7
  File.expand_path(ENV["XDG_DATA_HOME"] || "$HOME/.local/share")
8
8
  end
9
9
 
10
- def xdf_config_home
10
+ def xdg_config_home
11
11
  File.expand_path(ENV["XDG_CONFIG_HOME"] || "$HOME/.config")
12
12
  end
13
13
 
14
- def xdf_cache_home
14
+ def xdg_cache_home
15
15
  File.expand_path(ENV["XDG_CACHE_HOME"] || "$HOME/.cache")
16
16
  end
17
17
 
18
- def xdf_bin_home
18
+ def xdg_bin_home
19
19
  File.expand_path(ENV["XDG_BIN_HOME"] || "$HOME/.local/bin")
20
20
  end
21
21
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Dotsync
4
4
  class PullActionConfig < BaseConfig
5
- include XDGBaseDirectorySpec
5
+ include XDGBaseDirectory
6
6
 
7
7
  def mappings
8
8
  mappings_list = section["mappings"]
data/lib/dotsync/icons.rb CHANGED
@@ -7,7 +7,10 @@ module Dotsync
7
7
  ERROR = " "
8
8
 
9
9
  # Configuration icon
10
+ OPTIONS = " "
11
+ ENV_VARS = " "
10
12
  CONFIG = " "
13
+ DIFF = " "
11
14
 
12
15
  # Default Mapping icons
13
16
  DEFAULT_FORCE = "󰁪 "
@@ -19,8 +22,8 @@ module Dotsync
19
22
  PUSH = " "
20
23
  WATCH = "󰛐 "
21
24
 
22
- # TODO: review icons needed
23
25
  CONSOLE = "󰆍 "
26
+ # TODO: review icons needed
24
27
  LISTEN = " "
25
28
  SOURCE = " " #  "
26
29
  DEST = " " # " "
@@ -56,7 +59,10 @@ module Dotsync
56
59
  MAPPINGS = {
57
60
  info: INFO,
58
61
  error: ERROR,
62
+ env_vars: ENV_VARS,
63
+ options: OPTIONS,
59
64
  config: CONFIG,
65
+ diff: DIFF,
60
66
  force: -> { force },
61
67
  ignore: -> { ignore },
62
68
  pull: PULL,
@@ -12,9 +12,11 @@ module Dotsync
12
12
  @original_ignores = Array(attributes["ignore"])
13
13
  @force = attributes["force"] || false
14
14
 
15
- @sanitized_src = sanitize_path(@original_src)
16
- @sanitized_dest = sanitize_path(@original_dest)
17
- @sanitized_ignore = @original_ignores.map { |path| File.join(@sanitized_src, path) }
15
+ @sanitized_src, @sanitized_dest, @sanitized_ignore = process_paths(
16
+ @original_src,
17
+ @original_dest,
18
+ @original_ignores
19
+ )
18
20
  end
19
21
 
20
22
  def src
@@ -33,10 +35,17 @@ module Dotsync
33
35
  @force
34
36
  end
35
37
 
38
+ def directories?
39
+ File.directory?(src) && File.directory?(dest)
40
+ end
41
+
42
+ def files?
43
+ return true if File.file?(src) && File.file?(dest)
44
+ File.file?(src) && !File.exist?(dest) && File.directory?(File.dirname(dest))
45
+ end
46
+
36
47
  def valid?
37
- (File.file?(src) && File.file?(dest)) ||
38
- (File.directory?(src) && File.directory?(dest)) ||
39
- (File.file?(src) && !File.exist?(dest) && File.directory?(File.dirname(dest)))
48
+ directories? || files?
40
49
  end
41
50
 
42
51
  def backup_possible?
@@ -78,5 +87,12 @@ module Dotsync
78
87
  def ignores?
79
88
  @original_ignores.any?
80
89
  end
90
+
91
+ def process_paths(src, dest, ignores)
92
+ sanitized_src = sanitize_path(src)
93
+ sanitized_dest = sanitize_path(dest)
94
+ sanitized_ignore = ignores.map { |path| File.join(sanitized_src, path) }
95
+ [sanitized_src, sanitized_dest, sanitized_ignore]
96
+ end
81
97
  end
82
98
  end
@@ -7,7 +7,7 @@ module Dotsync
7
7
  end
8
8
 
9
9
  # action_name should be a symbol, e.g., :pull, :watch, :sync
10
- def run(action_name)
10
+ def run(action_name, options = {})
11
11
  case action_name
12
12
  when :setup
13
13
  setup_config
@@ -22,7 +22,7 @@ module Dotsync
22
22
 
23
23
  action = action_class.new(config, @logger)
24
24
 
25
- action.execute
25
+ action.execute(options)
26
26
  rescue ConfigError => e
27
27
  @logger.error("[#{action_name}] config error:")
28
28
  @logger.info(e.message)
@@ -46,21 +46,28 @@ module Dotsync
46
46
  FileUtils.mkdir_p(File.dirname(config_path))
47
47
 
48
48
  example_mappings = {
49
+ "icons" => {
50
+ "options" => "⚙️",
51
+ "config" => "📄",
52
+ "force" => "🔥",
53
+ "ignore" => "🚫",
54
+ "invalid" => "❌"
55
+ },
49
56
  "pull" => {
50
57
  "mappings" => [
51
- { "src" => "$DOTFILES_DIR/config/", "dest" => "$XDG_CONFIG_HOME", "force" => false },
52
- { "src" => "$DOTFILES_DIR/home/.zshenv", "dest" => "$HOME" }
58
+ { "src" => "$XDG_CONFIG_HOME_MIRROR", "dest" => "$XDG_CONFIG_HOME" },
59
+ { "src" => "$HOME_MIRROR/.zshenv", "dest" => "$HOME" }
53
60
  ],
54
61
  },
55
62
  "push" => {
56
63
  "mappings" => [
57
64
  { "src" => "$HOME/.zshenv", "dest" => "$DOTFILES_DIR/home/.zshenv" },
58
- { "src" => "$XDG_CONFIG_HOME/alacritty", "dest" => "$DOTFILES_DIR/config/alacritty" }
65
+ { "src" => "$XDG_CONFIG_HOME/alacritty", "dest" => "$XDG_CONFIG_HOME_MIRROR/alacritty" }
59
66
  ]
60
67
  },
61
68
  "watch" => {
62
69
  "mappings" => [
63
- { "src" => "$HOME/.zshenv", "dest" => "$DOTFILES_DIR/home/.zshenv" },
70
+ { "src" => "$HOME/.zshenv", "dest" => "$HOME_MIRROR/.zshenv" },
64
71
  { "src" => "$XDG_CONFIG_HOME/alacritty", "dest" => "$DOTFILES_DIR/config/alacritty" }
65
72
  ]
66
73
  }
@@ -1,103 +1,84 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dotsync
4
- # Usage:
5
- # differ = DirectoryDiffer.new("/path/to/src", "/path/to/dest")
6
- # differences = differ.diff
7
4
  class DirectoryDiffer
8
- attr_reader :src, :dest
9
-
10
- # Initializes a new DirectoryDiffer.
11
- #
12
- # @param mapping [Dotsync::Mapping] the mapping object containing source, destination, force, and ignore details
13
- # @option mapping [String] :src the source directory path
14
- # @option mapping [String] :dest the destination directory path
15
- # @option mapping [Boolean] :force? optional flag to force actions
16
- # @option mapping [Array<String>] :ignores optional list of files/directories to ignore
5
+ extend Forwardable
6
+
7
+ # attr_reader :src, :dest
8
+
9
+ def_delegator :@mapping, :src, :mapping_src
10
+ def_delegator :@mapping, :dest, :mapping_dest
11
+ def_delegator :@mapping, :original_src, :mapping_original_src
12
+ def_delegator :@mapping, :original_dest, :mapping_original_dest
13
+ def_delegator :@mapping, :force?, :force?
14
+ def_delegator :@mapping, :original_ignores, :ignores
15
+
17
16
  def initialize(mapping)
18
- @src = mapping.src
19
- @dest = mapping.dest
20
- @force = mapping.force?
21
- @ignores = mapping.original_ignores || []
17
+ @mapping = mapping
22
18
  end
23
19
 
24
20
  def diff
25
- additions = []
26
- modifications = []
27
- removals = []
21
+ if @mapping.directories?
22
+ diff_mapping_directories
23
+ elsif @mapping.files?
24
+ diff_mapping_files
25
+ end
26
+ end
27
+
28
+ private
29
+ def diff_mapping_directories
30
+ additions = []
31
+ modifications = []
32
+ removals = []
28
33
 
29
- Find.find(src) do |src_path|
30
- rel_path = src_path.sub(/^#{Regexp.escape(src)}\/?/, "")
31
- next if rel_path.empty?
34
+ Find.find(mapping_src) do |src_path|
35
+ rel_path = src_path.sub(/^#{Regexp.escape(mapping_src)}\/?/, "")
32
36
 
33
- dest_path = File.join(dest, rel_path)
37
+ dest_path = File.join(mapping_dest, rel_path)
34
38
 
35
- if !File.exist?(dest_path)
36
- additions << rel_path
37
- elsif File.file?(src_path) && File.file?(dest_path)
38
- if File.size(src_path) != File.size(dest_path)
39
- modifications << rel_path
39
+ if !File.exist?(dest_path)
40
+ additions << rel_path
41
+ elsif File.file?(src_path) && File.file?(dest_path)
42
+ if File.size(src_path) != File.size(dest_path)
43
+ modifications << rel_path
44
+ end
40
45
  end
41
46
  end
42
- end
43
47
 
44
- if @force
45
- Find.find(dest) do |dest_path|
46
- rel_path = dest_path.sub(/^#{Regexp.escape(dest)}\/?/, "")
47
- next if rel_path.empty?
48
+ if force?
49
+ Find.find(mapping_dest) do |dest_path|
50
+ rel_path = dest_path.sub(/^#{Regexp.escape(mapping_dest)}\/?/, "")
51
+ next if rel_path.empty?
48
52
 
49
- src_path = File.join(src, rel_path)
53
+ src_path = File.join(mapping_src, rel_path)
50
54
 
51
- if !File.exist?(src_path)
52
- removals << rel_path
55
+ if !File.exist?(src_path)
56
+ removals << rel_path
57
+ end
53
58
  end
54
59
  end
55
- end
56
-
57
- if @ignores.any?
58
- additions = filter_paths(additions, @ignores)
59
- modifications = filter_paths(modifications, @ignores)
60
- removals = filter_paths(removals, @ignores)
61
- end
62
60
 
63
- Dotsync::Diff.new(additions: additions, modifications: modifications, removals: removals)
64
- end
65
-
66
- private
67
- def collect_src_diffs
68
- diffs = []
69
- Find.find(src) do |src_path|
70
- rel_path = src_path.sub(/^#{Regexp.escape(src)}\/?/, "")
71
- next if rel_path.empty?
61
+ if ignores.any?
62
+ additions = filter_paths(additions, ignores)
63
+ modifications = filter_paths(modifications, ignores)
64
+ removals = filter_paths(removals, ignores)
65
+ end
72
66
 
73
- dest_path = File.join(dest, rel_path)
67
+ additions.map! { |rel_path| File.join(mapping_original_dest, rel_path) }
68
+ modifications.map! { |rel_path| File.join(mapping_original_dest, rel_path) }
69
+ removals.map! { |rel_path| File.join(mapping_original_src, rel_path) }
74
70
 
75
- if !File.exist?(dest_path)
76
- diffs << rel_path
77
- elsif File.directory?(src_path) && !File.directory?(dest_path)
78
- diffs << rel_path
79
- elsif File.file?(src_path) && !File.file?(dest_path)
80
- diffs << rel_path
81
- elsif File.file?(src_path) && File.file?(dest_path)
82
- if File.size(src_path) != File.size(dest_path)
83
- diffs << rel_path
84
- end
85
- end
86
- end
87
- diffs
71
+ Dotsync::Diff.new(additions: additions, modifications: modifications, removals: removals)
88
72
  end
89
73
 
90
- def collect_dest_diffs
91
- diffs = []
92
- Find.find(dest) do |dest_path|
93
- rel_path = dest_path.sub(/^#{Regexp.escape(dest)}\/?/, "")
94
- next if rel_path.empty?
95
- src_path = File.join(src, rel_path)
96
- if !File.exist?(src_path)
97
- diffs << rel_path
74
+ def diff_mapping_files
75
+ Dotsync::Diff.new.tap do |diff|
76
+ if !File.exist?(@mapping.dest)
77
+ diff.additions << @mapping.original_dest
78
+ else
79
+ diff.modifications << @mapping.original_dest
98
80
  end
99
81
  end
100
- diffs
101
82
  end
102
83
 
103
84
  def filter_paths(all_paths, ignore_paths)
@@ -8,6 +8,10 @@ module Dotsync
8
8
  path.gsub(/\$(\w+)/) { ENV[$1] }
9
9
  end
10
10
 
11
+ def extract_env_vars(path)
12
+ path.scan(/\$(\w+)/).flatten
13
+ end
14
+
11
15
  def colorize_env_vars(path)
12
16
  path.gsub(/\$(\w+)/) { "\e[38;5;#{ENV_VARS_COLOR}m$#{$1}\e[0m" }
13
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dotsync
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.9"
5
5
  end
data/lib/dotsync.rb CHANGED
@@ -19,8 +19,10 @@ require_relative "dotsync/utils/path_utils"
19
19
  require_relative "dotsync/models/mapping"
20
20
  require_relative "dotsync/models/diff"
21
21
 
22
+ # Config Concerns
23
+ require_relative "dotsync/config/concerns/xdg_base_directory"
24
+
22
25
  # Config
23
- require_relative "dotsync/config/xdg_base_directory_spec"
24
26
  require_relative "dotsync/config/base_config"
25
27
  require_relative "dotsync/config/pull_action_config"
26
28
  require_relative "dotsync/config/push_action_config"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Sáenz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-28 00:00:00.000000000 Z
11
+ date: 2025-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb
@@ -256,10 +256,10 @@ files:
256
256
  - lib/dotsync/actions/watch_action.rb
257
257
  - lib/dotsync/colors.rb
258
258
  - lib/dotsync/config/base_config.rb
259
+ - lib/dotsync/config/concerns/xdg_base_directory.rb
259
260
  - lib/dotsync/config/pull_action_config.rb
260
261
  - lib/dotsync/config/push_action_config.rb
261
262
  - lib/dotsync/config/watch_action_config.rb
262
- - lib/dotsync/config/xdg_base_directory_spec.rb
263
263
  - lib/dotsync/errors.rb
264
264
  - lib/dotsync/icons.rb
265
265
  - lib/dotsync/models/diff.rb