Class: Pindo::Command::Utils::Device
Defined Under Namespace
Classes: DeviceItem
Constant Summary
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
#args_help_flag
Class Method Summary
collapse
Instance Method Summary
collapse
run, use_cache?
#pindo_log_instance
#pindo_single_config
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #git_root_directory, #is_git_directory?, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, which, which!
Constructor Details
#initialize(argv) ⇒ Device
Returns a new instance of Device.
58
59
60
61
62
|
# File 'lib/pindo/command/utils/device.rb', line 58
def initialize(argv)
super(argv)
@additional_args = argv.remainder!
end
|
Class Method Details
.options ⇒ Object
52
53
54
55
56
|
# File 'lib/pindo/command/utils/device.rb', line 52
def self.options
[
].concat(super)
end
|
Instance Method Details
#fetch_device ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/pindo/command/utils/device.rb', line 82
def fetch_device
my_total_devices = read_user_csv()
JSON.pretty_generate(my_total_devices)
write_appstore_text(devices:my_total_devices)
write_user_csv(devices:my_total_devices)
write_apppgyer_csv(devices:my_total_devices)
end
|
#login ⇒ Object
77
78
79
80
|
# File 'lib/pindo/command/utils/device.rb', line 77
def login
end
|
#read_apppgyer_csv ⇒ Object
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
# File 'lib/pindo/command/utils/device.rb', line 229
def read_apppgyer_csv()
devices = {}
device_file = File.join(Dir.pwd, "jps_devices_list.csv");
if File.exist?(device_file)
line_num=0
CSV.foreach(device_file, headers:false) do |row|
if line_num > 0
device_item = DeviceItem.new
device_item.device_model = row[0]
device_item.udid = row[1]
device_item.device_type = row[2]
device_item.name = row[3]
device_item.device_description = row[4]
devices[device_item.udid] = device_item
end
line_num += 1
end
end
return devices
end
|
#read_user_csv ⇒ Object
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
# File 'lib/pindo/command/utils/device.rb', line 270
def read_user_csv()
devices = {}
device_file = File.join(Dir.pwd, "user_devices_list.csv");
if File.exist?(device_file)
puts 1111
line_num=0
CSV.foreach(device_file, headers:false) do |row|
if line_num > 0
device_item = DeviceItem.new
device_item.name = row[0]
device_item.udid = row[1]
device_item.device_type = row[2]
device_item.device_model = row[3]
device_item.device_description = row[4]
devices[device_item.udid] = device_item
end
line_num += 1
end
end
puts devices
return devices
end
|
#run ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/pindo/command/utils/device.rb', line 68
def run
login
fetch_device
end
|
#validate! ⇒ Object
64
65
66
|
# File 'lib/pindo/command/utils/device.rb', line 64
def validate!
super
end
|
#write_apppgyer_csv(devices: nil) ⇒ Object
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/pindo/command/utils/device.rb', line 200
def write_apppgyer_csv(devices:nil)
device_file = File.join(Dir.pwd, "new_jps_devices_list.csv");
devices.each do |key, item|
if item.device_type.to_s.eql?("ipad")
item.device_type = "iPad"
elsif item.device_type.to_s.eql?("iphone")
item.device_type = "iPhone"
elsif item.device_type.to_s.eql?("watch")
item.device_type = "Apple Watch"
elsif item.device_type.to_s.eql?("appleSiliconMac")
item.device_type = "Mac"
elsif item.device_type.to_s.eql?("mac")
item.device_type = "Mac"
end
end
CSV.open(device_file, "wb") do |csv|
csv << ["型号", "udid", "设备类型", "设备名称", "备注", "udid来源", "添加时间"]
devices.each do |key, device|
csv << [device.device_model,device.udid,device.device_type,device.name ,device.device_description]
end
end
end
|
#write_appstore_text(devices: nil) ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/pindo/command/utils/device.rb', line 169
def write_appstore_text(devices:nil)
device_file = File.join(Dir.pwd, "new_devices_list.txt");
str_text = String.new
str_text = "DEVICE ID\tDEVICE NAME\tDEVICE PLATFORM\n"
devices.each do |key, device|
if device.platform.nil? || !(device.platform.to_s.eql?("ios") || device.platform.to_s.eql?("mac"))
if device.device_type.to_s.strip.downcase.eql?("mac")
device.platform = "mac"
else
device.platform = "ios"
end
end
str = String.new
str = str + device.udid
str = str + "\t"
str = str + device.name
str = str + "\t"
str = str + device.platform
str = str + "\n"
str_text = str_text + str
end
File.open(device_file, "w") do |f|
f.write(str_text)
end
end
|
#write_user_csv(devices: nil) ⇒ Object
257
258
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/pindo/command/utils/device.rb', line 257
def write_user_csv(devices:nil)
device_file = File.join(Dir.pwd, "new_user_devices_list.csv");
CSV.open(device_file, "wb") do |csv|
csv << ["设备名称", "udid", "设备类型", "型号", "备注"]
devices.each do |key, device|
csv << [device.name,device.udid,device.device_type,device.device_model ,device.device_description]
end
end
end
|