dotsync 0.1.10 → 0.1.12
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 +4 -4
 - data/CHANGELOG.md +12 -1
 - data/Gemfile.lock +26 -1
 - data/README.md +11 -4
 - data/docs/images/dotsync_pull.png +0 -0
 - data/docs/images/dotsync_push.png +0 -0
 - data/dotsync.gemspec +4 -0
 - data/lib/dotsync/actions/watch_action.rb +1 -1
 - data/lib/dotsync/models/mapping.rb +17 -4
 - data/lib/dotsync/utils/directory_differ.rb +10 -13
 - data/lib/dotsync/utils/file_transfer.rb +27 -1
 - data/lib/dotsync/utils/path_utils.rb +8 -0
 - data/lib/dotsync/version.rb +1 -1
 - data/lib/dotsync.rb +1 -1
 - metadata +18 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2f547b92c47c8fc439eb6e46ab2fb858d6ad7ec8d424c67c76611b990fae88c9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 910ff1e02a260708a8b5dee75a665db652b47936bc565c5b435ca26c31d58c4b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b60dfcd57e1c676ed7a9f2a003610066c37d57689bbb90f864ecae9d5277ad95e9df76794f932858ba486b63f5a9d9ca8990ad4b27ecef73622145647e877526
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 242485598ab533582382f2452ce63bf4772a8f4c3f5178b27a1e74712b31ebffe816550046b1519d02a39cdd360a14d5afa1a776342ec8090e3b4653990e9535
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # 0.1.12
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            - FileTransfer: apply ignores both to src and dest
         
     | 
| 
      
 4 
     | 
    
         
            +
            - DirectoryDiffer: fix diff on simple files
         
     | 
| 
      
 5 
     | 
    
         
            +
            - PullAction: fix deletion older backup
         
     | 
| 
      
 6 
     | 
    
         
            +
            - Readme: new screenshots
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # 0.1.11
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            - Readme: fixes badge icon
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       1 
12 
     | 
    
         
             
            # 0.1.10
         
     | 
| 
       2 
13 
     | 
    
         | 
| 
       3 
14 
     | 
    
         
             
            - Readme: add screenshot for PushAction
         
     | 
| 
         @@ -8,7 +19,7 @@ 
     | 
|
| 
       8 
19 
     | 
    
         
             
            - Exe: improved banner with options
         
     | 
| 
       9 
20 
     | 
    
         
             
            - Options: added "--apply"
         
     | 
| 
       10 
21 
     | 
    
         
             
            - Options: added "--environment-variables"
         
     | 
| 
       11 
     | 
    
         
            -
            -  
     | 
| 
      
 22 
     | 
    
         
            +
            - DirectoryDiffer: show full path using original mapping paths
         
     | 
| 
       12 
23 
     | 
    
         
             
            - Readme: add gem version badge
         
     | 
| 
       13 
24 
     | 
    
         
             
            - Readme: add requirements section
         
     | 
| 
       14 
