Class: Fulmar::Infrastructure::Model::Transfer::Base
- Inherits:
-
Object
- Object
- Fulmar::Infrastructure::Model::Transfer::Base
- Defined in:
- lib/fulmar/infrastructure/model/transfer/base.rb
Overview
Abstract class for all transfers, provides common methods
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_CONFIG =
{ debug: false, user: '', password: '', remote_path: nil, local_path: '.', type: :rsync_with_versions }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
-
.config_hash(config) ⇒ Object
Generate a hash over all relevant config values to allow more precise caching.
Instance Method Summary collapse
-
#initialize(config) ⇒ Base
constructor
A new instance of Base.
- #prepare ⇒ Object
- #publish ⇒ Object
-
#test_config ⇒ Object
Test the supplied config for required parameters.
Constructor Details
#initialize(config) ⇒ Base
Returns a new instance of Base.
22 23 24 25 26 27 28 29 30 31 |
# 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 |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
19 20 21 |
# File 'lib/fulmar/infrastructure/model/transfer/base.rb', line 19 def config @config end |
Class Method Details
.config_hash(config) ⇒ Object
Generate a hash over all relevant config values to allow more precise caching
53 54 55 56 57 58 |
# 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 |
Instance Method Details
#prepare ⇒ Object
40 41 42 43 44 45 |
# 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 ⇒ Object
47 48 49 50 |
# 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 ⇒ Object
Test the supplied config for required parameters
34 35 36 37 38 |
# 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 |