Class: Spaceship::Tunes::AppVersionCommon

Inherits:
Object
  • Object
show all
Defined in:
spaceship/lib/spaceship/tunes/app_version_common.rb

Overview

internal to spaceship Represents the common structure between application and app_version

Class Method Summary collapse

Class Method Details

.find_platform(versions, search_platform: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'spaceship/lib/spaceship/tunes/app_version_common.rb', line 13

def find_platform(versions, search_platform: nil)
  # We only support platforms that exist ATM
  search_platform = search_platform.to_sym if search_platform

  platform = versions.detect do |p|
    ['ios', 'osx', 'appletvos'].include?(p['platformString'])
  end

  raise "Could not find platform 'ios', 'osx' or 'appletvos'" unless platform

  # If your app has versions for both iOS and tvOS we will default to returning the iOS version for now.
  # This is intentional as we need to do more work to support apps that have hybrid versions.
  if versions.length > 1 && search_platform.nil?
    platform = versions.detect { |p| p['platformString'].to_sym == :ios }
  elsif !search_platform.nil?
    platform = versions.detect { |p| p['platformString'].to_sym == search_platform }
  end
  platform
end

.find_version_id(platform, is_live) ⇒ Object



7
8
9
10
11
# File 'spaceship/lib/spaceship/tunes/app_version_common.rb', line 7

def find_version_id(platform, is_live)
  version = platform[(is_live ? 'deliverableVersion' : 'inFlightVersion')]
  return nil unless version
  version['id']
end