Class: Kinksync::File2Sync
- Inherits:
-
Object
- Object
- Kinksync::File2Sync
- Defined in:
- lib/kinksync/file_2_sync.rb
Overview
Class that represents a duple of files with absolute path which can be synced
Instance Method Summary collapse
-
#initialize(file) ⇒ File2Sync
constructor
Configures a File2Sync class.
-
#sync ⇒ Object
Sync a file, copying origin over destination.
Constructor Details
#initialize(file) ⇒ File2Sync
Configures a File2Sync class
12 13 14 15 |
# File 'lib/kinksync/file_2_sync.rb', line 12 def initialize(file) @file = file @twin_file = twin_file(file) end |
Instance Method Details
#sync ⇒ Object
Sync a file, copying origin over destination
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kinksync/file_2_sync.rb', line 22 def sync if File.exist?(@twin_file) && FileUtils.identical?(@file, @twin_file) nil else origin = newer destination = twin_file(origin) FileUtils.mkdir_p(File.dirname(@twin_file)) FileUtils.cp(origin, destination) @file end end |