Module: Fronde::Sync
- Defined in:
- lib/fronde/sync.rb,
lib/fronde/sync/rsync.rb,
lib/fronde/sync/neocities.rb
Overview
Entrypoint for synchronization with remote public server
Defined Under Namespace
Classes: Error, Neocities, Rsync
Constant Summary collapse
- ALLOWED_SYNCER =
%w[rsync neocities].freeze
Class Method Summary collapse
- .extract_method_and_remote(type) ⇒ Object
- .pull_or_push(direction, type, test: false, verbose: false) ⇒ Object
Class Method Details
.extract_method_and_remote(type) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/fronde/sync.rb', line 14 def self.extract_method_and_remote(type) remote_path = Fronde::CONFIG.get("#{type}_remote") raise Error, "No #{type} remote path set" if remote_path.nil? method, remote = remote_path.split(':', 2) return [method, remote] if ALLOWED_SYNCER.include?(method) ['rsync', remote_path] end |
.pull_or_push(direction, type, test: false, verbose: false) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/fronde/sync.rb', line 24 def self.pull_or_push(direction, type, test: false, verbose: false) method, remote_path = extract_method_and_remote type public_folder = Fronde::CONFIG.get("#{type}_public_folder") klass = Kernel.const_get("::Fronde::Sync::#{method.capitalize}") syncer = klass.new(remote_path, public_folder, verbose:) Thread.new { syncer.send(direction, test:) } end |