Sha256: ead2f620a04d40e1a3bf1baa04df7871be3b84a53b2122a48d03eac3e2eabd50

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

# Handles transfers for Job class
module RestFtpDaemon
  module Remote
    class RemoteBase
      include BmcDaemonLib::LoggerHelper

      # Class options
      attr_reader :logger
      attr_reader :log_prefix
      attr_accessor :job

      # Delegate set_info info to Job
      delegate :set_info, to: :job

      def initialize target, log_prefix, debug = false, ftpes = false
        # Init
        @target = target
        @ftpes = ftpes
        @debug = !!debug

        # Build and empty job to protect set_info delegation
        @job = Job.new(nil, {})

        # Logger
        @log_prefix = log_prefix || {}
        @logger = BmcDaemonLib::LoggerPool.instance.get :transfer

        # Annnounce object
        log_info "RemoteBase.initialize debug[#{debug}] target[#{target.path}] "

        # Prepare real object
        prepare
      end

      def prepare
      end

      def connect
        # Debug mode ?
        return unless @debug
        puts
        puts "-------------------- SESSION STARTING -------------------------"
        puts "class\t #{myname}"
        puts "host\t #{@target.host}"
        puts "user\t #{@target.user}"
        puts "port\t #{@target.port}"
        puts "---------------------------------------------------------------"
      end

      def chdir_or_create directory, mkdir = false
      end

      def remove! target
      end

      def close
        log_debug "RemoteBase.close"

        # Debug mode ?
        return unless @debug
        puts "-------------------- SESSION CLOSING --------------------------"
      end

    private

      def split_path path
        return unless path.is_a? String
        return File.dirname(path), File.basename(path)
      end

      # def extract_parent path
      #   return unless path.is_a? String
      #   m = path.match(/^(.*)\/([^\/]+)\/?$/)
      #   return m[1], m[2] unless m.nil?
      # end

      def myname
        self.class.to_s
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.434.0 lib/rest-ftp-daemon/remote/base.rb
rest-ftp-daemon-0.433.0 lib/rest-ftp-daemon/remote/base.rb