idevices 0.0.1
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.
- checksums.yaml +7 -0
- data/lib/idevices.rb +72 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dc870ec91735dc49c29878f454f7a9d9f2cc0952
|
4
|
+
data.tar.gz: 5de8383c5318dc6c4026cce1ddfad9cf815dc2dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 756d53df375f8fe20a2ac92cbe85691fdb23e058f887a492a8a117e3dbb502790df31935a9296b87a336c59b7599e366d9d9063c13fb4ed8141fb6b5a37b6692
|
7
|
+
data.tar.gz: b8e6f3b145bd7e968e5242e99436e9fb87fa2115456e49924a2ffde5797ed4a6d8291189845b57aa93a9694f77fe04255793677ec82c2d0c51dc479a31128f0d
|
data/lib/idevices.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Idevices
|
2
|
+
extend self
|
3
|
+
|
4
|
+
def available_real_devices
|
5
|
+
real_devices_list = Hash.new
|
6
|
+
|
7
|
+
real_device_id_list=`idevice_id -l`
|
8
|
+
|
9
|
+
real_device_id_list.split("\n").uniq.each do |d|
|
10
|
+
device = device_info(d)
|
11
|
+
real_devices_list.merge!(device)
|
12
|
+
end
|
13
|
+
real_devices_list
|
14
|
+
end
|
15
|
+
|
16
|
+
def available_simulators
|
17
|
+
simulators_list = Hash.new
|
18
|
+
|
19
|
+
simulator_list_raw=`instruments -s devices`
|
20
|
+
|
21
|
+
simulator_list_raw.split("\n").each do |s|
|
22
|
+
if s[0..1] == 'iP'
|
23
|
+
parsed_s = /(iP.*?)\s\(([0-9]+\.[0-9])\)\s\[(.*?)\]\s\((.*)\)/.match(s)
|
24
|
+
device_name = parsed_s[1]
|
25
|
+
os_version = parsed_s[2]
|
26
|
+
device_id = parsed_s[3]
|
27
|
+
product_type = parsed_s[4]
|
28
|
+
if parsed_s[1].size >= 20 # Name is too long
|
29
|
+
os_version = /\((.*)\)/.match(parsed_s[1])[1]
|
30
|
+
end
|
31
|
+
simulators_list.merge!(device_name => { device_id: device_id,
|
32
|
+
device_name: device_name,
|
33
|
+
os_version: os_version,
|
34
|
+
product_type: product_type})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
simulators_list
|
38
|
+
end
|
39
|
+
|
40
|
+
def available_devices
|
41
|
+
available_real_devices.merge(available_simulators)
|
42
|
+
end
|
43
|
+
|
44
|
+
def device_info(udid)
|
45
|
+
real_devices_list = Hash.new
|
46
|
+
device_info_raw = `ideviceinfo -u #{udid}`
|
47
|
+
device_name = /DeviceName: (.*)\n/.match(device_info_raw)[1]
|
48
|
+
product_name = /ProductName: (.*)\n/.match(device_info_raw)[1]
|
49
|
+
product_type = /ProductType: (.*)\n/.match(device_info_raw)[1]
|
50
|
+
product_version = /ProductVersion: (.*)\n/.match(device_info_raw)[1]
|
51
|
+
wifi_address = /WiFiAddress: (.*)\n/.match(device_info_raw)[1]
|
52
|
+
wifi_ip_raw = `arp -a | grep #{wifi_address.gsub('0', '')}`
|
53
|
+
wifi_ip_address = 'unknown'
|
54
|
+
if wifi_ip_raw == ''
|
55
|
+
warn "Can't find device #{udid} ip by MAC, try to reconnect wifi"
|
56
|
+
else
|
57
|
+
wifi_ip_address = /\((.*)\)/.match(wifi_ip_raw)[1]
|
58
|
+
end
|
59
|
+
{
|
60
|
+
device_name => {
|
61
|
+
device_id: udid,
|
62
|
+
device_name: device_name,
|
63
|
+
product_name: product_name,
|
64
|
+
product_type: product_type,
|
65
|
+
os_version: product_version,
|
66
|
+
wifi_address: wifi_address,
|
67
|
+
wifi_ip_address: wifi_ip_address
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: idevices
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yi MIN
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple lib to get infomations of real devices and similators
|
14
|
+
email: minsparky@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/idevices.rb
|
20
|
+
homepage: http://rubygems.org/gems/idevices
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: idevices
|
44
|
+
test_files: []
|