Class: Kinksync::Path2Sync

Inherits:
Object
  • Object
show all
Defined in:
lib/kinksync/path_2_sync.rb

Overview

Class that represents an absolute local or remote path which contains file(s) and/or directories to sync

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Path2Sync

Configures a Path2Sync class

Parameters:

  • path (String)

    local or remote path to sync



12
13
14
# File 'lib/kinksync/path_2_sync.rb', line 12

def initialize(path)
  @path = File.expand_path(path)
end

Instance Method Details

#syncObject

Syncs all files in path and its subdirectories, ignores symlinks

Returns:

  • lists of synced files, only including those changed



21
22
23
24
25
26
27
28
# File 'lib/kinksync/path_2_sync.rb', line 21

def sync
  synced = []
  files_to_sync = Find.find(@path).select do |f|
    File.file?(f) && !File.symlink?(f)
  end
  files_to_sync.each { |f| synced.push(f) if File2Sync.new(f).sync }
  synced
end