spaceship 0.21.0 → 0.21.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6a3472e6fb40f5531aa8ae2c860f26fe8594c37
4
- data.tar.gz: af5a9f4a0b7c9115123b32c07ef642d3ad80cfe6
3
+ metadata.gz: 5ce52c239b938c9368777decf6b3b239a32c93de
4
+ data.tar.gz: 6c5cc9ef074cc1216b07d76c2454ea8fb593e501
5
5
  SHA512:
6
- metadata.gz: 4b221fef762f3099d9893703b3959ba5302c595b23110af77a392febe04ae894b01d51065a877ebd8e0441c9e1210b09514ec87c3f9fb22264ac56c7fda2e2c9
7
- data.tar.gz: 91d022c2ebacf26a18bdb8d1667ae886d0a91d709d1bacf214d9ed96e65c36d43e05ef75a0240540b40d138d51707fd0d55167f28725ec62940ae36d7fb961fd
6
+ metadata.gz: 0f2e0c03d6ecb1695326598096e8356d6894db28c206d55c27898ba720f87c9c41dfd6c429b31bd41a43404201252691f640f3be6aa0b25e103a901cf6857f46
7
+ data.tar.gz: f7a42c64841df2afd1cef01e8660b2e69ecc76c6d40a847d01033e0b6a95b3010786fc206bcd717b98884c397fd661faf13aeca98f8b7d1488cd6b046781a995
@@ -193,7 +193,7 @@ module Spaceship
193
193
 
194
194
  def with_retry(tries = 5, &_block)
195
195
  return yield
196
- rescue Faraday::Error::ConnectionFailed, Faraday::Error::TimeoutError, AppleTimeoutError => ex # New Faraday version: Faraday::TimeoutError => ex
196
+ rescue Faraday::Error::ConnectionFailed, Faraday::Error::TimeoutError, AppleTimeoutError, Errno::EPIPE => ex # New Faraday version: Faraday::TimeoutError => ex
197
197
  unless (tries -= 1).zero?
198
198
  logger.warn("Timeout received: '#{ex.message}'. Retrying after 3 seconds (remaining: #{tries})...")
199
199
  sleep 3 unless defined? SpecHelper
@@ -201,7 +201,7 @@ module Spaceship
201
201
  end
202
202
  raise ex # re-raise the exception
203
203
  rescue UnauthorizedAccessError => ex
204
- if @loggedin
204
+ if @loggedin && !(tries -= 1).zero?
205
205
  msg = "Auth error received: '#{ex.message}'. Login in again then retrying after 3 seconds (remaining: #{tries})..."
206
206
  puts msg if $verbose
207
207
  logger.warn msg
@@ -155,6 +155,16 @@ module Spaceship
155
155
  "4APLUP237T" => ApplePay
156
156
  }
157
157
 
