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.



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

def options
  @options
end

Class Method Details

.startObject



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

def self.start
  new.run
end

Instance Method Details

#actionsObject



30
31
32
# File 'lib/appload/runner.rb', line 30

def actions
  [:check_ipa_action, :check_info_plist_action, :check_mpp_action]
end

#check_info_plist_actionObject



41
42
43
# File 'lib/appload/runner.rb', line 41

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

#check_ipa_actionObject



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

def check_ipa_action
  puts 'Please verify the following .ipa information:'
  ap ({ path: @options[:ipa_path],
        bundle_id: @ipa.bundle_identifier,
        bundle_version: @ipa.bundle_version })
end

#check_mpp_actionObject



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

def check_mpp_action
  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)

  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) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/appload/runner.rb', line 88

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

  if yes?
    true
  else
    exit if fail_hard
    false
  end
end

#runObject



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

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

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

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

  submit!
end

#submit!Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/appload/runner.rb', line 72

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)


99
100
101
# File 'lib/appload/runner.rb', line 99

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