mdq 0.5.1 → 0.5.2
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 +27 -11
- data/README.ja.md +27 -11
- data/README.md +27 -11
- data/lib/mdq/discovery.rb +56 -18
- data/lib/mdq/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6f15383d8943cba2f10e8204a31fde8117580ad57a94d0141ad898a5ed50b6a
|
4
|
+
data.tar.gz: ff937fc11de10ff1a1f97176a19cafa0aea59bf3cfeb18dd183ff79b5592868c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10a89282279e49ebf393d06d9af0e2d1483a958901f3f40b0a321e2c59f0ff16e9388f1d186f7af2c75556d33994e14f9228b258c7453dd819c7fbb36c509006
|
7
|
+
data.tar.gz: '09a80da76956894938b457d9c4ff1ab5d24093d84f5069e7e43ff79ecf3952c3d57888f16eaf75845cd3b51b6e1cdaf17dc8fc731d99f36fa2fb979333535c4f'
|
data/README.base.md
CHANGED
@@ -41,13 +41,17 @@ $ mdq list
|
|
41
41
|
"build_version": "16",
|
42
42
|
"build_id": "BP31.250502.008",
|
43
43
|
"battery_level": 88,
|
44
|
-
"total_disk":
|
45
|
-
"used_disk":
|
46
|
-
"available_disk":
|
44
|
+
"total_disk": 118015217664,
|
45
|
+
"used_disk": 19287748608,
|
46
|
+
"available_disk": 98727469056,
|
47
47
|
"capacity": 16,
|
48
|
-
"human_readable_total_disk": "
|
49
|
-
"human_readable_used_disk": "17.
|
50
|
-
"human_readable_available_disk": "
|
48
|
+
"human_readable_total_disk": "109.91 GB",
|
49
|
+
"human_readable_used_disk": "17.96 GB",
|
50
|
+
"human_readable_available_disk": "91.95 GB",
|
51
|
+
"mac_address": "ff:ff:ff:ff:ff:ff",
|
52
|
+
"ip_address": "192.168.1.1",
|
53
|
+
"ipv6_address": "IPV6_1,IPV6_2,IPV6_3,IPV6_3",
|
54
|
+
"wifi_network": "MyNet"
|
51
55
|
},
|
52
56
|
{
|
53
57
|
"id": 2,
|
@@ -65,9 +69,13 @@ $ mdq list
|
|
65
69
|
"used_disk": null,
|
66
70
|
"available_disk": null,
|
67
71
|
"capacity": null,
|
68
|
-
"human_readable_total_disk": "
|
72
|
+
"human_readable_total_disk": "128.0 GB",
|
69
73
|
"human_readable_used_disk": null,
|
70
|
-
"human_readable_available_disk": null
|
74
|
+
"human_readable_available_disk": null,
|
75
|
+
"mac_address": null,
|
76
|
+
"ip_address": null,
|
77
|
+
"ipv6_address": null,
|
78
|
+
"wifi_network": null
|
71
79
|
}
|
72
80
|
]
|
73
81
|
```
|
@@ -93,9 +101,13 @@ $ mdq list -q="select * from devices where platform='iOS'"
|
|
93
101
|
"used_disk": null,
|
94
102
|
"available_disk": null,
|
95
103
|
"capacity": null,
|
96
|
-
"human_readable_total_disk": "
|
104
|
+
"human_readable_total_disk": "128.0 GB",
|
97
105
|
"human_readable_used_disk": null,
|
98
|
-
"human_readable_available_disk": null
|
106
|
+
"human_readable_available_disk": null,
|
107
|
+
"mac_address": null,
|
108
|
+
"ip_address": null,
|
109
|
+
"ipv6_address": null,
|
110
|
+
"wifi_network": null
|
99
111
|
}
|
100
112
|
]
|
101
113
|
```
|
@@ -151,7 +163,11 @@ Details of the devices table.
|
|
151
163
|
| human_readable_total_disk | total_disk | total_disk |
|
152
164
|
| human_readable_available_disk | available_disk | Always "null" |
|
153
165
|
| human_readable_used_disk | used_disk | Always "null" |
|
154
|
-
|
166
|
+
| mac_address | MAC address (may be a random MAC address) | Always "null" |
|
167
|
+
| ip_address | IPv4 Address | Always "null" |
|
168
|
+
| ipv6_address | IPv6 Address | Always "null" |
|
169
|
+
| wifi_network | Wi-Fi Network | Always "null" |
|
170
|
+
|
155
171
|
Details of the apps table.
|
156
172
|
Apple Devices displays the apps installed with Xcode.
|
157
173
|
|
data/README.ja.md
CHANGED
@@ -36,13 +36,17 @@ $ mdq list
|
|
36
36
|
"build_version": "16",
|
37
37
|
"build_id": "BP31.250502.008",
|
38
38
|
"battery_level": 88,
|
39
|
-
"total_disk":
|
40
|
-
"used_disk":
|
41
|
-
"available_disk":
|
39
|
+
"total_disk": 118015217664,
|
40
|
+
"used_disk": 19287748608,
|
41
|
+
"available_disk": 98727469056,
|
42
42
|
"capacity": 16,
|
43
|
-
"human_readable_total_disk": "
|
44
|
-
"human_readable_used_disk": "17.
|
45
|
-
"human_readable_available_disk": "
|
43
|
+
"human_readable_total_disk": "109.91 GB",
|
44
|
+
"human_readable_used_disk": "17.96 GB",
|
45
|
+
"human_readable_available_disk": "91.95 GB",
|
46
|
+
"mac_address": "ff:ff:ff:ff:ff:ff",
|
47
|
+
"ip_address": "192.168.1.1",
|
48
|
+
"ipv6_address": "IPV6_1,IPV6_2,IPV6_3,IPV6_3",
|
49
|
+
"wifi_network": "MyNet"
|
46
50
|
},
|
47
51
|
{
|
48
52
|
"id": 2,
|
@@ -60,9 +64,13 @@ $ mdq list
|
|
60
64
|
"used_disk": null,
|
61
65
|
"available_disk": null,
|
62
66
|
"capacity": null,
|
63
|
-
"human_readable_total_disk": "
|
67
|
+
"human_readable_total_disk": "128.0 GB",
|
64
68
|
"human_readable_used_disk": null,
|
65
|
-
"human_readable_available_disk": null
|
69
|
+
"human_readable_available_disk": null,
|
70
|
+
"mac_address": null,
|
71
|
+
"ip_address": null,
|
72
|
+
"ipv6_address": null,
|
73
|
+
"wifi_network": null
|
66
74
|
}
|
67
75
|
]
|
68
76
|
```
|
@@ -88,9 +96,13 @@ $ mdq list -q="select * from devices where platform='iOS'"
|
|
88
96
|
"used_disk": null,
|
89
97
|
"available_disk": null,
|
90
98
|
"capacity": null,
|
91
|
-
"human_readable_total_disk": "
|
99
|
+
"human_readable_total_disk": "128.0 GB",
|
92
100
|
"human_readable_used_disk": null,
|
93
|
-
"human_readable_available_disk": null
|
101
|
+
"human_readable_available_disk": null,
|
102
|
+
"mac_address": null,
|
103
|
+
"ip_address": null,
|
104
|
+
"ipv6_address": null,
|
105
|
+
"wifi_network": null
|
94
106
|
}
|
95
107
|
]
|
96
108
|
```
|
@@ -146,7 +158,11 @@ Details of the devices table.
|
|
146
158
|
| human_readable_total_disk | total_disk | total_disk |
|
147
159
|
| human_readable_available_disk | available_disk | Always "null" |
|
148
160
|
| human_readable_used_disk | used_disk | Always "null" |
|
149
|
-
|
161
|
+
| mac_address | MAC address (may be a random MAC address) | Always "null" |
|
162
|
+
| ip_address | IPv4 Address | Always "null" |
|
163
|
+
| ipv6_address | IPv6 Address | Always "null" |
|
164
|
+
| wifi_network | Wi-Fi Network | Always "null" |
|
165
|
+
|
150
166
|
Details of the apps table.
|
151
167
|
Apple Devices displays the apps installed with Xcode.
|
152
168
|
|
data/README.md
CHANGED
@@ -36,13 +36,17 @@ $ mdq list
|
|
36
36
|
"build_version": "16",
|
37
37
|
"build_id": "BP31.250502.008",
|
38
38
|
"battery_level": 88,
|
39
|
-
"total_disk":
|
40
|
-
"used_disk":
|
41
|
-
"available_disk":
|
39
|
+
"total_disk": 118015217664,
|
40
|
+
"used_disk": 19287748608,
|
41
|
+
"available_disk": 98727469056,
|
42
42
|
"capacity": 16,
|
43
|
-
"human_readable_total_disk": "
|
44
|
-
"human_readable_used_disk": "17.
|
45
|
-
"human_readable_available_disk": "
|
43
|
+
"human_readable_total_disk": "109.91 GB",
|
44
|
+
"human_readable_used_disk": "17.96 GB",
|
45
|
+
"human_readable_available_disk": "91.95 GB",
|
46
|
+
"mac_address": "ff:ff:ff:ff:ff:ff",
|
47
|
+
"ip_address": "192.168.1.1",
|
48
|
+
"ipv6_address": "IPV6_1,IPV6_2,IPV6_3,IPV6_3",
|
49
|
+
"wifi_network": "MyNet"
|
46
50
|
},
|
47
51
|
{
|
48
52
|
"id": 2,
|
@@ -60,9 +64,13 @@ $ mdq list
|
|
60
64
|
"used_disk": null,
|
61
65
|
"available_disk": null,
|
62
66
|
"capacity": null,
|
63
|
-
"human_readable_total_disk": "
|
67
|
+
"human_readable_total_disk": "128.0 GB",
|
64
68
|
"human_readable_used_disk": null,
|
65
|
-
"human_readable_available_disk": null
|
69
|
+
"human_readable_available_disk": null,
|
70
|
+
"mac_address": null,
|
71
|
+
"ip_address": null,
|
72
|
+
"ipv6_address": null,
|
73
|
+
"wifi_network": null
|
66
74
|
}
|
67
75
|
]
|
68
76
|
```
|
@@ -88,9 +96,13 @@ $ mdq list -q="select * from devices where platform='iOS'"
|
|
88
96
|
"used_disk": null,
|
89
97
|
"available_disk": null,
|
90
98
|
"capacity": null,
|
91
|
-
"human_readable_total_disk": "
|
99
|
+
"human_readable_total_disk": "128.0 GB",
|
92
100
|
"human_readable_used_disk": null,
|
93
|
-
"human_readable_available_disk": null
|
101
|
+
"human_readable_available_disk": null,
|
102
|
+
"mac_address": null,
|
103
|
+
"ip_address": null,
|
104
|
+
"ipv6_address": null,
|
105
|
+
"wifi_network": null
|
94
106
|
}
|
95
107
|
]
|
96
108
|
```
|
@@ -146,7 +158,11 @@ Details of the devices table.
|
|
146
158
|
| human_readable_total_disk | total_disk | total_disk |
|
147
159
|
| human_readable_available_disk | available_disk | Always "null" |
|
148
160
|
| human_readable_used_disk | used_disk | Always "null" |
|
149
|
-
|
161
|
+
| mac_address | MAC address (may be a random MAC address) | Always "null" |
|
162
|
+
| ip_address | IPv4 Address | Always "null" |
|
163
|
+
| ipv6_address | IPv6 Address | Always "null" |
|
164
|
+
| wifi_network | Wi-Fi Network | Always "null" |
|
165
|
+
|
150
166
|
Details of the apps table.
|
151
167
|
Apple Devices displays the apps installed with Xcode.
|
152
168
|
|
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,
|
@@ -107,10 +136,14 @@ module Mdq
|
|
107
136
|
available_disk: available_disk,
|
108
137
|
used_disk: used_disk,
|
109
138
|
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'
|
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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arthur87
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|