Class: Spaceship::TestFlight::Build

Inherits:
Base
  • Object
show all
Defined in:
spaceship/lib/spaceship/test_flight/build.rb

Constant Summary collapse

BUILD_STATES =
{
  processing: 'testflight.build.state.processing',
  active: 'testflight.build.state.testing.active',
  ready_to_submit: 'testflight.build.state.submit.ready',
  ready_to_test: 'testflight.build.state.testing.ready',
  export_compliance_missing: 'testflight.build.state.export.compliance.missing',
  review_rejected: 'testflight.build.state.review.rejected',
  approved: 'testflight.build.state.review.approved'
}

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, inherited, #to_json

Methods inherited from Base

attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s

Constructor Details

This class inherits a constructor from Spaceship::Base

Instance Attribute Details

#auto_notify_enabledObject

Returns the value of attribute auto_notify_enabled.



53
54
55
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 53

def auto_notify_enabled
  @auto_notify_enabled
end

#beta_review_infoSpaceship::TestFlight::BetaReviewInfo

Getting builds from BuildTrains only gets a partial Build object We are then requesting the full build from iTC when we need to access any of the variables below, because they are not included in the partial Build objects

‘super` here calls `beta_review_info` as defined by the `attr_mapping` above.



182
183
184
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 182

def beta_review_info
  @beta_review_info
end

#build_sdkObject

Returns the value of attribute build_sdk.



59
60
61
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 59

def build_sdk
  @build_sdk
end

#build_versionObject

Examples:

"152"


41
42
43
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 41

def build_version
  @build_version
end

#bundle_idObject

Examples:

"com.sample.app"


16
17
18
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 16

def bundle_id
  @bundle_id
end

#contains_odrObject

Returns the value of attribute contains_odr.



62
63
64
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 62

def contains_odr
  @contains_odr
end

#crash_countObject

Returns the value of attribute crash_count.



51
52
53
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 51

def crash_count
  @crash_count
end

#did_notifyObject

Returns the value of attribute did_notify.



54
55
56
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 54

def did_notify
  @did_notify
end

#dsym_urlObject

Returns the value of attribute dsym_url.



58
59
60
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 58

def dsym_url
  @dsym_url
end

#export_complianceSpaceship::TestFlight::ExportCompliance



188
189
190
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 188

def export_compliance
  @export_compliance
end

#external_stateObject

Examples:

"testflight.build.state.submit.ready"
"testflight.build.state.processing"


28
29
30
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 28

def external_state
  @external_state
end

#file_nameObject

Returns the value of attribute file_name.



63
64
65
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 63

def file_name
  @file_name
end

#idObject

Internal build ID (int)

Examples:

19285309


33
34
35
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 33

def id
  @id
end

#include_symbolsObject

Returns the value of attribute include_symbols.



60
61
62
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 60

def include_symbols
  @include_symbols
end

#install_countObject

Returns the value of attribute install_count.



49
50
51
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 49

def install_count
  @install_count
end

#internal_stateObject

Examples:

"testflight.build.state.testing.active"
"testflight.build.state.processing"


22
23
24
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 22

def internal_state
  @internal_state
end

#invite_countObject

Returns the value of attribute invite_count.



50
51
52
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 50

def invite_count
  @invite_count
end

#number_of_asset_packsObject

Returns the value of attribute number_of_asset_packs.



61
62
63
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 61

def number_of_asset_packs
  @number_of_asset_packs
end

#test_infoSpaceship::TestFlight::TestInfo



194
195
196
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 194

def test_info
  @test_info
end

#train_versionObject

Examples:

"1.0"


37
38
39
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 37

def train_version
  @train_version
end

#upload_dateTime

Returns an parsed Time value for the upload_date.

Returns:

  • (Time)

    an parsed Time value for the upload_date



200
201
202
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 200

def upload_date
  @upload_date
end

Class Method Details

.all(app_id: nil, platform: nil, retry_count: 0) ⇒ Object



109
110
111
112
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 109

def self.all(app_id: nil, platform: nil, retry_count: 0)
  trains = BuildTrains.all(app_id: app_id, platform: platform, retry_count: retry_count)
  trains.values.flatten
end

.all_processing_builds(app_id: nil, platform: nil, retry_count: 0) ⇒ Object

Just the builds, as a flat array, that are still processing



120
121
122
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 120

def self.all_processing_builds(app_id: nil, platform: nil, retry_count: 0)
  all(app_id: app_id, platform: platform, retry_count: retry_count).find_all(&:processing?)
end

.all_waiting_for_review(app_id: nil, platform: nil, retry_count: 0) ⇒ Object

Just the builds, as a flat array, that are waiting for beta review



125
126
127
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 125

def self.all_waiting_for_review(app_id: nil, platform: nil, retry_count: 0)
  all(app_id: app_id, platform: platform, retry_count: retry_count).select { |app| app.external_state == 'testflight.build.state.review.waiting' }
end

.builds_for_train(app_id: nil, platform: nil, train_version: nil, retry_count: 3) ⇒ Object



114
115
116
117
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 114

def self.builds_for_train(app_id: nil, platform: nil, train_version: nil, retry_count: 3)
  builds_data = client.get_builds_for_train(app_id: app_id, platform: platform, train_version: train_version, retry_count: retry_count)
  builds_data.map { |data| self.new(data) }
end

.find(app_id: nil, build_id: nil) ⇒ Spaceship::TestFlight::Build

Find a Build by ‘build_id`.



