Class: Deliver::ItunesTransporter

Inherits:
Object
  • Object
show all
Defined in:
lib/deliver/itunes_transporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user = nil, password = nil) ⇒ ItunesTransporter

Returns a new instance of the iTunesTransporter. If no username or password given, it will be taken from the #CredentialsManager::PasswordManager



31
32
33
34
# File 'lib/deliver/itunes_transporter.rb', line 31

def initialize(user = nil, password = nil)
  @user = (user || CredentialsManager::PasswordManager.shared_manager.username)
  @password = (password || CredentialsManager::PasswordManager.shared_manager.password)
end

Class Method Details

.hide_transporter_outputObject

This will be called from the Deliverfile, and disables the logging of the transporter output



24
25
26
# File 'lib/deliver/itunes_transporter.rb', line 24

def self.hide_transporter_output
  @@hide_transporter_output = true
end

Instance Method Details

#download(app, dir = nil) ⇒ Bool

Downloads the latest version of the app metadata package from iTC.

Parameters:

  • app (Deliver::App)

    The app you want to download the data for

  • dir (String) (defaults to: nil)

    the path to the package file

Returns:

  • (Bool)

    True if everything worked fine

Raises:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/deliver/itunes_transporter.rb', line 43

def download(app, dir = nil)
  dir ||= "/tmp"
  raise TransporterInputError.new("No valid Deliver::App given") unless app.kind_of?Deliver::App

  Helper.log.info "Going to download app metadata from iTunesConnect"
  dir ||= app.
  command = build_download_command(@user, @password, app.apple_id, dir)

  result = execute_transporter(command)

  itmsp_path = [dir, "#{app.apple_id}.itmsp"].join('/')
  if result and File.directory?itmsp_path
    Helper.log.info "Successfully downloaded the latest package from iTunesConnect.".green
  else
    Helper.log.fatal "Could not download metadata from iTunes Connect. Do you have special characters in your password (Like ' or \")?"
  end

  result
end

#upload(app, dir) ⇒ Bool

Uploads the modified package back to iTunesConnect

Parameters:

  • app (Deliver::App)

    The app you want to download the data for

  • dir (String)

    the path in which the package file is located

Returns:

  • (Bool)

    True if everything worked fine

Raises:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/deliver/itunes_transporter.rb', line 70

def upload(app, dir)
  raise TransporterInputError.new("No valid Deliver::App given") unless app.kind_of?Deliver::App

  dir ||= app.
  dir += "/#{app.apple_id}.itmsp"

  Helper.log.info "Going to upload updated app to iTunesConnect"

  command = build_upload_command(@user, @password, dir)
  result = execute_transporter(command)

  if result
    Helper.log.info "Successfully uploaded package to iTunesConnect. It might take a few minutes until it's visible online.".green

    FileUtils.rm_rf(dir) unless Helper.is_test? # we don't need the package any more, since the upload was successful
  end

  result
end