Class: Repository::SyncManager

Inherits:
Object
  • Object
show all
Defined in:
lib/devlogs/repository/sync_manager.rb

Overview

SyncManager is an abstraction class for managing any necessity to sync files on the file system using Rsync.

Instance Method Summary collapse

Constructor Details

#initialize(config_store) ⇒ SyncManager

Returns a new instance of SyncManager.

Parameters:



15
16
17
# File 'lib/devlogs/repository/sync_manager.rb', line 15

def initialize(config_store)
  @config_store = config_store
end

Instance Method Details

#runObject

Use trailing slash to avoid sub-directory See rsync manual page



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/devlogs/repository/sync_manager.rb', line 25

def run
  dest_path = @config_store.values.mirror.path
  src_path = config_store_path_with_trailing

  runner.run("-av", src_path, dest_path) do |result|
    if result.success?
      puts "Mirror sync complete."
      result.changes.each do |change|
        puts "#{change.filename} (#{change.summary})"
      end
    else
      raise "Failed to sync: #{result.error}"
    end
  end
end