Class: Pindo::Command::Utils::Device
- Inherits:
-
Pindo::Command::Utils
- Object
- Pindo::Command
- Pindo::Command::Utils
- Pindo::Command::Utils::Device
- Defined in:
- lib/pindo/command/utils/device.rb
Defined Under Namespace
Classes: DeviceItem
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_device ⇒ Object
-
#initialize(argv) ⇒ Device
constructor
A new instance of Device.
- #login ⇒ Object
- #read_apppgyer_csv ⇒ Object
- #read_user_csv ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
- #write_apppgyer_csv(devices: nil) ⇒ Object
- #write_appstore_text(devices: nil) ⇒ Object
- #write_user_csv(devices: nil) ⇒ Object
Constructor Details
#initialize(argv) ⇒ 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. [ ].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 # devices = Spaceship::Portal.device.all(include_disabled: true).select do |device| # device.enabled? # end # mac_disabled_devices = Spaceship::Portal.device.all(mac: true, include_disabled: true).select do |device| # device.enabled? # end # my_total_devices = {} # devices.each do |item| # device_item = DeviceItem.new # device_item.name = item.name # device_item.name = device_item.name.downcase # device_item.udid = item.udid # device_item.platform = item.platform # device_item.device_model = item.model # device_item.device_type = item.device_type # device_item.device_description = "" # my_total_devices[item.udid] = device_item # end # mac_disabled_devices.each do |item| # # puts item # device_item = DeviceItem.new # device_item.name = item.name # device_item.name = device_item.name.downcase # device_item.udid = item.udid # device_item.platform = item.platform # device_item.device_model = item.model # device_item.device_type = item.device_type # device_item.device_description = "" # my_total_devices[item.udid] = device_item # end # use_devices = read_user_csv() # use_devices.each do |key, item| # if !my_total_devices[key].nil? # if !item.device_description.nil? # my_total_devices[key].device_description = item.device_description # end # if my_total_devices[key].device_description.nil? || my_total_devices[key].device_description.eql?("") # my_total_devices[key].device_description = item.name.to_s.downcase # end # if my_total_devices[key].device_model.nil? || my_total_devices[key].device_model.eql?("") # my_total_devices[key].device_model = item.device_model # end # if my_total_devices[key].device_model.nil? || my_total_devices[key].device_model.eql?("") # my_total_devices[key].device_model = item.name.to_s.downcase # end # end # end # pgyer_devices = read_apppgyer_csv() # pgyer_devices.each do |key, item| # if !my_total_devices[key].nil? # if !item.device_description.nil? # my_total_devices[key].device_description = item.device_description # end # end # end 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 # Spaceship::Portal.login(pindo_single_config.demo_apple_id) # Spaceship::Portal.select_team 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, "pgyer_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_pgyer_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 |