Class: Pilot::TesterManager
Instance Attribute Summary
Attributes inherited from Manager
#config
Instance Method Summary
collapse
Methods inherited from Manager
#app, #fetch_app_id, #fetch_app_identifier, #login, #start
Instance Method Details
#add_tester(options) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/pilot/tester_manager.rb', line 7
def add_tester(options)
start(options)
begin
tester = Spaceship::Tunes::Tester::Internal.find(config[:email])
tester ||= Spaceship::Tunes::Tester::External.find(config[:email])
if tester
UI.success("Existing tester #{tester.email}")
else
tester = Spaceship::Tunes::Tester::External.create!(email: config[:email],
first_name: config[:first_name],
last_name: config[:last_name])
UI.success("Successfully invited tester: #{tester.email}")
end
app_filter = (config[:apple_id] || config[:app_identifier])
if app_filter
begin
app = Spaceship::Application.find(app_filter)
UI.user_error!("Couldn't find app with '#{app_filter}'") unless app
tester.add_to_app!(app.apple_id)
UI.success("Successfully added tester to app #{app_filter}")
rescue => ex
UI.error("Could not add #{tester.email} to app: #{ex}")
raise ex
end
end
rescue => ex
UI.error("Could not create tester #{config[:email]}")
raise ex
end
end
|
#describe_tester(tester) ⇒ Object
Print out all the details of a specific tester
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/pilot/tester_manager.rb', line 151
def describe_tester(tester)
return unless tester
rows = []
rows << ["First name", tester.first_name]
rows << ["Last name", tester.last_name]
rows << ["Email", tester.email]
groups = tester.raw_data.get("groups")
if groups && groups.length > 0
group_names = groups.map { |group| group["name"]["value"] }
rows << ["Groups", group_names.join(', ')]
end
if tester.latest_install_date
rows << ["Latest Version", tester.full_version]
rows << ["Latest Install Date", tester.pretty_install_date]
end
if tester.devices.length == 0
rows << ["Devices", "No devices"]
else
rows << ["#{tester.devices.count} Devices", ""]
tester.devices.each do |device|
current = "\u2022 #{device['model']}, iOS #{device['osVersion']}"
if rows.last[1].length == 0
rows.last[1] = current
else
rows << ["", current]
end
end
end
puts Terminal::Table.new(
title: tester.email.green,
rows: rows
)
end
|
#find_tester(options) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/pilot/tester_manager.rb', line 41
def find_tester(options)
start(options)
tester = Spaceship::Tunes::Tester::Internal.find(config[:email])
tester ||= Spaceship::Tunes::Tester::External.find(config[:email])
UI.user_error!("Tester #{config[:email]} not found") unless tester
describe_tester(tester)
return tester
end
|
#list(all_testers, title, headings) ⇒ Object
Requires a block that accepts a tester and returns an array of tester column values
142
143
144
145
146
147
148
|
# File 'lib/pilot/tester_manager.rb', line 142
def list(all_testers, title, headings)
puts Terminal::Table.new(
title: title.green,
headings: headings,
rows: all_testers.map { |tester| yield tester }
)
end
|
#list_by_app(all_testers, title) ⇒ Object
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/pilot/tester_manager.rb', line 128
def list_by_app(all_testers, title)
= ["First", "Last", "Email"]
list(all_testers, title, ) do |tester|
[
tester.first_name,
tester.last_name,
tester.email
]
end
end
|
#list_global(all_testers, title) ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/pilot/tester_manager.rb', line 114
def list_global(all_testers, title)
= ["First", "Last", "Email", "Devices", "Latest Version", "Latest Install Date"]
list(all_testers, title, ) do |tester|
[
tester.first_name,
tester.last_name,
tester.email,
tester.devices.count,
tester.full_version,
tester.pretty_install_date
]
end
end
|
#list_testers(options) ⇒ Object
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/pilot/tester_manager.rb', line 80
def list_testers(options)
start(options)
app_filter = (config[:apple_id] || config[:app_identifier])
if app_filter
list_testers_by_app(app_filter)
else
list_testers_global
end
end
|
#list_testers_by_app(app_filter) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/pilot/tester_manager.rb', line 93
def list_testers_by_app(app_filter)
app = Spaceship::Application.find(app_filter)
UI.user_error!("Couldn't find app with '#{app_filter}'") unless app
int_testers = Spaceship::Tunes::Tester::Internal.all_by_app(app.apple_id)
ext_testers = Spaceship::Tunes::Tester::External.all_by_app(app.apple_id)
list_by_app(int_testers, "Internal Testers")
puts ""
list_by_app(ext_testers, "External Testers")
end
|
#list_testers_global ⇒ Object
105
106
107
108
109
110
111
112
|
# File 'lib/pilot/tester_manager.rb', line 105
def list_testers_global
int_testers = Spaceship::Tunes::Tester::Internal.all
ext_testers = Spaceship::Tunes::Tester::External.all
list_global(int_testers, "Internal Testers")
puts ""
list_global(ext_testers, "External Testers")
end
|
#remove_tester(options) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/pilot/tester_manager.rb', line 53
def remove_tester(options)
start(options)
tester = Spaceship::Tunes::Tester::External.find(config[:email])
tester ||= Spaceship::Tunes::Tester::Internal.find(config[:email])
if tester
app_filter = (config[:apple_id] || config[:app_identifier])
if app_filter
begin
app = Spaceship::Application.find(app_filter)
UI.user_error!("Couldn't find app with '#{app_filter}'") unless app
tester.remove_from_app!(app.apple_id)
UI.success("Successfully removed tester #{tester.email} from app #{app_filter}")
rescue => ex
UI.error("Could not remove #{tester.email} from app: #{ex}")
raise ex
end
else
tester.delete!
UI.success("Successfully removed tester #{tester.email}")
end
else
UI.error("Tester not found: #{config[:email]}")
end
end
|