158
+ OLDER_IOS_CERTIFICATE_TYPES = [
159
+ # those are also sent by the browser, but not sure what they represent
160
+ "T44PTHVNID",
161
+ "DZQUP8189Y",
162
+ "FGQUP4785Z",
163
+ "S5WE21TULA",
164
+ "3BQKVH9I2X", # ProductionPush,
165
+ "FUOY7LWJET"
166
+ ]
167
+
158
168
  MAC_CERTIFICATE_TYPE_IDS = {
159
169
  "749Y1QAGU7" => MacDevelopment,
160
170
  "HXZEUKP0FP" => MacAppDistribution,
@@ -239,6 +249,7 @@ module Spaceship
239
249
  if self == Certificate # are we the base-class?
240
250
  type_ids = mac ? MAC_CERTIFICATE_TYPE_IDS : IOS_CERTIFICATE_TYPE_IDS
241
251
  types = type_ids.keys
252
+ types += OLDER_IOS_CERTIFICATE_TYPES unless mac
242
253
  else
243
254
  types = [CERTIFICATE_TYPE_IDS.key(self)]
244
255
  mac = MAC_CERTIFICATE_TYPE_IDS.values.include? self
@@ -159,8 +159,15 @@ module Spaceship
159
159
  # @param app_id (String) The unique Apple ID of this app
160
160
  # @param is_live (Boolean)
161
161
  def find(application, app_id, is_live)
162
+ # we only support applications
163
+ platform = Spaceship::Tunes::AppVersionCommon.find_platform(application.raw_data['versionSets'])
164
+ raise "We do not support BUNDLE types right now" if platform['type'] == 'BUNDLE'
165
+
166
+ # too bad the "id" field is empty, it forces us to make more requests to the server
167
+ # these could also be cached
162
168
  attrs = client.app_version(app_id, is_live)
163
169
  return nil unless attrs
170
+
164
171
  attrs.merge!(application: application)
165
172
  attrs.merge!(is_live: is_live)
166
173
 
@@ -0,0 +1,31 @@
1
+ module Spaceship
2
+ module Tunes
3
+ # internal to spaceship
4
+ # Represents the common structure between application['versionSets'] and app_version['platform']
5
+ class AppVersionCommon
6
+ class << self
7
+ def find_version_id(platform, is_live)
8
+ version = platform[(is_live ? 'deliverableVersion' : 'inFlightVersion')]
9
+ return nil unless version
10
+ version['id']
11
+ end
12
+
13
+ def find_platform(versions)
14
+ # We only support platforms that exist ATM
15
+ platform = versions.detect do |p|
16
+ ['ios', 'osx', 'appletvos'].include? p['platformString']
17
+ end
18
+
19
+ raise "Could not find platform ios, osx or appletvos for app #{app_id}" unless platform
20
+
21
+ # If your app has versions for both iOS and tvOS we will default to returning the iOS version for now.
22
+ # This is intentional as we need to do more work to support apps that have hybrid versions.
23
+ if versions.length > 1
24
+ platform = versions.detect { |p| p['platformString'] == "ios" }
25
+ end
26
+ platform
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -11,11 +11,6 @@ module Spaceship
11
11
  # "Spaceship App"
12
12
  attr_accessor :name
13
13
 
14
- # @return (String) the supported platform of this app
15
- # @example
16
- # "ios"
17
- attr_accessor :platform
18
-
19
14
  # @return (String) The Vendor ID provided by iTunes Connect
20
15
  # @example
21
16
  # "1435592086"
@@ -42,7 +37,6 @@ module Spaceship
42
37
  attr_mapping(
43
38
  'adamId' => :apple_id,
44
39
  'name' => :name,
45
- 'appType' => :platform,
46
40
  'vendorId' => :vendor_id,
47
41
  'bundleId' => :bundle_id,
48
42
  'lastModifiedDate' => :last_modified,
@@ -100,13 +94,6 @@ module Spaceship
100
94
  # @return (Spaceship::AppVersion) Receive the version that is currently live on the
101
95
  # App Store. You can't modify all values there, so be careful.
102
96
  def live_version
103
- if (raw_data['versions'] || []).count == 1
104
- v = raw_data['versions'].last
105
- if ['Prepare for Upload', 'prepareForUpload'].include?(v['state']) # this only applies for the initial version
106
- return nil
107
- end
108
- end
109
-
110
97
  Spaceship::AppVersion.find(self, self.apple_id, true)
111
98
  end
112
99
 
@@ -116,9 +103,9 @@ module Spaceship
116
103
  end
117
104
 
118
105
  # @return (Spaceship::AppVersion) This will return the `edit_version` if available
119
- # and fallback to the `edit_version`. Use this to just access the latest data
106
+ # and fallback to the `live_version`. Use this to just access the latest data
120
107
  def latest_version
121
- edit_version || live_version || Spaceship::AppVersion.find(self, self.apple_id, false) # we want to get *any* version, prefered the latest one
108
+ edit_version || live_version
122
109
  end
123
110
 
124
111
  # @return (String) An URL to this specific resource. You can enter this URL into your browser
@@ -133,6 +120,14 @@ module Spaceship
133
120
  client.get_resolution_center(apple_id, platform)
134
121
  end
135
122
 
123
+ # kept for backward compatibility
124
+ # tries to guess the platform of the currently submitted apps
125
+ # note that as ITC now supports multiple app types, this might break
126
+ # if your app supports more than one
127
+ def platform
128
+ Spaceship::Tunes::AppVersionCommon.find_platform(raw_data['versionSets'])['platformString']
129
+ end
130
+
136
131
  def details
137
132
  attrs = client.app_details(apple_id)
138
133
  attrs.merge!(application: self)
@@ -1,6 +1,7 @@
1
1
  require 'spaceship/tunes/tunes_base'
2
2
  require 'spaceship/tunes/application'
3
3
  require 'spaceship/tunes/app_version'
4
+ require 'spaceship/tunes/app_version_common'
4
5
  require 'spaceship/tunes/app_submission'
5
6
  require 'spaceship/tunes/tunes_client'
6
7
  require 'spaceship/tunes/language_item'
@@ -324,24 +324,22 @@ module Spaceship
324
324
  r = request(:get, "ra/apps/#{app_id}/overview")
325
325
  platforms = parse_response(r, 'data')['platforms']
326
326
 
327
- # We only support platforms that exist ATM
328
- platform = platforms.find do |p|
329
- ['ios', 'osx', 'appletvos'].include? p['platformString']
330
- end
331
-
332
- raise "Could not find platform ios, osx or appletvos for app #{app_id}" unless platform
327
+ platform = Spaceship::Tunes::AppVersionCommon.find_platform(platforms)
328
+ return nil unless platform
333
329
 
334
- # If your app has versions for both iOS and tvOS we will default to returning the iOS version for now.
335
- # This is intentional as we need to do more work to support apps that have hybrid versions.
336
- if platforms.length > 1
337
- platform = platforms.detect { |p| p['platformString'] == "ios" }
338
- end
330
+ version_id = Spaceship::Tunes::AppVersionCommon.find_version_id(platform, is_live)
331
+ return nil unless version_id
339
332
 
340
- version = platform[(is_live ? 'deliverableVersion' : 'inFlightVersion')]
341
- return nil unless version
342
- version_id = version['id']
343
333
  version_platform = platform['platformString']
344
334
 
335
+ app_version_data(app_id, version_platform: version_platform, version_id: version_id)
336
+ end
337
+
338
+ def app_version_data(app_id, version_platform: nil, version_id:nil)
339
+ raise "app_id is required" unless app_id
340
+ raise "version_platform is required" unless version_platform
341
+ raise "version_id is required" unless version_id
342
+
345
343
  r = request(:get, "ra/apps/#{app_id}/platforms/#{version_platform}/versions/#{version_id}")
346
344
  parse_response(r, 'data')
347
345
  end
@@ -1,3 +1,3 @@
1
1
  module Spaceship
2
- VERSION = "0.21.0"
2
+ VERSION = "0.21.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spaceship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-20 00:00:00.000000000 Z
12
+ date: 2016-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: credentials_manager
@@ -291,6 +291,7 @@ files:
291
291
  - lib/spaceship/tunes/app_submission.rb
292
292
  - lib/spaceship/tunes/app_trailer.rb
293
293
  - lib/spaceship/tunes/app_version.rb
294
+ - lib/spaceship/tunes/app_version_common.rb
294
295
  - lib/spaceship/tunes/app_version_ref.rb
295
296
  - lib/spaceship/tunes/application.rb
296
297
  - lib/spaceship/tunes/build.rb
@@ -328,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
329
  version: '0'
329
330
  requirements: []
330
331
  rubyforge_project:
331
- rubygems_version: 2.4.0
332
+ rubygems_version: 2.2.2
332
333
  signing_key:
333
334
  specification_version: 4
334
335
  summary: Because you would rather spend your time building stuff than fighting provisioning