Class: DRbQS::Server::TransferSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/drbqs/server/transfer_setting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, user, directory) ⇒ TransferSetting

Returns a new instance of TransferSetting.



8
9
10
11
12
13
# File 'lib/drbqs/server/transfer_setting.rb', line 8

def initialize(host, user, directory)
  @host = host
  @user = user
  @directory = directory
  @setup_server = false
end

Instance Attribute Details

#directoryObject

Returns the value of attribute directory.



6
7
8
# File 'lib/drbqs/server/transfer_setting.rb', line 6

def directory
  @directory
end

#hostObject

Returns the value of attribute host.



6
7
8
# File 'lib/drbqs/server/transfer_setting.rb', line 6

def host
  @host
end

#userObject

Returns the value of attribute user.



6
7
8
# File 'lib/drbqs/server/transfer_setting.rb', line 6

def user
  @user
end

Instance Method Details

#get_client(same_host) ⇒ Object



37
38
39
# File 'lib/drbqs/server/transfer_setting.rb', line 37

def get_client(same_host)
  @setup_server ? DRbQS::Transfer::Client.new(@directory, same_host, @host, @user) : nil
end

#informationObject



19
20
21
22
23
# File 'lib/drbqs/server/transfer_setting.rb', line 19

def information
  info = "directory: #{@directory}"
  info << ", sftp: #{@user}@#{@host}" if @host && @user
  info
end

#prepared_directoryObject



15
16
17
# File 'lib/drbqs/server/transfer_setting.rb', line 15

def prepared_directory
  @setup_server && @directory
end

#setup_server(directory, opts = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/drbqs/server/transfer_setting.rb', line 25

def setup_server(directory, opts = {})
  return nil if @setup_server
  @directory = directory || @directory
  return nil if !@directory
  @setup_server = true
  @directory = File.expand_path(@directory)
  FileUtils.mkdir_p(@directory)
  @host = opts[:host] || @host
  @user = opts[:user] || @user || ENV['USER']
  true
end