Class: Shenzhen::Plugins::SFTP::Client

Inherits:
FTP::Client show all
Defined in:
lib/shenzhen/plugins/ftp.rb

Instance Method Summary collapse

Methods inherited from FTP::Client

#initialize

Constructor Details

This class inherits a constructor from Shenzhen::Plugins::FTP::Client

Instance Method Details

#determine_file_path(file_name, path) ⇒ Object


88
89
90
91
92
93
94
# File 'lib/shenzhen/plugins/ftp.rb', line 88

def determine_file_path(file_name, path)
  if path.empty?
    file_name
  else
    "#{path}/#{file_name}"
  end
end

#upload(ipa, options = {}) ⇒ Object


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/shenzhen/plugins/ftp.rb', line 69

def upload(ipa, options = {})
  session = Net::SSH.start(@host, @user, :password => @password, :port => @port)
  connection = Net::SFTP::Session.new(session).connect!

  path = expand_path_with_substitutions_from_ipa_plist(ipa, options[:path])

  begin
    connection.stat!(path) do |response|
      connection.mkdir! path if options[:mkdir] and not response.ok?

      connection.upload! ipa, determine_file_path(File.basename(ipa), path)
      connection.upload! options[:dsym], determine_file_path(File.basename(options[:dsym]), path) if options[:dsym]
    end
  ensure
    connection.close_channel
    session.shutdown!
  end
end