class Shenzhen::Plugins::SFTP::Client

Public Instance Methods

determine_file_path(file_name, path) click to toggle source
# 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 = {}) click to toggle source
# 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