Class: Deliver::DetectValues

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

Instance Method Summary collapse

Instance Method Details

#ensure_folders_created(options) ⇒ Object



44
45
46
47
# File 'lib/deliver/detect_values.rb', line 44

def ensure_folders_created(options)
  FileUtils.mkdir_p(options[:screenshots_path])
  FileUtils.mkdir_p(options[:metadata_path])
end

#find_app(options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/deliver/detect_values.rb', line 27

def find_app(options)
  search_by = options[:app_identifier]
  search_by = options[:app] if search_by.to_s.length == 0
  app = Spaceship::Application.find(search_by)
  if app
    options[:app] = app
  else
    UI.user_error!("Could not find app with app identifier '#{options[:app_identifier]}' in your iTunes Connect account (#{options[:username]} - Team: #{Spaceship::Tunes.client.team_id})")
  end
end

#find_app_identifier(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/deliver/detect_values.rb', line 12

def find_app_identifier(options)
  return if options[:app_identifier]

  if options[:ipa]
    identifier = FastlaneCore::IpaFileAnalyser.fetch_app_identifier(options[:ipa])
  elsif options[:pkg]
    identifier = FastlaneCore::PkgFileAnalyser.fetch_app_identifier(options[:pkg])
  end

  options[:app_identifier] = identifier if identifier.to_s.length > 0
  options[:app_identifier] ||= UI.input("The Bundle Identifier of your App: ")
rescue
  UI.user_error!("Could not infer your App's Bundle Identifier")
end

#find_folders(options) ⇒ Object



38
39
40
41
42
# File 'lib/deliver/detect_values.rb', line 38

def find_folders(options)
  containing = Helper.fastlane_enabled? ? FastlaneCore::FastlaneFolder.path : '.'
  options[:screenshots_path] ||= File.join(containing, 'screenshots')
  options[:metadata_path] ||= File.join(containing, 'metadata')
end

#find_platform(options) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/deliver/detect_values.rb', line 61

def find_platform(options)
  if options[:ipa]
    options[:platform] ||= FastlaneCore::IpaFileAnalyser.fetch_app_platform(options[:ipa])
  elsif options[:pkg]
    options[:platform] = 'osx'
  end
end

#find_version(options) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/deliver/detect_values.rb', line 49

def find_version(options)
  return if options[:app_version]

  if options[:ipa]
    options[:app_version] ||= FastlaneCore::IpaFileAnalyser.fetch_app_version(options[:ipa])
  elsif options[:pkg]
    options[:app_version] ||= FastlaneCore::PkgFileAnalyser.fetch_app_version(options[:pkg])
  end
rescue
  UI.user_error!("Could not infer your app's version")
end

#run!(options, skip_params = {}) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/deliver/detect_values.rb', line 3

def run!(options, skip_params = {})
  find_app_identifier(options)
  find_app(options)
  find_folders(options)
  ensure_folders_created(options)
  find_version(options) unless skip_params[:skip_version]
  find_platform(options)
end