spaceship 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,23 +28,24 @@ module Spaceship
28
28
  end
29
29
 
30
30
  private
31
+
31
32
  # Path to the gem to fetch resoures
32
- def spaceship_gem_path
33
- if Gem::Specification::find_all_by_name('spaceship').any?
34
- return Gem::Specification.find_by_name('spaceship').gem_dir
35
- else
36
- return './'
37
- end
33
+ def spaceship_gem_path
34
+ if Gem::Specification::find_all_by_name('spaceship').any?
35
+ return Gem::Specification.find_by_name('spaceship').gem_dir
36
+ else
37
+ return './'
38
38
  end
39
+ end
39
40
 
40
41
  # Get the mapping JSON parsed
41
- def mapping
42
- @languages ||= JSON.parse(File.read(File.join(spaceship_gem_path, "lib", "assets", "languageMapping.json")))
43
- end
42
+ def mapping
43
+ @languages ||= JSON.parse(File.read(File.join(spaceship_gem_path, "lib", "assets", "languageMapping.json")))
44
+ end
44
45
 
45
- def readable_mapping
46
- @readable ||= JSON.parse(File.read(File.join(spaceship_gem_path, "lib", "assets", "languageMappingReadable.json")))
47
- end
46
+ def readable_mapping
47
+ @readable ||= JSON.parse(File.read(File.join(spaceship_gem_path, "lib", "assets", "languageMappingReadable.json")))
48
+ end
48
49
  end
49
50
  end
50
51
  end
@@ -58,4 +59,4 @@ class String
58
59
  def to_full_language
59
60
  Spaceship::Tunes::LanguageConverter.from_standard_to_itc(self)
60
61
  end
61
- end
62
+ end
@@ -51,4 +51,4 @@ module Spaceship
51
51
  end
52
52
  end
53
53
  end
54
- end
54
+ end
@@ -27,4 +27,4 @@ module Spaceship
27
27
  end
28
28
  end
29
29
  end
30
- end
30
+ end
@@ -8,19 +8,19 @@ module Spaceship
8
8
  # Authenticates with Apple's web services. This method has to be called once
9
9
  # to generate a valid session. The session will automatically be used from then
10
10
  # on.
11
- #
11
+ #
12
12
  # This method will automatically use the username from the Appfile (if available)
13
13
  # and fetch the password from the Keychain (if available)
14
- #
14
+ #
15
15
  # @param user (String) (optional): The username (usually the email address)
16
16
  # @param password (String) (optional): The password
17
- #
17
+ #
18
18
  # @raise InvalidUserCredentialsError: raised if authentication failed
19
- #
19
+ #
20
20
  # @return (Spaceship::Client) The client the login method was called for
21
21
  def login(user = nil, password = nil)
22
22
  @client = TunesClient.login(user, password)
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -3,22 +3,22 @@ module Spaceship
3
3
  class Tester < TunesBase
4
4
 
5
5
  # @return (String) The identifier of this tester, provided by iTunes Connect
6
- # @example
6
+ # @example
7
7
  # "60f858b4-60a8-428a-963a-f943a3d68d17"
8
8
  attr_accessor :tester_id
9
9
 
10
10
  # @return (String) The email of this tester
11
- # @example
11
+ # @example
12
12
  # "tester@spaceship.com"
13
13
  attr_accessor :email
14
-
14
+
15
15
  # @return (String) The first name of this tester
16
- # @example
16
+ # @example
17
17
  # "Cary"
18
18
  attr_accessor :first_name
19
19
 
20
20
  # @return (String) The last name of this tester
21
- # @example
21
+ # @example
22
22
  # "Bennett"
23
23
  attr_accessor :last_name
24
24
 
@@ -32,7 +32,6 @@ module Spaceship
32
32
  # }]
33
33
  attr_accessor :devices
34
34
 
35
-
36
35
  # Information about the most recent beta install
37
36
  # @return [Integer] The ID of the most recently installed app
38
37
  attr_accessor :latest_install_app_id
@@ -56,7 +55,7 @@ module Spaceship
56
55
  'latestInstalledAppAdamId' => :latest_install_app_id,
57
56
  'latestInstalledDate' => :latest_install_date,
58
57
  'latestInstalledVersion' => :latest_installed_version_number,
59
- 'latestInstalledShortVersion' => :latest_installed_build_number,
58
+ 'latestInstalledShortVersion' => :latest_installed_build_number
60
59
  )
61
60
 
62
61
  class << self
@@ -90,10 +89,10 @@ module Spaceship
90
89
  # @param email (String) (required): The email of the new tester
91
90
  # @param first_name (String) (optional): The first name of the new tester
