Class: Appload::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/appload/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/appload/runner.rb', line 7

def options
  @options
end

Class Method Details

.startObject



9
10
11
# File 'lib/appload/runner.rb', line 9

def self.start
  new.run
end

Instance Method Details

#check_info_plistObject



37
38
39
# File 'lib/appload/runner.rb', line 37

def check_info_plist
  ap(@ipa.info_plist, index: false)
end

#check_ipaObject



31
32
33
34
35
# File 'lib/appload/runner.rb', line 31

def check_ipa
  ap 'Please verify the following .ipa information:'
  ap('path' => @options[:ipa_path],
     bundle_id: @ipa.bundle_identifier)
end

#check_mppObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/appload/runner.rb', line 41

def check_mpp
  profile = @ipa.provisioning_profile

  if !profile
    puts 'No provisioning profile found in the .ipa!'.red
    return
  elsif profile.expired?
    puts 'Provisioning profile expired!'.red
    return
  end

  cert = profile.developer_certificates.first
  fingerprint = OpenSSL::Digest::SHA1.new(cert.to_der).to_s.upcase

  ap 'Please verify the following provisioning profile information:'
  sleep(1.5)

  ap({
       name: profile.name,
       team_id: profile.team_identifier,
       SHA1: fingerprint,
       devices: profile.provisioned_devices,
       expiration: profile.expiration_date,
       entitlements: profile.entitlements.ents
     }, index: false)
end

#prompt_user(message = 'Continue?', fail_hard = true, **_opts) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/appload/runner.rb', line 84

def prompt_user(message = 'Continue?', fail_hard = true, **_opts)
  print "#{message} ".green

  if yes?
    true
  else
    exit if fail_hard
    false
  end
end

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/appload/runner.rb', line 13

def run
  puts "Appload #{Appload::VERSION}"
  @options = Appload::Options.new.options

  Pliney::IPA.from_path(options[:ipa_path]) do |ipa|
    @ipa = ipa

    actions = [:check_ipa, :check_info_plist, :check_mpp]

    actions.each do |action|
      send(action)
      prompt_user
    end
  end

  submit!
end

#submit!Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/appload/runner.rb', line 68

def submit!
  command = ['deliver', '--ipa', @options[:ipa_path]]
  print 'Submit for review? '.green
  command << '--submit_for_review' if yes?

  puts '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'.red
  puts '% Are you sure you want to submit? %'.red
  puts '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'.red

  if yes?
    puts
    puts 'Run this command:'.green
    puts command.join(' ')
  end
end

#yes?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/appload/runner.rb', line 95

def yes?
  %w(y Y).include?(STDIN.gets.chomp)
end