Sha256: 6975b809a5562b11ce57c08d3b93116c4416c1348262e8f2130f09e79e6571d7

Contents?: true

Size: 1.61 KB

Versions: 37

Compression:

Stored size: 1.61 KB

Contents

require 'fulmar/shell'

module Fulmar
  module Infrastructure
    module Service
      module Transfer
        # Abstract class for alle transfers, provides common methods
        class Base
          DEFAULT_CONFIG = {
            debug: false,
            user: '',
            password: '',
            remote_path: nil,
            local_path: '.',
            type: :rsync_with_versions
          }

          attr_accessor :config

          # @param [Fulmar::Domain::Service::ConfigurationService] config
          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

          # Test the supplied config for required parameters
          def test_config
            required = [:host, :remote_path, :local_path]
            required.each { |key| fail "Configuration is missing required setting '#{key}'." if @config.blank? }
            fail ':remote_path must be absolute' if @config[:remote_path][0, 1] != '/'
          end

          def prepare
            @local_shell = Fulmar::Infrastructure::Service::ShellService.new @config[:local_path]
            @local_shell.debug = @config[:debug]
            @prepared = true
          end

          def publish
            # Placeholder for consistent api, currently only implemented in rsync_with_versions
            true
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
fulmar-1.8.0 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.7.5 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.7.4 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.7.3 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.7.2 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.7.1 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.7.0 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.6.4 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.6.3 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.6.2 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.6.1 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.6.0 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.5.2 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.5.1 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.5.0 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.4.2 lib/fulmar/infrastructure/service/transfer/base.rb
fulmar-1.4.1 lib/fulmar/infrastructure/service/transfer/base.rb