92
91
  # @param last_name (String) (optional): The last name of the new tester
93
- # @example
92
+ # @example
94
93
  # Spaceship::Tunes::Tester.external.create!(email: "tester@mathiascarignani.com", first_name: "Cary", last_name:"Bennett")
95
94
  # @return (Tester): The newly created tester
96
- def create!(email: nil, first_name: nil, last_name: nil)
95
+ def create!(email: nil, first_name: nil, last_name: nil)
97
96
  data = client.create_tester!(tester: self,
98
97
  email: email,
99
98
  first_name: first_name,
@@ -107,7 +106,7 @@ module Spaceship
107
106
 
108
107
  # @return (Array) Returns all beta testers available for this account filtered by app
109
108
  # @param app_id (String) (required): The app id to filter the testers
110
- def all_by_app(app_id)
109
+ def all_by_app(app_id)
111
110
  client.testers_by_app(self, app_id).map { |tester| self.factory(tester) }
112
111
  end
113
112
 
@@ -128,7 +127,7 @@ module Spaceship
128
127
  begin
129
128
  tester.add_to_app!(app_id)
130
129
  rescue => ex
131
- if ex.to_s.include?"testerEmailExistsInternal" or ex.to_s.include?"duplicate.email"
130
+ if ex.to_s.include? "testerEmailExistsInternal" or ex.to_s.include? "duplicate.email"
132
131
  # That's a non-relevant error message by iTC
133
132
  # ignore that
134
133
  else
@@ -146,7 +145,7 @@ module Spaceship
146
145
  #####################################################
147
146
  # @!group Subclasses
148
147
  #####################################################
149
- class External < Tester
148
+ class External < Tester
150
149
  def self.url(app_id = nil)
151
150
  {
152
151
  index: "ra/users/pre/ext",
@@ -158,7 +157,7 @@ module Spaceship
158
157
  end
159
158
  end
160
159
 
161
- class Internal < Tester
160
+ class Internal < Tester
162
161
  def self.url(app_id = nil)
163
162
  {
164
163
  index: "ra/users/pre/int",
@@ -171,7 +170,7 @@ module Spaceship
171
170
  end
172
171
 
173
172
  # Delete current tester
174
- def delete!
173
+ def delete!
175
174
  client.delete_tester!(self)
176
175
  end
177
176
 
@@ -192,4 +191,4 @@ module Spaceship
192
191
  end
193
192
  end
194
193
  end
195
- end
194
+ end
@@ -17,7 +17,7 @@ module Spaceship
17
17
  def login_url
18
18
  cache_path = "/tmp/spaceship_itc_login_url.txt"
19
19
  begin
20
- cached = File.read(cache_path)
20
+ cached = File.read(cache_path)
21
21
  rescue Errno::ENOENT
22
22
  end
23
23
  return cached if cached
@@ -61,7 +61,7 @@ module Spaceship
61
61
  # User Credentials are wrong
62
62
  raise InvalidUserCredentialsError.new(response)
63
63
  end
64
-
64
+
65
65
  return @client
66
66
  else
67
67
  # User Credentials are wrong
@@ -71,30 +71,30 @@ module Spaceship
71
71
 
72
72
  def handle_itc_response(raw)
73
73
  return unless raw
74
- return unless raw.kind_of?Hash
74
+ return unless raw.kind_of? Hash
75
75
 
76
76
  data = raw['data'] || raw # sometimes it's with data, sometimes it isn't
77
-
77
+
78
78
  if data.fetch('sectionErrorKeys', []).count == 0 and
79
- data.fetch('sectionInfoKeys', []).count == 0 and
79
+ data.fetch('sectionInfoKeys', []).count == 0 and
80
80
  data.fetch('sectionWarningKeys', []).count == 0
81
-
81
+
82
82
  logger.debug("Request was successful")
83
83
  end
84
84
 
85
- def handle_response_hash(hash)
85
+ handle_response_hash = lambda do |hash|
86
86
  errors = []
87
- if hash.kind_of?Hash
87
+ if hash.kind_of? Hash
88
88
  hash.each do |key, value|
89
- errors = errors + handle_response_hash(value)
89
+ errors = errors + handle_response_hash.call(value)
90
90
 
91
- if key == 'errorKeys' and value.kind_of?Array and value.count > 0
91
+ if key == 'errorKeys' and value.kind_of? Array and value.count > 0
92
92
  errors = errors + value
93
93
  end
94
94
  end
95
- elsif hash.kind_of?Array
95
+ elsif hash.kind_of? Array
96
96
  hash.each do |value|
97
- errors = errors + handle_response_hash(value)
97
+ errors = errors + handle_response_hash.call(value)
98
98
  end
99
99
  else
100
100
  # We don't care about simple values
@@ -102,7 +102,7 @@ module Spaceship
102
102
  return errors
103
103
  end
104
104
 
105
- errors = handle_response_hash(data)
105
+ errors = handle_response_hash.call(data)
106
106
  errors = errors + data.fetch('sectionErrorKeys') if data['sectionErrorKeys']
107
107
 
108
108
  # Sometimes there is a different kind of error in the JSON response
@@ -120,7 +120,6 @@ module Spaceship
120
120
  return data
121
121
  end
122
122
 
123
-
124
123
  #####################################################
125
124
  # @!group Applications
126
125
  #####################################################
@@ -131,14 +130,14 @@ module Spaceship
131
130
  end
132
131
 
133
132
  # Creates a new application on iTunes Connect
134
- # @param name (String): The name of your app as it will appear on the App Store.
133
+ # @param name (String): The name of your app as it will appear on the App Store.
135
134
  # This can't be longer than 255 characters.
136
- # @param primary_language (String): If localized app information isn't available in an
135
+ # @param primary_language (String): If localized app information isn't available in an
137
136
  # App Store territory, the information from your primary language will be used instead.
138
- # @param version (String): The version number is shown on the App Store and should
137
+ # @param version (String): The version number is shown on the App Store and should
139
138
  # match the one you used in Xcode.
140
139
  # @param sku (String): A unique ID for your app that is not visible on the App Store.
141
- # @param bundle_id (String): The bundle ID must match the one you used in Xcode. It
140
+ # @param bundle_id (String): The bundle ID must match the one you used in Xcode. It
142
141
  # can't be changed after you submit your first build.
143
142
  def create_application!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil)
144
143
  # First, we need to fetch the data from Apple, which we then modify with the user's values
@@ -160,7 +159,7 @@ module Spaceship
160
159
  req.body = data.to_json
161
160
  req.headers['Content-Type'] = 'application/json'
162
161
  end
163
-
162
+
164
163
  data = parse_response(r, 'data')
165
164
  handle_itc_response(data)
166
165
  end
@@ -203,7 +202,7 @@ module Spaceship
203
202
  req.body = data.to_json
204
203
  req.headers['Content-Type'] = 'application/json'
205
204
  end
206
-
205
+
207
206
  handle_itc_response(r.body)
208
207
  end
209
208
 
@@ -239,10 +238,10 @@ module Spaceship
239
238
  handle_itc_response(r.body)
240
239
  end
241
240
 
242
- def submit_testflight_build_for_review!(# Required:
243
- app_id: nil,
244
- train: nil,
245
- build_number: nil,
241
+ def submit_testflight_build_for_review!( # Required:
242
+ app_id: nil,
243
+ train: nil,
244
+ build_number: nil,
246
245
  cancel_other_submissions: false,
247
246
 
248
247
  # Required Metadata:
@@ -271,7 +270,7 @@ module Spaceship
271
270
 
272
271
  build_info = r.body['data']
273
272
  # Now fill in the values provided by the user
274
-
273
+
275
274
  # First the localised values:
276
275
  build_info['testInfo']['details'].each do |current|
277
276
  current['whatsNew']['value'] = changelog
@@ -310,11 +309,11 @@ module Spaceship
310
309
  handle_itc_response(r.body)
311
310
  end
312
311
  end
313
-
312
+
314
313
  #####################################################
315
314
  # @!group Submit for Review
316
315
  #####################################################
317
-
316
+
318
317
  def send_app_submission(app_id, data, stage)
319
318
  raise "app_id is required" unless app_id
320
319
 
@@ -323,7 +322,7 @@ module Spaceship
323
322
  req.body = data.to_json
324
323
  req.headers['Content-Type'] = 'application/json'
325
324
  end
326
-
325
+
327
326
  handle_itc_response(r.body)
328
327
  parse_response(r, 'data')
329
328
  end
@@ -337,20 +336,20 @@ module Spaceship
337
336
  parse_response(r, 'data')['testers']
338
337
  end
339
338
 
340
- def testers_by_app(tester, app_id)
339
+ def testers_by_app(tester, app_id)
341
340
  url = tester.url(app_id)[:index_by_app]
342
341
  r = request(:get, url)
343
342
  parse_response(r, 'data')['users']
344
343
  end
345
344
 
346
- def create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil)
345
+ def create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil)
347
346
  url = tester.url[:create]
348
347
  raise "Action not provided for this tester type." unless url
349
348
 
350
349
  tester_data = {
351
350
  emailAddress: {
352
351
  value: email
353
- },
352
+ },
354
353
  firstName: {
355
354
  value: first_name
356
355
  },
@@ -382,7 +381,7 @@ module Spaceship
382
381
  {
383
382
  emailAddress: {
384
383
  value: tester.email
385
- },
384
+ },
386
385
  firstName: {
387
386
  value: tester.first_name
388
387
  },
@@ -415,36 +414,37 @@ module Spaceship
415
414
  update_tester_from_app!(tester, app_id, false)
416
415
  end
417
416
 
418
- private
419
- def update_tester_from_app!(tester, app_id, testing)
420
- url = tester.class.url(app_id)[:update_by_app]
421
- data = {
422
- users: [
423
- {
424
- emailAddress: {
425
- value: tester.email
426
- },
427
- firstName: {
428
- value: tester.first_name
429
- },
430
- lastName: {
431
- value: tester.last_name
432
- },
433
- testing: {
434
- value: testing
435
- }
417
+ private
418
+
419
+ def update_tester_from_app!(tester, app_id, testing)
420
+ url = tester.class.url(app_id)[:update_by_app]
421
+ data = {
422
+ users: [
423
+ {
424
+ emailAddress: {
425
+ value: tester.email
426
+ },
427
+ firstName: {
428
+ value: tester.first_name
429
+ },
430
+ lastName: {
431
+ value: tester.last_name
432
+ },
433
+ testing: {
434
+ value: testing
436
435
  }
437
- ]
438
- }
436
+ }
437
+ ]
438
+ }
439
439
 
440
- r = request(:post) do |req|
441
- req.url url
442
- req.body = data.to_json
443
- req.headers['Content-Type'] = 'application/json'
444
- end
445
-
446
- data = parse_response(r, 'data')
447
- handle_itc_response(data)
440
+ r = request(:post) do |req|
441
+ req.url url
442
+ req.body = data.to_json
443
+ req.headers['Content-Type'] = 'application/json'
448
444
  end
445
+
446
+ data = parse_response(r, 'data')
447
+ handle_itc_response(data)
448
+ end
449
449
  end
450
- end
450
+ end
data/lib/spaceship/ui.rb CHANGED
@@ -4,7 +4,6 @@ paths.each do |file|
4
4
  require file
5
5
  end
6
6
 
7
-
8
7
  module Spaceship
9
8
  class Client
10
9
  # Public getter for all UI related code
@@ -25,4 +24,4 @@ module Spaceship
25
24
  end
26
25
  end
27
26
  end
28
- end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Spaceship
2
- VERSION = "0.3.2"
3
- end
2
+ VERSION = "0.4.0"
3
+ end
data/lib/spaceship.rb CHANGED
@@ -19,10 +19,11 @@ module Spaceship
19
19
  ProvisioningProfile = Spaceship::Portal::ProvisioningProfile
20
20
  Device = Spaceship::Portal::Device
21
21
  App = Spaceship::Portal::App
22
+ AppGroup = Spaceship::Portal::AppGroup
23
+ AppService = Spaceship::Portal::AppService
22
24
 
23
25
  # iTunes Connect
24
26
  AppVersion = Spaceship::Tunes::AppVersion
25
27
  AppSubmission = Spaceship::Tunes::AppSubmission
26
28
  Application = Spaceship::Tunes::Application
27
29
  end
28
-
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.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Natchev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-24 00:00:00.000000000 Z
12
+ date: 2015-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: credentials_manager
@@ -193,6 +193,20 @@ dependencies:
193
193
  - - ">="
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: rubocop
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - "~>"
201
+ - !ruby/object:Gem::Version
202
+ version: 0.32.1
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: 0.32.1
196
210
  description: Because you would rather spend your time building stuff than fighting
197
211
  provisioning
198
212
  email:
@@ -213,6 +227,8 @@ files:
213
227
  - lib/spaceship/helper/plist_middleware.rb
214
228
  - lib/spaceship/launcher.rb
215
229
  - lib/spaceship/portal/app.rb
230
+ - lib/spaceship/portal/app_group.rb
231
+ - lib/spaceship/portal/app_service.rb
216
232
  - lib/spaceship/portal/certificate.rb
217
233
  - lib/spaceship/portal/device.rb
218
234
  - lib/spaceship/portal/portal.rb
@@ -258,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
274
  version: '0'
259
275
  requirements: []
260
276
  rubyforge_project:
261
- rubygems_version: 2.4.6
277
+ rubygems_version: 2.4.8
262
278
  signing_key:
263
279
  specification_version: 4
264
280
  summary: Because you would rather spend your time building stuff than fighting provisioning