104
105
106
107
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 104

def self.find(app_id: nil, build_id: nil)
  attrs = client.get_build(app_id: app_id, build_id: build_id)
  self.new(attrs)
end

.latest(app_id: nil, platform: nil) ⇒ Object



129
130
131
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 129

def self.latest(app_id: nil, platform: nil)
  all(app_id: app_id, platform: platform).sort_by(&:upload_date).last
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


152
153
154
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 152

def active?
  external_state == BUILD_STATES[:active]
end

#add_group!(group) ⇒ Object



227
228
229
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 227

def add_group!(group)
  client.add_group_to_build(app_id: app_id, group_id: group.id, build_id: id)
end

#approved?Boolean

Returns:

  • (Boolean)


168
169
170
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 168

def approved?
  external_state == BUILD_STATES[:approved]
end

#expire!Object



223
224
225
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 223

def expire!
  client.expire_build(app_id: app_id, build_id: id, build: self)
end

#export_compliance_missing?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 160

def export_compliance_missing?
  external_state == BUILD_STATES[:export_compliance_missing]
end

#find_app_store_connect_buildObject

Bridges the TestFlight::Build to the App Store Connect API build



232
233
234
235
236
237
238
239
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 232

def find_app_store_connect_build
  builds = Spaceship::ConnectAPI::Build.all(
    app_id: app_id,
    version: self.train_version,
    build_number: self.build_version
  )
  return builds.find { |build| build.id == id }
end

#processed?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 172

def processed?
  active? || ready_to_submit? || export_compliance_missing? || review_rejected?
end

#processing?Boolean

Returns:

  • (Boolean)


156
157
158
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 156

def processing?
  external_state == BUILD_STATES[:processing]
end

#ready_to_submit?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 144

def ready_to_submit?
  external_state == BUILD_STATES[:ready_to_submit]
end

#ready_to_test?Boolean

Returns:

  • (Boolean)


148
149
150
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 148

def ready_to_test?
  external_state == BUILD_STATES[:ready_to_test]
end

#reloadSpaceship::Base::DataHash

reload the raw_data resource for this build. This is useful when we start with a partial build response as returned by the BuildTrains, but then need to look up some attributes on the full build representation.

Note: this will overwrite any non-saved changes to the object

Returns:



140
141
142
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 140

def reload
  self.raw_data = self.class.find(app_id: app_id, build_id: id).raw_data
end

#review_rejected?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 164

def review_rejected?
  external_state == BUILD_STATES[:review_rejected]
end

#save!Object

saves the changes to the Build object to TestFlight



205
206
207
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 205

def save!
  client.put_build(app_id: app_id, build_id: id, build: self)
end

#submit_for_testflight_review!Object



216
217
218
219
220
221
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 216

def submit_for_testflight_review!
  return if ready_to_test?
  return if approved?

  Spaceship::ConnectAPI.post_beta_app_review_submissions(build_id: id)
end

#update_build_information!(description: nil, feedback_email: nil, whats_new: nil) ⇒ Object



209
210
211
212
213
214
# File 'spaceship/lib/spaceship/test_flight/build.rb', line 209

def update_build_information!(description: nil, feedback_email: nil, whats_new: nil)
  test_info.description = description if description
  test_info.feedback_email = feedback_email if feedback_email
  test_info.whats_new = whats_new if whats_new
  save!
end