mdq 0.5.1 → 1.0.0
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 +4 -4
- data/README.base.md +48 -15
- data/README.ja.md +48 -15
- data/README.md +48 -15
- data/lib/mdq/cli.rb +60 -8
- data/lib/mdq/db.rb +62 -37
- data/lib/mdq/discovery.rb +57 -19
- data/lib/mdq/version.rb +1 -1
- data/lib/mdq.rb +0 -3
- metadata +3 -9
- data/lib/mdq/check.rb +0 -29
- data/lib/mdq/list.rb +0 -40
- data/lib/mdq/output_builder.rb +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29fbbd7bc987bc45f23473fff290c05f458f9677c0f95739c6cfab4ea0e4da13
|
|
4
|
+
data.tar.gz: 7797f6cdaad6c791717a83bfa5bfb67d5a1f485bc84e8855a6e3f91adc26251b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fa1379783a969a874b20beb37b02d7ea7134f55f4cfc41f69c7b41ad8e3ab1f293602e8aa3cc2a8557d40fe5c18a08bfee49c16e4e7aa84241aac161abadf30
|
|
7
|
+
data.tar.gz: 7612066bfa36a5702c7194da49f1d562bed37ddbcf0537e510dfcb4260baab57047743af94e8b734cdcd001b9d94bcd704c557d2d6552a36c7d6835a28d3ceb8
|
data/README.base.md
CHANGED
|
@@ -22,6 +22,23 @@ Check the software installation status.
|
|
|
22
22
|
$ mdq check
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
## Devices
|
|
26
|
+
|
|
27
|
+
Show mobile devices.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
$ mdq devices
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Apss
|
|
34
|
+
|
|
35
|
+
Show apps.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
$ mdq apps
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
|
|
25
42
|
## List
|
|
26
43
|
|
|
27
44
|
It's easy to use.
|
|
@@ -41,13 +58,17 @@ $ mdq list
|
|
|
41
58
|
"build_version": "16",
|
|
42
59
|
"build_id": "BP31.250502.008",
|
|
43
60
|
"battery_level": 88,
|
|
44
|
-
"total_disk":
|
|
45
|
-
"used_disk":
|
|
46
|
-
"available_disk":
|
|
61
|
+
"total_disk": 118015217664,
|
|
62
|
+
"used_disk": 19287748608,
|
|
63
|
+
"available_disk": 98727469056,
|
|
47
64
|
"capacity": 16,
|
|
48
|
-
"human_readable_total_disk": "
|
|
49
|
-
"human_readable_used_disk": "17.
|
|
50
|
-
"human_readable_available_disk": "
|
|
65
|
+
"human_readable_total_disk": "109.91 GB",
|
|
66
|
+
"human_readable_used_disk": "17.96 GB",
|
|
67
|
+
"human_readable_available_disk": "91.95 GB",
|
|
68
|
+
"mac_address": "ff:ff:ff:ff:ff:ff",
|
|
69
|
+
"ip_address": "192.168.1.1",
|
|
70
|
+
"ipv6_address": "IPV6_1,IPV6_2,IPV6_3,IPV6_3",
|
|
71
|
+
"wifi_network": "MyNet"
|
|
51
72
|
},
|
|
52
73
|
{
|
|
53
74
|
"id": 2,
|
|
@@ -65,9 +86,13 @@ $ mdq list
|
|
|
65
86
|
"used_disk": null,
|
|
66
87
|
"available_disk": null,
|
|
67
88
|
"capacity": null,
|
|
68
|
-
"human_readable_total_disk": "
|
|
89
|
+
"human_readable_total_disk": "128.0 GB",
|
|
69
90
|
"human_readable_used_disk": null,
|
|
70
|
-
"human_readable_available_disk": null
|
|
91
|
+
"human_readable_available_disk": null,
|
|
92
|
+
"mac_address": null,
|
|
93
|
+
"ip_address": null,
|
|
94
|
+
"ipv6_address": null,
|
|
95
|
+
"wifi_network": null
|
|
71
96
|
}
|
|
72
97
|
]
|
|
73
98
|
```
|
|
@@ -93,9 +118,13 @@ $ mdq list -q="select * from devices where platform='iOS'"
|
|
|
93
118
|
"used_disk": null,
|
|
94
119
|
"available_disk": null,
|
|
95
120
|
"capacity": null,
|
|
96
|
-
"human_readable_total_disk": "
|
|
121
|
+
"human_readable_total_disk": "128.0 GB",
|
|
97
122
|
"human_readable_used_disk": null,
|
|
98
|
-
"human_readable_available_disk": null
|
|
123
|
+
"human_readable_available_disk": null,
|
|
124
|
+
"mac_address": null,
|
|
125
|
+
"ip_address": null,
|
|
126
|
+
"ipv6_address": null,
|
|
127
|
+
"wifi_network": null
|
|
99
128
|
}
|
|
100
129
|
]
|
|
101
130
|
```
|
|
@@ -110,20 +139,20 @@ $ mdq list -q='select * from apps'
|
|
|
110
139
|
Take a screenshot on Android.
|
|
111
140
|
|
|
112
141
|
```
|
|
113
|
-
$ mdq
|
|
142
|
+
$ mdq cap -o='/Users/xxxxx/' -u='UDID'
|
|
114
143
|
```
|
|
115
144
|
|
|
116
145
|
Install the app.
|
|
117
146
|
|
|
118
147
|
```
|
|
119
|
-
$ mdq
|
|
120
|
-
$ mdq
|
|
148
|
+
$ mdq install -i='/Users/xxxxx/example.apk' -u='UDID'
|
|
149
|
+
$ mdq install -i=='/Users/xxxxx/example.ipa' -u='UDID'
|
|
121
150
|
```
|
|
122
151
|
|
|
123
152
|
Uninstall the app.
|
|
124
153
|
|
|
125
154
|
```
|
|
126
|
-
$ mdq
|
|
155
|
+
$ mdq uninstall -i='com.example.app' -u='UDID'
|
|
127
156
|
```
|
|
128
157
|
|
|
129
158
|
|
|
@@ -151,7 +180,11 @@ Details of the devices table.
|
|
|
151
180
|
| human_readable_total_disk | total_disk | total_disk |
|
|
152
181
|
| human_readable_available_disk | available_disk | Always "null" |
|
|
153
182
|
| human_readable_used_disk | used_disk | Always "null" |
|
|
154
|
-
|
|
183
|
+
| mac_address | MAC address (may be a random MAC address) | Always "null" |
|
|
184
|
+
| ip_address | IPv4 Address | Always "null" |
|
|
185
|
+
| ipv6_address | IPv6 Address | Always "null" |
|
|
186
|
+
| wifi_network | Wi-Fi Network | Always "null" |
|
|
187
|
+
|
|
155
188
|
Details of the apps table.
|
|
156
189
|
Apple Devices displays the apps installed with Xcode.
|
|
157
190
|
|
data/README.ja.md
CHANGED
|
@@ -17,6 +17,23 @@ Check the software installation status.
|
|
|
17
17
|
$ mdq check
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
## Devices
|
|
21
|
+
|
|
22
|
+
Show mobile devices.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
$ mdq devices
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Apss
|
|
29
|
+
|
|
30
|
+
Show apps.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ mdq apps
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
|
|
20
37
|
## List
|
|
21
38
|
|
|
22
39
|
It's easy to use.
|
|
@@ -36,13 +53,17 @@ $ mdq list
|
|
|
36
53
|
"build_version": "16",
|
|
37
54
|
"build_id": "BP31.250502.008",
|
|
38
55
|
"battery_level": 88,
|
|
39
|
-
"total_disk":
|
|
40
|
-
"used_disk":
|
|
41
|
-
"available_disk":
|
|
56
|
+
"total_disk": 118015217664,
|
|
57
|
+
"used_disk": 19287748608,
|
|
58
|
+
"available_disk": 98727469056,
|
|
42
59
|
"capacity": 16,
|
|
43
|
-
"human_readable_total_disk": "
|
|
44
|
-
"human_readable_used_disk": "17.
|
|
45
|
-
"human_readable_available_disk": "
|
|
60
|
+
"human_readable_total_disk": "109.91 GB",
|
|
61
|
+
"human_readable_used_disk": "17.96 GB",
|
|
62
|
+
"human_readable_available_disk": "91.95 GB",
|
|
63
|
+
"mac_address": "ff:ff:ff:ff:ff:ff",
|
|
64
|
+
"ip_address": "192.168.1.1",
|
|
65
|
+
"ipv6_address": "IPV6_1,IPV6_2,IPV6_3,IPV6_3",
|
|
66
|
+
"wifi_network": "MyNet"
|
|
46
67
|
},
|
|
47
68
|
{
|
|
48
69
|
"id": 2,
|
|
@@ -60,9 +81,13 @@ $ mdq list
|
|
|
60
81
|
"used_disk": null,
|
|
61
82
|
"available_disk": null,
|
|
62
83
|
"capacity": null,
|
|
63
|
-
"human_readable_total_disk": "
|
|
84
|
+
"human_readable_total_disk": "128.0 GB",
|
|
64
85
|
"human_readable_used_disk": null,
|
|
65
|
-
"human_readable_available_disk": null
|
|
86
|
+
"human_readable_available_disk": null,
|
|
87
|
+
"mac_address": null,
|
|
88
|
+
"ip_address": null,
|
|
89
|
+
"ipv6_address": null,
|
|
90
|
+
"wifi_network": null
|
|
66
91
|
}
|
|
67
92
|
]
|
|
68
93
|
```
|
|
@@ -88,9 +113,13 @@ $ mdq list -q="select * from devices where platform='iOS'"
|
|
|
88
113
|
"used_disk": null,
|
|
89
114
|
"available_disk": null,
|
|
90
115
|
"capacity": null,
|
|
91
|
-
"human_readable_total_disk": "
|
|
116
|
+
"human_readable_total_disk": "128.0 GB",
|
|
92
117
|
"human_readable_used_disk": null,
|
|
93
|
-
"human_readable_available_disk": null
|
|
118
|
+
"human_readable_available_disk": null,
|
|
119
|
+
"mac_address": null,
|
|
120
|
+
"ip_address": null,
|
|
121
|
+
"ipv6_address": null,
|
|
122
|
+
"wifi_network": null
|
|
94
123
|
}
|
|
95
124
|
]
|
|
96
125
|
```
|
|
@@ -105,20 +134,20 @@ $ mdq list -q='select * from apps'
|
|
|
105
134
|
Take a screenshot on Android.
|
|
106
135
|
|
|
107
136
|
```
|
|
108
|
-
$ mdq
|
|
137
|
+
$ mdq cap -o='/Users/xxxxx/' -u='UDID'
|
|
109
138
|
```
|
|
110
139
|
|
|
111
140
|
Install the app.
|
|
112
141
|
|
|
113
142
|
```
|
|
114
|
-
$ mdq
|
|
115
|
-
$ mdq
|
|
143
|
+
$ mdq install -i='/Users/xxxxx/example.apk' -u='UDID'
|
|
144
|
+
$ mdq install -i=='/Users/xxxxx/example.ipa' -u='UDID'
|
|
116
145
|
```
|
|
117
146
|
|
|
118
147
|
Uninstall the app.
|
|
119
148
|
|
|
120
149
|
```
|
|
121
|
-
$ mdq
|
|
150
|
+
$ mdq uninstall -i='com.example.app' -u='UDID'
|
|
122
151
|
```
|
|
123
152
|
|
|
124
153
|
|
|
@@ -146,7 +175,11 @@ Details of the devices table.
|
|
|
146
175
|
| human_readable_total_disk | total_disk | total_disk |
|
|
147
176
|
| human_readable_available_disk | available_disk | Always "null" |
|
|
148
177
|
| human_readable_used_disk | used_disk | Always "null" |
|
|
149
|
-
|
|
178
|
+
| mac_address | MAC address (may be a random MAC address) | Always "null" |
|
|
179
|
+
| ip_address | IPv4 Address | Always "null" |
|
|
180
|
+
| ipv6_address | IPv6 Address | Always "null" |
|
|
181
|
+
| wifi_network | Wi-Fi Network | Always "null" |
|
|
182
|
+
|
|
150
183
|
Details of the apps table.
|
|
151
184
|
Apple Devices displays the apps installed with Xcode.
|
|
152
185
|
|
data/README.md
CHANGED
|
@@ -17,6 +17,23 @@ Check the software installation status.
|
|
|
17
17
|
$ mdq check
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
## Devices
|
|
21
|
+
|
|
22
|
+
Show mobile devices.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
$ mdq devices
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Apss
|
|
29
|
+
|
|
30
|
+
Show apps.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ mdq apps
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
|
|
20
37
|
## List
|
|
21
38
|
|
|
22
39
|
It's easy to use.
|
|
@@ -36,13 +53,17 @@ $ mdq list
|
|
|
36
53
|
"build_version": "16",
|
|
37
54
|
"build_id": "BP31.250502.008",
|
|
38
55
|
"battery_level": 88,
|
|
39
|
-
"total_disk":
|
|
40
|
-
"used_disk":
|
|
41
|
-
"available_disk":
|
|
56
|
+
"total_disk": 118015217664,
|
|
57
|
+
"used_disk": 19287748608,
|
|
58
|
+
"available_disk": 98727469056,
|
|
42
59
|
"capacity": 16,
|
|
43
|
-
"human_readable_total_disk": "
|
|
44
|
-
"human_readable_used_disk": "17.
|
|
45
|
-
"human_readable_available_disk": "
|
|
60
|
+
"human_readable_total_disk": "109.91 GB",
|
|
61
|
+
"human_readable_used_disk": "17.96 GB",
|
|
62
|
+
"human_readable_available_disk": "91.95 GB",
|
|
63
|
+
"mac_address": "ff:ff:ff:ff:ff:ff",
|
|
64
|
+
"ip_address": "192.168.1.1",
|
|
65
|
+
"ipv6_address": "IPV6_1,IPV6_2,IPV6_3,IPV6_3",
|
|
66
|
+
"wifi_network": "MyNet"
|
|
46
67
|
},
|
|
47
68
|
{
|
|
48
69
|
"id": 2,
|
|
@@ -60,9 +81,13 @@ $ mdq list
|
|
|
60
81
|
"used_disk": null,
|
|
61
82
|
"available_disk": null,
|
|
62
83
|
"capacity": null,
|
|
63
|
-
"human_readable_total_disk": "
|
|
84
|
+
"human_readable_total_disk": "128.0 GB",
|
|
64
85
|
"human_readable_used_disk": null,
|
|
65
|
-
"human_readable_available_disk": null
|
|
86
|
+
"human_readable_available_disk": null,
|
|
87
|
+
"mac_address": null,
|
|
88
|
+
"ip_address": null,
|
|
89
|
+
"ipv6_address": null,
|
|
90
|
+
"wifi_network": null
|
|
66
91
|
}
|
|
67
92
|
]
|
|
68
93
|
```
|
|
@@ -88,9 +113,13 @@ $ mdq list -q="select * from devices where platform='iOS'"
|
|
|
88
113
|
"used_disk": null,
|
|
89
114
|
"available_disk": null,
|
|
90
115
|
"capacity": null,
|
|
91
|
-
"human_readable_total_disk": "
|
|
116
|
+
"human_readable_total_disk": "128.0 GB",
|
|
92
117
|
"human_readable_used_disk": null,
|
|
93
|
-
"human_readable_available_disk": null
|
|
118
|
+
"human_readable_available_disk": null,
|
|
119
|
+
"mac_address": null,
|
|
120
|
+
"ip_address": null,
|
|
121
|
+
"ipv6_address": null,
|
|
122
|
+
"wifi_network": null
|
|
94
123
|
}
|
|
95
124
|
]
|
|
96
125
|
```
|
|
@@ -105,20 +134,20 @@ $ mdq list -q='select * from apps'
|
|
|
105
134
|
Take a screenshot on Android.
|
|
106
135
|
|
|
107
136
|
```
|
|
108
|
-
$ mdq
|
|
137
|
+
$ mdq cap -o='/Users/xxxxx/' -u='UDID'
|
|
109
138
|
```
|
|
110
139
|
|
|
111
140
|
Install the app.
|
|
112
141
|
|
|
113
142
|
```
|
|
114
|
-
$ mdq
|
|
115
|
-
$ mdq
|
|
143
|
+
$ mdq install -i='/Users/xxxxx/example.apk' -u='UDID'
|
|
144
|
+
$ mdq install -i=='/Users/xxxxx/example.ipa' -u='UDID'
|
|
116
145
|
```
|
|
117
146
|
|
|
118
147
|
Uninstall the app.
|
|
119
148
|
|
|
120
149
|
```
|
|
121
|
-
$ mdq
|
|
150
|
+
$ mdq uninstall -i='com.example.app' -u='UDID'
|
|
122
151
|
```
|
|
123
152
|
|
|
124
153
|
|
|
@@ -146,7 +175,11 @@ Details of the devices table.
|
|
|
146
175
|
| human_readable_total_disk | total_disk | total_disk |
|
|
147
176
|
| human_readable_available_disk | available_disk | Always "null" |
|
|
148
177
|
| human_readable_used_disk | used_disk | Always "null" |
|
|
149
|
-
|
|
178
|
+
| mac_address | MAC address (may be a random MAC address) | Always "null" |
|
|
179
|
+
| ip_address | IPv4 Address | Always "null" |
|
|
180
|
+
| ipv6_address | IPv6 Address | Always "null" |
|
|
181
|
+
| wifi_network | Wi-Fi Network | Always "null" |
|
|
182
|
+
|
|
150
183
|
Details of the apps table.
|
|
151
184
|
Apple Devices displays the apps installed with Xcode.
|
|
152
185
|
|
data/lib/mdq/cli.rb
CHANGED
|
@@ -19,17 +19,69 @@ module Mdq
|
|
|
19
19
|
|
|
20
20
|
desc 'check', 'Check the software installation status'
|
|
21
21
|
def check
|
|
22
|
-
Mdq::
|
|
22
|
+
db = Mdq::DB.new
|
|
23
|
+
puts "adb is installed: #{db.android_discoverable?}"
|
|
24
|
+
puts "Xcode is installed: #{db.apple_discoverable?}"
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
desc '
|
|
26
|
-
method_option :
|
|
27
|
-
|
|
28
|
-
method_option :
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
desc 'devices', 'Show mobile devices'
|
|
28
|
+
method_option :android, desc: 'Show Android devices', default: true,
|
|
29
|
+
type: :boolean
|
|
30
|
+
method_option :apple, desc: 'Show Apple devices', default: true,
|
|
31
|
+
type: :boolean
|
|
32
|
+
def devices
|
|
33
|
+
db = Mdq::DB.new
|
|
34
|
+
db.get(is_android: options[:android], is_apple: options[:apple], is_apps: false)
|
|
35
|
+
puts(JSON.pretty_generate(Device.all.as_json))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
desc 'apps', 'Show mobile apps'
|
|
39
|
+
method_option :android, desc: 'Show Android devices', default: true,
|
|
40
|
+
type: :boolean
|
|
41
|
+
method_option :apple, desc: 'Show Apple devices', default: true,
|
|
42
|
+
type: :boolean
|
|
43
|
+
def apps
|
|
44
|
+
db = Mdq::DB.new
|
|
45
|
+
db.get(is_android: options[:android], is_apple: options[:apple])
|
|
46
|
+
puts(JSON.pretty_generate(App.all.as_json))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
desc 'list', 'Show mobile devices or apps'
|
|
50
|
+
method_option :query, desc: 'SQL to filter devices or apps', aliases: '-q'
|
|
31
51
|
def list
|
|
32
|
-
Mdq::
|
|
52
|
+
db = Mdq::DB.new
|
|
53
|
+
db.get
|
|
54
|
+
result = db.query(options['query'])
|
|
55
|
+
puts(JSON.pretty_generate(result.as_json))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
desc 'cap', 'Path to save screenshots(Android only)'
|
|
59
|
+
method_option :udid, desc: 'Specify the device UDID', aliases: '-u', required: true
|
|
60
|
+
method_option :output, desc: 'Save to file', aliases: '-o', required: true
|
|
61
|
+
def cap
|
|
62
|
+
db = Mdq::DB.new
|
|
63
|
+
db.get(is_apps: false)
|
|
64
|
+
db.device_screencap(options[:output], options[:udid])
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
desc 'install', 'Installing the app(apk, ipa)'
|
|
68
|
+
method_option :udid, desc: 'Specify the device UDID', aliases: '-u', required: true
|
|
69
|
+
method_option :input, desc: 'Path to the app file', aliases: '-i', required: true
|
|
70
|
+
method_option :replace, desc: 'Replace the app if it is already installed', aliases: '-r', default: false,
|
|
71
|
+
type: :boolean
|
|
72
|
+
def install
|
|
73
|
+
db = Mdq::DB.new
|
|
74
|
+
db.get(is_apps: false)
|
|
75
|
+
db.app_install(options[:input], options[:udid], options[:replace])
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
desc 'uninstall', 'Uninstalling the app(apk, ipa)'
|
|
79
|
+
method_option :udid, desc: 'Specify the device UDID', aliases: '-u', required: true
|
|
80
|
+
method_option :input, desc: 'Path to the app file', aliases: '-i', required: true
|
|
81
|
+
def uninstall
|
|
82
|
+
db = Mdq::DB.new
|
|
83
|
+
db.get(is_apps: false)
|
|
84
|
+
db.app_uninstall(options[:input], options[:udid])
|
|
33
85
|
end
|
|
34
86
|
end
|
|
35
87
|
end
|
data/lib/mdq/db.rb
CHANGED
|
@@ -8,63 +8,88 @@ require 'fileutils'
|
|
|
8
8
|
module Mdq
|
|
9
9
|
# DB
|
|
10
10
|
class DB < Discovery
|
|
11
|
-
#
|
|
12
|
-
def get(
|
|
11
|
+
# デバイスとアプリの取得
|
|
12
|
+
def get(is_android: true, is_apple: true, is_apps: true)
|
|
13
13
|
reset
|
|
14
14
|
# デバイスの発見
|
|
15
|
-
android_discover
|
|
16
|
-
apple_discover
|
|
15
|
+
android_discover if is_android
|
|
16
|
+
apple_discover if is_apple
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
Device.all.each do |model|
|
|
20
|
-
# インストール済みAppの取得
|
|
21
|
-
if model.android?
|
|
22
|
-
android_apps(model.udid)
|
|
23
|
-
else
|
|
24
|
-
apple_apps(model.udid)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
18
|
+
return unless is_apps
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
Device.all.each do |model|
|
|
21
|
+
# インストール済みAppの取得
|
|
22
|
+
if model.android?
|
|
23
|
+
android_apps(model.udid)
|
|
24
|
+
else
|
|
25
|
+
apple_apps(model.udid)
|
|
32
26
|
end
|
|
33
|
-
else
|
|
34
|
-
Device.all
|
|
35
27
|
end
|
|
36
28
|
end
|
|
37
29
|
|
|
30
|
+
# クエリの実行
|
|
31
|
+
def query(sql)
|
|
32
|
+
ActiveRecord::Base.connection.execute(sql)
|
|
33
|
+
rescue StandardError
|
|
34
|
+
[]
|
|
35
|
+
end
|
|
36
|
+
|
|
38
37
|
# Androidデバイスのスクリーンショットを撮る
|
|
39
|
-
def device_screencap(output, udid
|
|
40
|
-
|
|
38
|
+
def device_screencap(output, udid)
|
|
39
|
+
device = Device.find_by(udid: udid)
|
|
40
|
+
if device.nil? || !device.android?
|
|
41
|
+
puts 'Device not found or not an Android device.'
|
|
42
|
+
return
|
|
43
|
+
end
|
|
41
44
|
|
|
42
45
|
FileUtils.mkdir_p(output)
|
|
43
|
-
file = "
|
|
44
|
-
|
|
45
|
-
adb_command("
|
|
46
|
-
adb_command("
|
|
47
|
-
|
|
48
|
-
{ command: 'cap', udid: udid, result: nil }
|
|
46
|
+
file = "#{udid}-#{Time.now.strftime('%y%m%d-%H%M%S')}.png"
|
|
47
|
+
full_path = "/sdcard/#{file}"
|
|
48
|
+
adb_command("shell screencap -p #{full_path}", udid)
|
|
49
|
+
adb_command("pull #{full_path} #{output}", udid)
|
|
50
|
+
adb_command("shell rm #{full_path}", udid)
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
# Appをインストールする
|
|
52
|
-
def app_install(input, udid,
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
def app_install(input, udid, is_replace)
|
|
55
|
+
file_error_message = 'Invalid file format. Please provide an .apk file for Android or an .ipa file for iOS.'
|
|
56
|
+
unless File.exist?(input)
|
|
57
|
+
puts file_error_message
|
|
58
|
+
return
|
|
59
|
+
end
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
device = Device.find_by(udid: udid)
|
|
62
|
+
if device.nil?
|
|
63
|
+
puts 'Device not found.'
|
|
64
|
+
return
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if device.android? && input.end_with?('.apk')
|
|
68
|
+
if is_replace
|
|
69
|
+
adb_command("install -r #{input}", udid)
|
|
70
|
+
else
|
|
71
|
+
adb_command("install #{input}", udid)
|
|
72
|
+
end
|
|
73
|
+
elsif !device.android? && input.end_with?('.ipa')
|
|
74
|
+
apple_command("device install app #{input}", udid)
|
|
75
|
+
else
|
|
76
|
+
puts file_error_message
|
|
77
|
+
end
|
|
57
78
|
end
|
|
58
79
|
|
|
59
80
|
# Appをアンインストールする
|
|
60
|
-
def app_uninstall(input, udid
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
def app_uninstall(input, udid)
|
|
82
|
+
device = Device.find_by(udid: udid)
|
|
83
|
+
if device.nil?
|
|
84
|
+
puts 'Device not found.'
|
|
85
|
+
return
|
|
65
86
|
end
|
|
66
87
|
|
|
67
|
-
|
|
88
|
+
if device.android?
|
|
89
|
+
adb_command("uninstall #{input}", udid)
|
|
90
|
+
else
|
|
91
|
+
apple_command("device uninstall app #{input}", udid)
|
|
92
|
+
end
|
|
68
93
|
end
|
|
69
94
|
end
|
|
70
95
|
end
|
data/lib/mdq/discovery.rb
CHANGED
|
@@ -7,7 +7,7 @@ require 'fileutils'
|
|
|
7
7
|
# Mdq
|
|
8
8
|
module Mdq
|
|
9
9
|
# Discovery
|
|
10
|
-
class Discovery
|
|
10
|
+
class Discovery # rubocop:disable Metrics/ClassLength
|
|
11
11
|
def initialize
|
|
12
12
|
@home = FileUtils.mkdir_p([Dir.home, '.mdq'].join(File::Separator))
|
|
13
13
|
end
|
|
@@ -53,17 +53,19 @@ module Mdq
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# Androidデバイス一覧を取得する
|
|
56
|
-
def android_discover # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
56
|
+
def android_discover # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
57
57
|
output, = adb_command('devices -l')
|
|
58
58
|
return if output.nil?
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
next if index.zero?
|
|
60
|
+
k = 1024.0
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
output.split("\n").each_with_index do |output_line, output_index| # rubocop:disable Metrics/BlockLength
|
|
63
|
+
next if output_index.zero?
|
|
64
|
+
|
|
65
|
+
columns = output_line.split
|
|
64
66
|
|
|
65
67
|
udid = columns[0]
|
|
66
|
-
authorized =
|
|
68
|
+
authorized = output_line.index('unauthorized').nil?
|
|
67
69
|
|
|
68
70
|
if authorized
|
|
69
71
|
model, = adb_command('shell getprop ro.product.model', udid)
|
|
@@ -74,6 +76,10 @@ module Mdq
|
|
|
74
76
|
total_disk = nil
|
|
75
77
|
available_disk = nil
|
|
76
78
|
used_disk = nil
|
|
79
|
+
mac_address = nil
|
|
80
|
+
ip_address = nil
|
|
81
|
+
ipv6_address = []
|
|
82
|
+
wifi_network = nil
|
|
77
83
|
|
|
78
84
|
# バッテリー
|
|
79
85
|
lines1, = adb_command('shell dumpsys battery', udid)
|
|
@@ -83,17 +89,40 @@ module Mdq
|
|
|
83
89
|
|
|
84
90
|
# ストレージ
|
|
85
91
|
lines2, = adb_command('shell df', udid)
|
|
86
|
-
lines2.split("\n").each_with_index do |
|
|
87
|
-
next if
|
|
92
|
+
lines2.split("\n").each_with_index do |line, index|
|
|
93
|
+
next if index.zero?
|
|
88
94
|
|
|
89
|
-
columns =
|
|
95
|
+
columns = line.split
|
|
90
96
|
next if columns[5].index('/data').nil?
|
|
91
97
|
|
|
92
|
-
total_disk = columns[1].to_f *
|
|
93
|
-
available_disk = columns[3].to_f *
|
|
98
|
+
total_disk = columns[1].to_f * k
|
|
99
|
+
available_disk = columns[3].to_f * k
|
|
94
100
|
used_disk = total_disk - available_disk
|
|
95
101
|
end
|
|
96
102
|
|
|
103
|
+
# MACアドレスとIPアドレス
|
|
104
|
+
lines3, = adb_command('shell ip addr show wlan0', udid)
|
|
105
|
+
lines3.split("\n").each do |line|
|
|
106
|
+
match = line.match('link/ether (.*?) ')
|
|
107
|
+
mac_address = match[1] unless match.nil?
|
|
108
|
+
|
|
109
|
+
match = line.match('inet (.*?)/')
|
|
110
|
+
ip_address = match[1] unless match.nil?
|
|
111
|
+
|
|
112
|
+
match = line.match('inet6 (.*?)/')
|
|
113
|
+
ipv6_address << match[1] unless match.nil?
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Wi-Fi
|
|
117
|
+
lines4, = adb_command("shell dumpsys netstats | grep -E 'iface=wlan0'", udid)
|
|
118
|
+
lines4.split("\n").each do |line|
|
|
119
|
+
match = line.match(' wifiNetworkKey="(.*?)"')
|
|
120
|
+
next if match[1].nil?
|
|
121
|
+
|
|
122
|
+
wifi_network = match[1]
|
|
123
|
+
break
|
|
124
|
+
end
|
|
125
|
+
|
|
97
126
|
Device.create({
|
|
98
127
|
udid: udid,
|
|
99
128
|
serial_number: udid,
|
|
@@ -106,11 +135,15 @@ module Mdq
|
|
|
106
135
|
total_disk: total_disk,
|
|
107
136
|
available_disk: available_disk,
|
|
108
137
|
used_disk: used_disk,
|
|
109
|
-
capacity: (used_disk / total_disk) * 100,
|
|
110
|
-
human_readable_total_disk: number_to_human_size(total_disk),
|
|
111
|
-
human_readable_available_disk: number_to_human_size(available_disk),
|
|
112
|
-
human_readable_used_disk: number_to_human_size(used_disk),
|
|
113
|
-
platform: 'Android'
|
|
138
|
+
capacity: (used_disk.to_f / total_disk) * 100,
|
|
139
|
+
human_readable_total_disk: number_to_human_size(total_disk, k),
|
|
140
|
+
human_readable_available_disk: number_to_human_size(available_disk, k),
|
|
141
|
+
human_readable_used_disk: number_to_human_size(used_disk, k),
|
|
142
|
+
platform: 'Android',
|
|
143
|
+
mac_address: mac_address,
|
|
144
|
+
ip_address: ip_address,
|
|
145
|
+
ipv6_address: ipv6_address.join(','),
|
|
146
|
+
wifi_network: wifi_network
|
|
114
147
|
})
|
|
115
148
|
|
|
116
149
|
else
|
|
@@ -128,6 +161,7 @@ module Mdq
|
|
|
128
161
|
def apple_discover
|
|
129
162
|
file = [@home, 'mdq.json'].join(File::Separator)
|
|
130
163
|
result = apple_command("list devices -v -j #{file}")
|
|
164
|
+
k = 1000.0
|
|
131
165
|
|
|
132
166
|
return unless File.exist?(file)
|
|
133
167
|
|
|
@@ -147,7 +181,7 @@ module Mdq
|
|
|
147
181
|
build_version: device['deviceProperties']['osVersionNumber'],
|
|
148
182
|
build_id: device['deviceProperties']['osBuildUpdate'],
|
|
149
183
|
total_disk: total_disk,
|
|
150
|
-
human_readable_total_disk: number_to_human_size(total_disk)
|
|
184
|
+
human_readable_total_disk: number_to_human_size(total_disk, k)
|
|
151
185
|
})
|
|
152
186
|
end
|
|
153
187
|
|
|
@@ -196,13 +230,13 @@ module Mdq
|
|
|
196
230
|
ActiveRecord::Base.connection.execute("delete from sqlite_sequence where name='apps'")
|
|
197
231
|
end
|
|
198
232
|
|
|
199
|
-
|
|
233
|
+
# バイト単位の数値を変換
|
|
234
|
+
def number_to_human_size(size, k) # rubocop:disable Naming/MethodParameterName
|
|
200
235
|
return nil if size.nil?
|
|
201
236
|
|
|
202
237
|
units = [' B', ' KB', ' MB', ' GB', ' TB']
|
|
203
238
|
|
|
204
239
|
i = 0
|
|
205
|
-
k = 1000.0
|
|
206
240
|
while size > k
|
|
207
241
|
size /= k
|
|
208
242
|
i += 1
|
|
@@ -239,6 +273,10 @@ ActiveRecord::Migration.create_table :devices do |t|
|
|
|
239
273
|
t.string :human_readable_total_disk
|
|
240
274
|
t.string :human_readable_used_disk
|
|
241
275
|
t.string :human_readable_available_disk
|
|
276
|
+
t.string :mac_address
|
|
277
|
+
t.string :ip_address
|
|
278
|
+
t.text :ipv6_address
|
|
279
|
+
t.string :wifi_network
|
|
242
280
|
end
|
|
243
281
|
|
|
244
282
|
ActiveRecord::Migration.create_table :apps do |t|
|
data/lib/mdq/version.rb
CHANGED
data/lib/mdq.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mdq
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- arthur87
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-04-01 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rubocop
|
|
@@ -85,12 +84,9 @@ files:
|
|
|
85
84
|
- Rakefile
|
|
86
85
|
- exe/mdq
|
|
87
86
|
- lib/mdq.rb
|
|
88
|
-
- lib/mdq/check.rb
|
|
89
87
|
- lib/mdq/cli.rb
|
|
90
88
|
- lib/mdq/db.rb
|
|
91
89
|
- lib/mdq/discovery.rb
|
|
92
|
-
- lib/mdq/list.rb
|
|
93
|
-
- lib/mdq/output_builder.rb
|
|
94
90
|
- lib/mdq/version.rb
|
|
95
91
|
homepage: https://github.com/arthur87/mdq
|
|
96
92
|
licenses:
|
|
@@ -98,7 +94,6 @@ licenses:
|
|
|
98
94
|
metadata:
|
|
99
95
|
homepage_uri: https://github.com/arthur87/mdq
|
|
100
96
|
source_code_uri: https://github.com/arthur87/mdq
|
|
101
|
-
post_install_message:
|
|
102
97
|
rdoc_options: []
|
|
103
98
|
require_paths:
|
|
104
99
|
- lib
|
|
@@ -113,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
113
108
|
- !ruby/object:Gem::Version
|
|
114
109
|
version: '0'
|
|
115
110
|
requirements: []
|
|
116
|
-
rubygems_version: 3.
|
|
117
|
-
signing_key:
|
|
111
|
+
rubygems_version: 3.6.3
|
|
118
112
|
specification_version: 4
|
|
119
113
|
summary: mdq is a command line tool for displaying information about Android and Apple
|
|
120
114
|
devices.
|
data/lib/mdq/check.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'mdq'
|
|
4
|
-
|
|
5
|
-
# Mdq
|
|
6
|
-
module Mdq
|
|
7
|
-
# Check
|
|
8
|
-
class Check
|
|
9
|
-
def initialize
|
|
10
|
-
ob = Mdq::OutputBuilder.new
|
|
11
|
-
|
|
12
|
-
db = Mdq::DB.new
|
|
13
|
-
ob.add(show_message('adb', db.android_discoverable?))
|
|
14
|
-
ob.add(show_message('Xcode', db.apple_discoverable?))
|
|
15
|
-
|
|
16
|
-
ob.print
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def show_message(name, discoverable)
|
|
22
|
-
if discoverable
|
|
23
|
-
{ result: "#{name} is installed." }
|
|
24
|
-
else
|
|
25
|
-
{ result: "#{name} is not installed." }
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
data/lib/mdq/list.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'mdq'
|
|
4
|
-
|
|
5
|
-
# Mdq
|
|
6
|
-
module Mdq
|
|
7
|
-
# List
|
|
8
|
-
class List
|
|
9
|
-
def initialize(options)
|
|
10
|
-
db = Mdq::DB.new
|
|
11
|
-
|
|
12
|
-
query = options['query']
|
|
13
|
-
models = db.get(query)
|
|
14
|
-
|
|
15
|
-
output = JSON.pretty_generate(models.as_json)
|
|
16
|
-
puts output
|
|
17
|
-
if options['output']
|
|
18
|
-
File.open(options['output'], 'w') do |f|
|
|
19
|
-
f.write(output)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
ob = Mdq::OutputBuilder.new
|
|
24
|
-
|
|
25
|
-
models.each do |device|
|
|
26
|
-
model = Device.find_by(udid: device.udid)
|
|
27
|
-
udid = model.udid
|
|
28
|
-
is_android = model.android?
|
|
29
|
-
|
|
30
|
-
ob.add(db.device_screencap(options[:cap], udid, is_android)) if options[:cap]
|
|
31
|
-
ob.add(db.app_install(options[:install], udid, is_android)) if options[:install]
|
|
32
|
-
ob.add(db.app_uninstall(options[:uninstall], udid, is_android)) if options[:uninstall]
|
|
33
|
-
rescue StandardError
|
|
34
|
-
# none
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
ob.print
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
data/lib/mdq/output_builder.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'mdq'
|
|
4
|
-
|
|
5
|
-
# Mdq
|
|
6
|
-
module Mdq
|
|
7
|
-
# OutputBuilder
|
|
8
|
-
class OutputBuilder
|
|
9
|
-
def initialize
|
|
10
|
-
@result = []
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def clear
|
|
14
|
-
@result = []
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def add(new_result)
|
|
18
|
-
@result << new_result
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def print
|
|
22
|
-
return if @result == []
|
|
23
|
-
|
|
24
|
-
puts JSON.pretty_generate(@result.as_json)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|