datapimp 1.2.5 → 1.2.6
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/lib/datapimp/sync/dropbox_folder.rb +26 -7
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3e7609a425e96b824cd59702a741cf7c90c22feb
         | 
| 4 | 
            +
              data.tar.gz: 019bd86145f9858406eca5b08ee8a7bafbe948c7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f3ec44528217a58b23251a886be555f16ae1533ead7c063d2d5fbb4d39a23c44639175f119a915ca0657e58af94ee6c30f8586ae39e9a221bb4a3967855b4894
         | 
| 7 | 
            +
              data.tar.gz: 0071efb4dff0a298ef67a8a9dbbc510532a0094092c4e42bb75df42f2e0b50f57a2a614b3ab3827b24559209381376a1d7462713810f5db0328e46614667bbe7
         | 
| @@ -21,13 +21,30 @@ module Datapimp | |
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 23 | 
             
                def run_pull_action
         | 
| 24 | 
            +
                  binding.pry
         | 
| 25 | 
            +
             | 
| 24 26 | 
             
                  remote_path_entries.each do |entry|
         | 
| 25 27 | 
             
                    remote_dropbox_path = entry.path
         | 
| 26 | 
            -
                    remote_content = dropbox.download(remote_dropbox_path)
         | 
| 27 | 
            -
                    relative_local_path = remote_dropbox_path.gsub("#{remote}/",'')
         | 
| 28 28 |  | 
| 29 | 
            -
                    log " | 
| 30 | 
            -
                     | 
| 29 | 
            +
                    log "Syncing #{ remote_dropbox_path }"
         | 
| 30 | 
            +
                    begin
         | 
| 31 | 
            +
                      relative_local_path = remote_dropbox_path.gsub("#{remote}/",'')
         | 
| 32 | 
            +
                      target = local_path.join(relative_local_path)
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                      next if target.exist? && target.size == entry.bytes
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                      if entry.is_dir
         | 
| 37 | 
            +
                        log "Creating folder #{ relative_local_path }"
         | 
| 38 | 
            +
                        FileUtils.mkdir_p local_path.join(relative_local_path)
         | 
| 39 | 
            +
                      else
         | 
| 40 | 
            +
                        log "== Syncing #{ entry.path }"
         | 
| 41 | 
            +
                        remote_content = dropbox.download(remote_dropbox_path)
         | 
| 42 | 
            +
                        target.open("w+") {|fh| fh.write(remote_content) }
         | 
| 43 | 
            +
                      end
         | 
| 44 | 
            +
                    rescue => e
         | 
| 45 | 
            +
                      log "== Error while saving #{ remote_dropbox_path } to #{ relative_local_path }"
         | 
| 46 | 
            +
                      log "    * Message: #{ e.message }"
         | 
| 47 | 
            +
                    end
         | 
| 31 48 | 
             
                  end
         | 
| 32 49 | 
             
                end
         | 
| 33 50 |  | 
| @@ -93,13 +110,15 @@ module Datapimp | |
| 93 110 | 
             
                end
         | 
| 94 111 |  | 
| 95 112 | 
             
                def remote_path_entries
         | 
| 96 | 
            -
                   | 
| 113 | 
            +
                  pather = lambda do |entry|
         | 
| 97 114 | 
             
                    if entry.is_dir
         | 
| 98 | 
            -
                      dropbox.ls(entry.path)
         | 
| 115 | 
            +
                      Array(dropbox.ls(entry.path)).map(&pather)
         | 
| 99 116 | 
             
                    else
         | 
| 100 117 | 
             
                      entry
         | 
| 101 118 | 
             
                    end
         | 
| 102 | 
            -
                  end | 
| 119 | 
            +
                  end
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  remote_path.map(&pather).flatten
         | 
| 103 122 | 
             
                end
         | 
| 104 123 |  | 
| 105 124 | 
             
              end
         |