class Fulmar::Infrastructure::Model::Transfer::Base
Abstract class for all transfers, provides common methods
Constants
- DEFAULT_CONFIG
Attributes
config[RW]
Public Class Methods
config_hash(config)
click to toggle source
Generate a hash over all relevant config values to allow more precise caching
# File lib/fulmar/infrastructure/model/transfer/base.rb, line 53 def self.config_hash(config) id_string = self.class.to_s id_string << DEFAULT_CONFIG.keys.map { |key| config[key].to_s }.join('-') id_string << config[:hostname] Digest::SHA256.hexdigest id_string end
new(config)
click to toggle source
@param [Fulmar::Domain::Service::ConfigurationService] config
# File lib/fulmar/infrastructure/model/transfer/base.rb, line 22 def initialize(config) @config = config @config.merge(DEFAULT_CONFIG) # Remove trailing slashes @config[:local_path] = @config[:local_path].chomp('/') if @config[:local_path] @config[:remote_path] = @config[:remote_path].chomp('/') if @config[:remote_path] @prepared = false end
Public Instance Methods
prepare()
click to toggle source
# File lib/fulmar/infrastructure/model/transfer/base.rb, line 40 def prepare @local_shell = Fulmar::Shell.new @config[:local_path] @local_shell.strict = true @local_shell.debug = @config[:debug] @prepared = true end
publish()
click to toggle source
# File lib/fulmar/infrastructure/model/transfer/base.rb, line 47 def publish # Placeholder for consistent api, currently only implemented in rsync_with_versions true end
test_config()
click to toggle source
Test the supplied config for required parameters
# File lib/fulmar/infrastructure/model/transfer/base.rb, line 34 def test_config required = %i[host remote_path local_path] required.each { |key| raise "Configuration is missing required setting '#{key}'." if @config.blank? } raise ':remote_path must be absolute' if @config[:remote_path][0, 1] != '/' end