Class: Deliver::SubmitForReview

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

Instance Method Summary collapse

Instance Method Details

#find_build(app) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/deliver/submit_for_review.rb', line 64

def find_build(app)
  build = nil
  app.latest_version.candidate_builds.each do |b|
    if !build or b.upload_date > build.upload_date
      build = b
    end
  end

  unless build
    Helper.log.fatal app.latest_version.candidate_builds
    raise "Could not find build".red
  end

  return build
end

#select_build(options) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/deliver/submit_for_review.rb', line 31

def select_build(options)
  Helper.log.info "Selecting the latest build..."
  app = options[:app]
  v = app.edit_version
  build = wait_for_build(app)

  Helper.log.info "Selecting build #{build.train_version} (#{build.build_version})..."

  v.select_build(build)
  v.save!

  Helper.log.info "Successfully selected build".green
end

#submit!(options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/deliver/submit_for_review.rb', line 3

def submit!(options)
  app = options[:app]
  select_build(options)

  Helper.log.info "Submitting the app for review..."
  submission = app.create_submission

  # Set app submission information
  # Default Values
  submission.content_rights_contains_third_party_content = false
  submission.content_rights_has_rights = true
  submission.add_id_info_uses_idfa = false

  # User Values
  if options[:submission_information]
    raise "`submission_information` must be a hash" unless options[:submission_information].kind_of?(Hash)
    options[:submission_information].each do |key, value|
      Helper.log.info "Setting '#{key}' to '#{value}'..."
      submission.send("#{key}=", value)
    end
  end

  # Finalize app submission
  submission.complete!

  Helper.log.info "Successfully submitted the app for review!".green
end

#wait_for_build(app) ⇒ Object



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

def wait_for_build(app)
  raise "Could not find app with app identifier #{WatchBuild.config[:app_identifier]}".red unless app

  start = Time.now

  loop do
    build = find_build(app)
    return build if build.processing == false

    Helper.log.info "Waiting iTunes Connect processing for build #{build.train_version} (#{build.build_version})... this might take a while..."
    if (Time.now - start) > (60 * 5)
      Helper.log.info ""
      Helper.log.info "You can tweet: \"iTunes Connect #iosprocessingtime #{((Time.now - start) / 60).round} minutes\""
    end
    sleep 30
  end
  nil
end