lib/spaceship/portal/provisioning_profile.rb in spaceship-0.3.4 vs lib/spaceship/portal/provisioning_profile.rb in spaceship-0.4.0
- old
+ new
@@ -14,16 +14,16 @@
# @example
# "23d7df3b-9767-4e85-a1ea-1df4d8f32fec"
attr_accessor :uuid
# @return (DateTime) The date and time of when the profile
- # expires.
+ # expires.
# @example
# #<DateTime: 2015-11-25T22:45:50+00:00 ((2457352j,81950s,0n),+0s,2299161j)>
attr_accessor :expires
- # @return (String) The profile distribution type. You probably want to
+ # @return (String) The profile distribution type. You probably want to
# use the class type to detect the profile type instead of this string.
# @example AppStore Profile
# "store"
# @example AdHoc Profile
# "adhoc"
@@ -43,11 +43,11 @@
# "Expired"
# @example Invalid (e.g. code signing identity not available any more)
# "Invalid"
attr_accessor :status
- # @return (String) The type of the profile (development or distribution).
+ # @return (String) The type of the profile (development or distribution).
# You'll probably not need this value
# @example Distribution
# "iOS Distribution"
# @example Development
# "iOS Development"
@@ -67,22 +67,22 @@
attr_accessor :managing_app
# A reference to the app this profile is for.
# You can then easily access the value directly
# @return (App) The app this profile is for
- #
+ #
# @example Example Value
# <Spaceship::App
# @app_id="2UMR2S6PAA"
# @name="App Name"
# @platform="ios"
# @prefix="5A997XSAAA"
# @bundle_id="com.krausefx.app"
# @is_wildcard=false
# @dev_push_enabled=false
# @prod_push_enabled=false>
- #
+ #
# @example Usage
# profile.app.name
attr_accessor :app
# @return (Array) A list of certificates used for this profile
@@ -97,26 +97,26 @@
# @owner_type="team"
# @owner_name=nil
# @owner_id=nil
# @type_display_id="R58UK2EWAA">]
# ]
- #
+ #
# @example Usage
# profile.certificates.first.id
attr_accessor :certificates
# @return (Array) A list of devices this profile is enabled for.
# This will always be [] for AppStore profiles
- #
+ #
# @example Example Value
# <Spaceship::Device
# @id="WXQ7V239BE"
# @name="Grahams iPhone 4s"
# @udid="ba0ac7d70f7a14c6fa02ef0e02f4fe9c5178e2f7"
# @platform="ios"
# @status="c">]
- #
+ #
# @example Usage
# profile.devices.first.name
attr_accessor :devices
attr_mapping({
@@ -202,11 +202,11 @@
# Fill in sensible default values
name ||= [bundle_id, self.pretty_type].join(' ')
devices = [] if (self == AppStore or self == InHouse) # App Store Profiles MUST NOT have devices
- certificate_parameter = certificate.collect { |c| c.id } if certificate.kind_of?Array
+ certificate_parameter = certificate.collect { |c| c.id } if certificate.kind_of? Array
certificate_parameter ||= [certificate.id]
# Fix https://github.com/KrauseFx/fastlane/issues/349
certificate_parameter = certificate_parameter.first if certificate_parameter.count == 1
@@ -215,33 +215,23 @@
# For Development and AdHoc we usually want all devices by default
devices = Spaceship::Device.all
end
end
- def send_create_request(name, type, app_id, certificate_parameter, devices)
- tries ||= 5
- client.create_provisioning_profile!(name, type, app_id, certificate_parameter, devices)
- rescue => ex
- unless (tries -= 1).zero?
- sleep 3
- retry
- end
-
- raise ex # re-raise the exception
+ profile = client.with_retry do
+ client.create_provisioning_profile!(name,
+ self.type,
+ app.app_id,
+ certificate_parameter,
+ devices.map {|d| d.id} )
end
- profile = send_create_request(name,
- self.type,
- app.app_id,
- certificate_parameter,
- devices.map {|d| d.id} )
-
self.new(profile)
end
# @return (Array) Returns all profiles registered for this account
- # If you're calling this from a subclass (like AdHoc), this will
+ # If you're calling this from a subclass (like AdHoc), this will
# only return the profiles that are of this type
def all
profiles = client.provisioning_profiles.map do |profile|
self.factory(profile)
end
@@ -315,68 +305,52 @@
client.delete_provisioning_profile!(self.id)
end
# Repair an existing provisioning profile
# alias to update!
- # @return (ProvisioningProfile) A new provisioning profile, as
+ # @return (ProvisioningProfile) A new provisioning profile, as
# the repair method will generate a profile with a new ID
def repair!
update!
end
# Updates the provisioning profile from the local data
# e.g. after you added new devices to the profile
# This will also update the code signing identity if necessary
- # @return (ProvisioningProfile) A new provisioning profile, as
+ # @return (ProvisioningProfile) A new provisioning profile, as
# the repair method will generate a profile with a new ID
def update!
unless certificate_valid?
- if self.kind_of?Development
+ if self.kind_of? Development
self.certificates = [Spaceship::Certificate::Development.all.first]
- elsif self.kind_of?InHouse
+ elsif self.kind_of? InHouse
self.certificates = [Spaceship::Certificate::InHouse.all.first]
else
- self.certificates = [Spaceship::Certificate::Production.all.first]
+ self.certificates = [Spaceship::Certificate::Production.all.first]
end
end
- def send_update_request(id, name, distribution_method, app_id, certificates, devices)
- tries ||= 5
+ client.with_retry do
client.repair_provisioning_profile!(
id,
name,
distribution_method,
- app_id,
- certificates,
- devices
+ app.app_id,
+ certificates.map { |c| c.id },
+ devices.map { |d| d.id }
)
- rescue => ex
- unless (tries -= 1).zero?
- sleep 3
- retry
- end
- raise ex # re-raise the exception
end
- send_update_request(
- self.id,
- self.name,
- self.distribution_method,
- self.app.app_id,
- self.certificates.map { |c| c.id },
- self.devices.map { |d| d.id }
- )
-
# We need to fetch the provisioning profile again, as the ID changes
- profile = Spaceship::ProvisioningProfile.all.find do |profile|
- profile.name == self.name # we can use the name as it's valid
+ profile = Spaceship::ProvisioningProfile.all.find do |p|
+ p.name == self.name # we can use the name as it's valid
end
return profile
end
# Is the certificate of this profile available?
- # @return (Bool) is the certificate valid?
+ # @return (Bool) is the certificate valid?
def certificate_valid?
return false if (certificates || []).count == 0
certificates.each do |c|
if Spaceship::Certificate.all.collect { |s| s.id }.include?(c.id)
return true