25 
     | 
    
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                dotsync (0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
                dotsync (0.1.12)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  fileutils (~> 1.7.3)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  find (~> 0.2.0)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  listen (~> 3.9.0)
         
     | 
| 
         @@ -14,7 +14,12 @@ GEM 
     | 
|
| 
       14 
14 
     | 
    
         
             
              specs:
         
     | 
| 
       15 
15 
     | 
    
         
             
                ast (2.4.3)
         
     | 
| 
       16 
16 
     | 
    
         
             
                citrus (3.0.2)
         
     | 
| 
      
 17 
     | 
    
         
            +
                date (3.5.0)
         
     | 
| 
      
 18 
     | 
    
         
            +
                debug (1.11.0)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  irb (~> 1.10)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  reline (>= 0.3.8)
         
     | 
| 
       17 
21 
     | 
    
         
             
                diff-lcs (1.6.2)
         
     | 
| 
      
 22 
     | 
    
         
            +
                erb (5.1.3)
         
     | 
| 
       18 
23 
     | 
    
         
             
                ffi (1.17.2)
         
     | 
| 
       19 
24 
     | 
    
         
             
                ffi (1.17.2-aarch64-linux-gnu)
         
     | 
| 
       20 
25 
     | 
    
         
             
                ffi (1.17.2-aarch64-linux-musl)
         
     | 
| 
         @@ -28,6 +33,11 @@ GEM 
     | 
|
| 
       28 
33 
     | 
    
         
             
                ffi (1.17.2-x86_64-linux-musl)
         
     | 
| 
       29 
34 
     | 
    
         
             
                fileutils (1.7.3)
         
     | 
| 
       30 
35 
     | 
    
         
             
                find (0.2.0)
         
     | 
| 
      
 36 
     | 
    
         
            +
                io-console (0.8.1)
         
     | 
| 
      
 37 
     | 
    
         
            +
                irb (1.15.3)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  pp (>= 0.6.0)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  rdoc (>= 4.0.0)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  reline (>= 0.4.2)
         
     | 
| 
       31 
41 
     | 
    
         
             
                json (2.15.2)
         
     | 
| 
       32 
42 
     | 
    
         
             
                language_server-protocol (3.17.0.5)
         
     | 
| 
       33 
43 
     | 
    
         
             
                lint_roller (1.1.0)
         
     | 
| 
         @@ -40,7 +50,13 @@ GEM 
     | 
|
| 
       40 
50 
     | 
    
         
             
                parser (3.3.10.0)
         
     | 
| 
       41 
51 
     | 
    
         
             
                  ast (~> 2.4.1)
         
     | 
| 
       42 
52 
     | 
    
         
             
                  racc
         
     | 
| 
      
 53 
     | 
    
         
            +
                pp (0.6.3)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  prettyprint
         
     | 
| 
      
 55 
     | 
    
         
            +
                prettyprint (0.2.0)
         
     | 
| 
       43 
56 
     | 
    
         
             
                prism (1.6.0)
         
     | 
| 
      
 57 
     | 
    
         
            +
                psych (5.2.6)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  date
         
     | 
| 
      
 59 
     | 
    
         
            +
                  stringio
         
     | 
| 
       44 
60 
     | 
    
         
             
                racc (1.8.1)
         
     | 
| 
       45 
61 
     | 
    
         
             
                rainbow (3.1.1)
         
     | 
| 
       46 
62 
     | 
    
         
             
                rake (13.3.0)
         
     | 
| 
         @@ -49,7 +65,13 @@ GEM 
     | 
|
| 
       49 
65 
     | 
    
         
             
                  ffi (~> 1.0)
         
     | 
| 
       50 
66 
     | 
    
         
             
                rbs (3.9.5)
         
     | 
| 
       51 
67 
     | 
    
         
             
                  logger
         
     | 
| 
      
 68 
     | 
    
         
            +
                rdoc (6.15.1)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  erb
         
     | 
| 
      
 70 
     | 
    
         
            +
                  psych (>= 4.0.0)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  tsort
         
     | 
| 
       52 
72 
     | 
    
         
             
                regexp_parser (2.11.3)
         
     | 
| 
      
 73 
     | 
    
         
            +
                reline (0.6.2)
         
     | 
| 
      
 74 
     | 
    
         
            +
                  io-console (~> 0.5)
         
     | 
| 
       53 
75 
     | 
    
         
             
                rspec (3.13.2)
         
     | 
| 
       54 
76 
     | 
    
         
             
                  rspec-core (~> 3.13.0)
         
     | 
| 
       55 
77 
     | 
    
         
             
                  rspec-expectations (~> 3.13.0)
         
     | 
| 
         @@ -95,10 +117,12 @@ GEM 
     | 
|
| 
       95 
117 
     | 
    
         
             
                  prism (>= 1.2, < 2.0)
         
     | 
| 
       96 
118 
     | 
    
         
             
                  rbs (>= 3, < 5)
         
     | 
| 
       97 
119 
     | 
    
         
             
                ruby-progressbar (1.13.0)
         
     | 
| 
      
 120 
     | 
    
         
            +
                stringio (3.1.7)
         
     | 
| 
       98 
121 
     | 
    
         
             
                timecop (0.9.10)
         
     | 
| 
       99 
122 
     | 
    
         
             
                toml-rb (4.0.0)
         
     | 
| 
       100 
123 
     | 
    
         
             
                  citrus (~> 3.0, > 3.0)
         
     | 
| 
       101 
124 
     | 
    
         
             
                  racc (~> 1.7)
         
     | 
| 
      
 125 
     | 
    
         
            +
                tsort (0.2.0)
         
     | 
| 
       102 
126 
     | 
    
         
             
                unicode-display_width (3.2.0)
         
     | 
| 
       103 
127 
     | 
    
         
             
                  unicode-emoji (~> 4.1)
         
     | 
| 
       104 
128 
     | 
    
         
             
                unicode-emoji (4.1.0)
         
     | 
| 
         @@ -117,6 +141,7 @@ PLATFORMS 
     | 
|
| 
       117 
141 
     | 
    
         
             
              x86_64-linux-musl
         
     | 
| 
       118 
142 
     | 
    
         | 
| 
       119 
143 
     | 
    
         
             
            DEPENDENCIES
         
     | 
| 
      
 144 
     | 
    
         
            +
              debug (~> 1.11)
         
     | 
| 
       120 
145 
     | 
    
         
             
              dotsync!
         
     | 
| 
       121 
146 
     | 
    
         
             
              rake (~> 13.3.0)
         
     | 
| 
       122 
147 
     | 
    
         
             
              rspec (~> 3.13.1)
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Dotsync
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            [](https://rubygems.org/gems/dotsync)
         
     | 
| 
       4 
4 
     | 
    
         
             
            [](https://github.com/dsaenztagarro/dotsync/actions)
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            > [!WARNING]
         
     | 
| 
         @@ -38,7 +38,7 @@ Dotsync provides the following commands to manage your dotfiles: 
     | 
|
| 
       38 
38 
     | 
    
         
             
              dotsync push
         
     | 
| 
       39 
39 
     | 
    
         
             
              ```
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
              
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
            - **Pull**: Synchronize dotfiles from the repository to your local machine.
         
     | 
| 
       44 
44 
     | 
    
         
             
              ```shell
         
     | 
| 
         @@ -47,6 +47,8 @@ Dotsync provides the following commands to manage your dotfiles: 
     | 
|
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
              During the `pull` operation, `Dotsync::PullAction` creates a backup of the existing files on the destination. These backups are stored in a directory under the XDG path, with each backup organized by a timestamp. To prevent excessive storage usage, only the 10 most recent backups are retained. Older backups are automatically purged, ensuring efficient storage management.
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
      
 50 
     | 
    
         
            +
              
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
       50 
52 
     | 
    
         
             
            - **Watch**: Continuously monitor and sync changes between your local machine and the repository.
         
     | 
| 
       51 
53 
     | 
    
         
             
              ```shell
         
     | 
| 
       52 
54 
     | 
    
         
             
              dotsync watch
         
     | 
| 
         @@ -65,6 +67,13 @@ The configuration file uses a `mappings` structure to define the source and dest 
     | 
|
| 
       65 
67 
     | 
    
         
             
            [[pull.mappings]]
         
     | 
| 
       66 
68 
     | 
    
         
             
            src = "$XDG_CONFIG_HOME_MIRROR"
         
     | 
| 
       67 
69 
     | 
    
         
             
            dest = "$XDG_CONFIG_HOME"
         
     | 
| 
      
 70 
     | 
    
         
            +
            ignore = ["nvim"]
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            [[pull.mappings]]
         
     | 
| 
      
 73 
     | 
    
         
            +
            src  = "$XDG_CONFIG_HOME_MIRROR/nvim"
         
     | 
| 
      
 74 
     | 
    
         
            +
            dest = "$XDG_CONFIG_HOME/nvim"
         
     | 
| 
      
 75 
     | 
    
         
            +
            force = true  # it forces the deletion of destination folder
         
     | 
| 
      
 76 
     | 
    
         
            +
            ignore = ["lazy-lock.json"]  # use relative paths to "dest" to ignore files and folders
         
     | 
| 
       68 
77 
     | 
    
         | 
| 
       69 
78 
     | 
    
         
             
            [[pull.mappings]]
         
     | 
| 
       70 
79 
     | 
    
         
             
            src = "$HOME_MIRROR/.zshenv"
         
     | 
| 
         @@ -78,8 +87,6 @@ src = "$HOME_MIRROR/.zshenv" 
     | 
|
| 
       78 
87 
     | 
    
         
             
            [[push.mappings]]
         
     | 
| 
       79 
88 
     | 
    
         
             
            src = "$XDG_CONFIG_HOME/alacritty"
         
     | 
| 
       80 
89 
     | 
    
         
             
            dest = "$DOTFILES_DIR/config/alacritty"
         
     | 
| 
       81 
     | 
    
         
            -
            force = true # it forces the deletion of destination folder
         
     | 
| 
       82 
     | 
    
         
            -
            ignore = ["themes/rose-pine.toml"] # use relative paths to "dest" to ignore files and folders
         
     | 
| 
       83 
90 
     | 
    
         | 
| 
       84 
91 
     | 
    
         | 
| 
       85 
92 
     | 
    
         
             
            [[watch.mappings]]
         
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
    
        data/dotsync.gemspec
    CHANGED
    
    | 
         @@ -33,6 +33,10 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       33 
33 
     | 
    
         
             
              spec.add_dependency "logger", "~> 1.7.0" # No longer part of default gems from Ruby 3.5
         
     | 
| 
       34 
34 
     | 
    
         
             
              spec.add_dependency "ostruct", "~> 0.6.3" # No longer part of default gems from Ruby 3.5
         
     | 
| 
       35 
35 
     | 
    
         
             
              spec.add_dependency "find", "~> 0.2.0"
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              # Debug with:
         
     | 
| 
      
 38 
     | 
    
         
            +
              # require 'debug'; binding.break
         
     | 
| 
      
 39 
     | 
    
         
            +
              spec.add_development_dependency "debug", "~> 1.11"
         
     | 
| 
       36 
40 
     | 
    
         
             
              spec.add_development_dependency "rake", "~> 13.3.0"
         
     | 
| 
       37 
41 
     | 
    
         
             
              spec.add_development_dependency "rspec", "~> 3.13.1"
         
     | 
| 
       38 
42 
     | 
    
         
             
              spec.add_development_dependency "rubocop", "~> 1.81.1"
         
     | 
| 
         @@ -47,7 +47,7 @@ module Dotsync 
     | 
|
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
                  def handle_file_changes(mapping, modified, added, removed)
         
     | 
| 
       49 
49 
     | 
    
         
             
                    (modified + added).each do |path|
         
     | 
| 
       50 
     | 
    
         
            -
                      new_mapping = mapping. 
     | 
| 
      
 50 
     | 
    
         
            +
                      new_mapping = mapping.apply_to(path)
         
     | 
| 
       51 
51 
     | 
    
         
             
                      logger.info("Copied file: #{new_mapping}", icon: :copy)
         
     | 
| 
       52 
52 
     | 
    
         
             
                      Dotsync::FileTransfer.new(new_mapping).transfer
         
     | 
| 
       53 
53 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -40,12 +40,23 @@ module Dotsync 
     | 
|
| 
       40 
40 
     | 
    
         
             
                end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                def files?
         
     | 
| 
       43 
     | 
    
         
            -
                   
     | 
| 
      
 43 
     | 
    
         
            +
                  files_present? || file_present_in_src_only?
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                def files_present?
         
     | 
| 
      
 47 
     | 
    
         
            +
                  File.file?(src) && File.file?(dest)
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                def file_present_in_src_only?
         
     | 
| 
       44 
51 
     | 
    
         
             
                  File.file?(src) && !File.exist?(dest) && File.directory?(File.dirname(dest))
         
     | 
| 
       45 
52 
     | 
    
         
             
                end
         
     | 
| 
       46 
53 
     | 
    
         | 
| 
       47 
54 
     | 
    
         
             
                def valid?
         
     | 
| 
       48 
     | 
    
         
            -
                  directories? || files?
         
     | 
| 
      
 55 
     | 
    
         
            +
                  directories? || files? || file_present_in_src_only?
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                def file_changed?
         
     | 
| 
      
 59 
     | 
    
         
            +
                  files_present? && (File.size(src) != File.size(dest))
         
     | 
| 
       49 
60 
     | 
    
         
             
                end
         
     | 
| 
       50 
61 
     | 
    
         | 
| 
       51 
62 
     | 
    
         
             
                def backup_possible?
         
     | 
| 
         @@ -68,7 +79,7 @@ module Dotsync 
     | 
|
| 
       68 
79 
     | 
    
         
             
                  msg.join(" ")
         
     | 
| 
       69 
80 
     | 
    
         
             
                end
         
     | 
| 
       70 
81 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
                def  
     | 
| 
      
 82 
     | 
    
         
            +
                def apply_to(path)
         
     | 
| 
       72 
83 
     | 
    
         
             
                  relative_path = if Pathname.new(path).absolute?
         
     | 
| 
       73 
84 
     | 
    
         
             
                    path.delete_prefix(File.join(src, "/"))
         
     | 
| 
       74 
85 
     | 
    
         
             
                  else
         
     | 
| 
         @@ -91,7 +102,9 @@ module Dotsync 
     | 
|
| 
       91 
102 
     | 
    
         
             
                  def process_paths(src, dest, ignores)
         
     | 
| 
       92 
103 
     | 
    
         
             
                    sanitized_src = sanitize_path(src)
         
     | 
| 
       93 
104 
     | 
    
         
             
                    sanitized_dest = sanitize_path(dest)
         
     | 
| 
       94 
     | 
    
         
            -
                    sanitized_ignore = ignores. 
     | 
| 
      
 105 
     | 
    
         
            +
                    sanitized_ignore = ignores.flat_map do |path|
         
     | 
| 
      
 106 
     | 
    
         
            +
                      [File.join(sanitized_src, path), File.join(sanitized_dest, path)]
         
     | 
| 
      
 107 
     | 
    
         
            +
                    end
         
     | 
| 
       95 
108 
     | 
    
         
             
                    [sanitized_src, sanitized_dest, sanitized_ignore]
         
     | 
| 
       96 
109 
     | 
    
         
             
                  end
         
     | 
| 
       97 
110 
     | 
    
         
             
              end
         
     | 
| 
         @@ -2,6 +2,8 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module Dotsync
         
     | 
| 
       4 
4 
     | 
    
         
             
              class DirectoryDiffer
         
     | 
| 
      
 5 
     | 
    
         
            +
                include Dotsync::PathUtils
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       5 
7 
     | 
    
         
             
                extend Forwardable
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
                # attr_reader :src, :dest
         
     | 
| 
         @@ -58,32 +60,27 @@ module Dotsync 
     | 
|
| 
       58 
60 
     | 
    
         
             
                      end
         
     | 
| 
       59 
61 
     | 
    
         
             
                    end
         
     | 
| 
       60 
62 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                     
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                      removals = filter_paths(removals, ignores)
         
     | 
| 
       65 
     | 
    
         
            -
                    end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       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) }
         
     | 
| 
      
 63 
     | 
    
         
            +
                    additions = relative_to_absolute(filter_ignores(additions), mapping_original_dest)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    modifications = relative_to_absolute(filter_ignores(modifications), mapping_original_dest)
         
     | 
| 
      
 65 
     | 
    
         
            +
                    removals = relative_to_absolute(filter_ignores(removals), mapping_original_src)
         
     | 
| 
       70 
66 
     | 
    
         | 
| 
       71 
67 
     | 
    
         
             
                    Dotsync::Diff.new(additions: additions, modifications: modifications, removals: removals)
         
     | 
| 
       72 
68 
     | 
    
         
             
                  end
         
     | 
| 
       73 
69 
     | 
    
         | 
| 
       74 
70 
     | 
    
         
             
                  def diff_mapping_files
         
     | 
| 
       75 
71 
     | 
    
         
             
                    Dotsync::Diff.new.tap do |diff|
         
     | 
| 
       76 
     | 
    
         
            -
                      if  
     | 
| 
      
 72 
     | 
    
         
            +
                      if @mapping.file_present_in_src_only?
         
     | 
| 
       77 
73 
     | 
    
         
             
                        diff.additions << @mapping.original_dest
         
     | 
| 
       78 
     | 
    
         
            -
                       
     | 
| 
      
 74 
     | 
    
         
            +
                      elsif @mapping.file_changed?
         
     | 
| 
       79 
75 
     | 
    
         
             
                        diff.modifications << @mapping.original_dest
         
     | 
| 
       80 
76 
     | 
    
         
             
                      end
         
     | 
| 
       81 
77 
     | 
    
         
             
                    end
         
     | 
| 
       82 
78 
     | 
    
         
             
                  end
         
     | 
| 
       83 
79 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
                  def  
     | 
| 
      
 80 
     | 
    
         
            +
                  def filter_ignores(all_paths)
         
     | 
| 
      
 81 
     | 
    
         
            +
                    return all_paths unless ignores.any?
         
     | 
| 
       85 
82 
     | 
    
         
             
                    all_paths.reject do |path|
         
     | 
| 
       86 
     | 
    
         
            -
                       
     | 
| 
      
 83 
     | 
    
         
            +
                      ignores.any? do |ignore|
         
     | 
| 
       87 
84 
     | 
    
         
             
                        path == ignore || path.start_with?("#{ignore}/")
         
     | 
| 
       88 
85 
     | 
    
         
             
                      end
         
     | 
| 
       89 
86 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -22,7 +22,7 @@ module Dotsync 
     | 
|
| 
       22 
22 
     | 
    
         
             
                  if File.file?(@src)
         
     | 
| 
       23 
23 
     | 
    
         
             
                    transfer_file(@src, @dest)
         
     | 
| 
       24 
24 
     | 
    
         
             
                  else
         
     | 
| 
       25 
     | 
    
         
            -
                     
     | 
| 
      
 25 
     | 
    
         
            +
                    cleanup_folder(@dest, @ignores) if @force
         
     | 
| 
       26 
26 
     | 
    
         
             
                    transfer_folder(@src, @dest)
         
     | 
| 
       27 
27 
     | 
    
         
             
                  end
         
     | 
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
         @@ -50,6 +50,32 @@ module Dotsync 
     | 
|
| 
       50 
50 
     | 
    
         
             
                    end
         
     | 
| 
       51 
51 
     | 
    
         
             
                  end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
      
 53 
     | 
    
         
            +
                  def cleanup_folder(target_dir, exclusions = [])
         
     | 
| 
      
 54 
     | 
    
         
            +
                    exclusions = exclusions.map { |ex| File.expand_path(ex) }
         
     | 
| 
      
 55 
     | 
    
         
            +
                    target_dir = File.expand_path(target_dir)
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    # The `Find.find` method in Ruby performs a depth-first traversal of the
         
     | 
| 
      
 58 
     | 
    
         
            +
                    # file hierarchy. This means it will explore all files and subdirectories
         
     | 
| 
      
 59 
     | 
    
         
            +
                    # within a directory before returning to process the parent directory.
         
     | 
| 
      
 60 
     | 
    
         
            +
                    # Because of this order, `FileUtils.rmdir` can be executed safely at the
         
     | 
| 
      
 61 
     | 
    
         
            +
                    # end of the traversal, as all files and subdirectories within a directory
         
     | 
| 
      
 62 
     | 
    
         
            +
                    # would have already been processed and removed.
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                    Find.find(target_dir) do |path|
         
     | 
| 
      
 65 
     | 
    
         
            +
                      next if path == target_dir
         
     | 
| 
      
 66 
     | 
    
         
            +
                      abs_path = File.expand_path(path)
         
     | 
| 
      
 67 
     | 
    
         
            +
                      if exclusions.any? { |ex| abs_path.start_with?(ex) }
         
     | 
| 
      
 68 
     | 
    
         
            +
                        Find.prune if File.directory?(path)
         
     | 
| 
      
 69 
     | 
    
         
            +
                        next
         
     | 
| 
      
 70 
     | 
    
         
            +
                      end
         
     | 
| 
      
 71 
     | 
    
         
            +
                      if File.file?(path)
         
     | 
| 
      
 72 
     | 
    
         
            +
                        FileUtils.rm(path)
         
     | 
| 
      
 73 
     | 
    
         
            +
                      elsif File.directory?(path) && Dir.empty?(path)
         
     | 
| 
      
 74 
     | 
    
         
            +
                        FileUtils.rmdir(path)
         
     | 
| 
      
 75 
     | 
    
         
            +
                      end
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
       53 
79 
     | 
    
         
             
                  def ignore?(path)
         
     | 
| 
       54 
80 
     | 
    
         
             
                    @ignores.any? { |ignore| path.start_with?(ignore) }
         
     | 
| 
       55 
81 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -16,6 +16,14 @@ module Dotsync 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  path.gsub(/\$(\w+)/) { "\e[38;5;#{ENV_VARS_COLOR}m$#{$1}\e[0m" }
         
     | 
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
                # Converts an array of relative paths to absolute paths based on a specified base path
         
     | 
| 
      
 20 
     | 
    
         
            +
                # @param [Array<String>] paths The array of relative paths
         
     | 
| 
      
 21 
     | 
    
         
            +
                # @param [String] base_path The base absolute path to resolve relative paths
         
     | 
| 
      
 22 
     | 
    
         
            +
                # @return [Array<String>] The array of absolute paths
         
     | 
| 
      
 23 
     | 
    
         
            +
                def relative_to_absolute(paths, base_path)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  paths.map { |path| File.join(base_path, path) }
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       19 
27 
     | 
    
         
             
                # Translates /tmp paths to /private/tmp paths on macOS
         
     | 
| 
       20 
28 
     | 
    
         
             
                # Retains other paths as-is
         
     | 
| 
       21 
29 
     | 
    
         
             
                # @param [String] path The input path to translate
         
     | 
    
        data/lib/dotsync/version.rb
    CHANGED
    
    
    
        data/lib/dotsync.rb
    CHANGED
    
    | 
         @@ -10,10 +10,10 @@ require "ostruct" 
     | 
|
| 
       10 
10 
     | 
    
         
             
            require "find"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            # Utils
         
     | 
| 
      
 13 
     | 
    
         
            +
            require_relative "dotsync/utils/path_utils"
         
     | 
| 
       13 
14 
     | 
    
         
             
            require_relative "dotsync/utils/logger"
         
     | 
| 
       14 
15 
     | 
    
         
             
            require_relative "dotsync/utils/file_transfer"
         
     | 
| 
       15 
16 
     | 
    
         
             
            require_relative "dotsync/utils/directory_differ"
         
     | 
| 
       16 
     | 
    
         
            -
            require_relative "dotsync/utils/path_utils"
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
            # Models
         
     | 
| 
       19 
19 
     | 
    
         
             
            require_relative "dotsync/models/mapping"
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.12
         
     | 
| 
       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-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-11-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: toml-rb
         
     | 
| 
         @@ -94,6 +94,20 @@ dependencies: 
     | 
|
| 
       94 
94 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       95 
95 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
96 
     | 
    
         
             
                    version: 0.2.0
         
     | 
| 
      
 97 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: debug
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
       97 
111 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       98 
112 
     | 
    
         
             
              name: rake
         
     | 
| 
       99 
113 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -244,6 +258,8 @@ files: 
     | 
|
| 
       244 
258 
     | 
    
         
             
            - README.md
         
     | 
| 
       245 
259 
     | 
    
         
             
            - RELEASING.md
         
     | 
| 
       246 
260 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 261 
     | 
    
         
            +
            - docs/images/dotsync_pull.png
         
     | 
| 
      
 262 
     | 
    
         
            +
            - docs/images/dotsync_push.png
         
     | 
| 
       247 
263 
     | 
    
         
             
            - docs/images/dotsync_push_apply.png
         
     | 
| 
       248 
264 
     | 
    
         
             
            - dotsync.gemspec
         
     | 
| 
       249 
265 
     | 
    
         
             
            - exe/console
         
     |