mdq 1.5.0 → 1.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/lib/mdq/cli.rb +9 -1
- data/lib/mdq/db.rb +3 -3
- data/lib/mdq/discovery.rb +29 -16
- 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: eec98441746fbb4662ed354d93d0f228e07b71bb51e1c6e377ad999e13b6b97e
|
|
4
|
+
data.tar.gz: f08772d007547d4b559d29de26fd15197c69f845eff048fe4343cb23f9ce5148
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f8224cf564bad8c026f5f7ea9f5615ce582a014a7c0659dd4f467503acc31c2a1cb411017f5933218fdb679ed0673c52ac0c8e8ef8477a8a64721ec458b94b28
|
|
7
|
+
data.tar.gz: f3b50616a7cad1eb9179ad5dd30c65f888c2339dcb197ad5612b365026c526e3945af0af75d387343ea30cb3c480d0e8be4223249e04f04a7e1c56b68d779e97
|
data/lib/mdq/cli.rb
CHANGED
|
@@ -29,9 +29,17 @@ module Mdq
|
|
|
29
29
|
type: :boolean
|
|
30
30
|
method_option :apple, desc: 'Show Apple devices', default: true,
|
|
31
31
|
type: :boolean
|
|
32
|
+
method_option :physical, desc: 'Show physical devices', default: true,
|
|
33
|
+
type: :boolean
|
|
34
|
+
method_option :simulated, desc: 'Show simulated devices', default: true,
|
|
35
|
+
type: :boolean
|
|
32
36
|
def devices
|
|
33
37
|
db = Mdq::DB.new
|
|
34
|
-
db.get(is_android: options[:android],
|
|
38
|
+
db.get(is_android: options[:android],
|
|
39
|
+
is_apple: options[:apple],
|
|
40
|
+
is_apps: false,
|
|
41
|
+
is_physical: options[:physical],
|
|
42
|
+
is_simulated: options[:simulated])
|
|
35
43
|
puts(JSON.pretty_generate(Device.all.as_json))
|
|
36
44
|
end
|
|
37
45
|
|
data/lib/mdq/db.rb
CHANGED
|
@@ -10,11 +10,11 @@ module Mdq
|
|
|
10
10
|
# DB
|
|
11
11
|
class DB < Discovery
|
|
12
12
|
# デバイスとアプリの取得
|
|
13
|
-
def get(is_android: true, is_apple: true, is_apps: true)
|
|
13
|
+
def get(is_android: true, is_apple: true, is_apps: true, is_physical: true, is_simulated: true)
|
|
14
14
|
reset
|
|
15
15
|
# デバイスの発見
|
|
16
|
-
android_discover if is_android
|
|
17
|
-
apple_discover if is_apple
|
|
16
|
+
android_discover(is_physical) if is_android
|
|
17
|
+
apple_discover(is_physical, is_simulated) if is_apple
|
|
18
18
|
|
|
19
19
|
return unless is_apps
|
|
20
20
|
|
data/lib/mdq/discovery.rb
CHANGED
|
@@ -64,7 +64,9 @@ module Mdq
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Androidデバイス一覧を取得する
|
|
67
|
-
def android_discover # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
67
|
+
def android_discover(is_physical = true) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Style/OptionalBooleanParameter
|
|
68
|
+
return if skip_device?(true, is_physical, false)
|
|
69
|
+
|
|
68
70
|
output, = adb_command('devices -l')
|
|
69
71
|
return if output.nil?
|
|
70
72
|
|
|
@@ -90,17 +92,16 @@ module Mdq
|
|
|
90
92
|
mac_address = nil
|
|
91
93
|
ip_address = nil
|
|
92
94
|
ipv6_address = []
|
|
93
|
-
wifi_network = nil
|
|
94
95
|
|
|
95
96
|
# バッテリー
|
|
96
|
-
|
|
97
|
-
if (match =
|
|
97
|
+
battery_lines, = adb_command('shell dumpsys battery', udid)
|
|
98
|
+
if (match = battery_lines.match(/level: (\d*)/))
|
|
98
99
|
battery_level = match[1].to_i
|
|
99
100
|
end
|
|
100
101
|
|
|
101
102
|
# ストレージ
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
df_lines, = adb_command('shell df', udid)
|
|
104
|
+
df_lines.split("\n").each_with_index do |line, index|
|
|
104
105
|
next if index.zero?
|
|
105
106
|
|
|
106
107
|
columns = line.split
|
|
@@ -112,8 +113,8 @@ module Mdq
|
|
|
112
113
|
end
|
|
113
114
|
|
|
114
115
|
# MACアドレスとIPアドレス
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
ip_lines, = adb_command('shell ip addr show wlan0', udid)
|
|
117
|
+
ip_lines.split("\n").each do |line|
|
|
117
118
|
match = line.match('link/ether (.*?) ')
|
|
118
119
|
mac_address = match[1] unless match.nil?
|
|
119
120
|
|
|
@@ -125,13 +126,15 @@ module Mdq
|
|
|
125
126
|
end
|
|
126
127
|
|
|
127
128
|
# Wi-Fi
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
wifi_network = nil
|
|
130
|
+
wifi_lines, = adb_command("shell dumpsys netstats | grep -E 'iface=wlan0'", udid)
|
|
131
|
+
wifi_lines.split("\n").each do |line|
|
|
132
|
+
if line.include?('wifiNetworkKey=') && (match = line.match(/(wifiNetworkKey="(.*?)")/))
|
|
133
|
+
wifi_network = match[2]
|
|
134
|
+
end
|
|
135
|
+
if line.include?('networkId=') && (match = line.match(/(networkId="(.*?)")/))
|
|
136
|
+
wifi_network = match[2]
|
|
137
|
+
end
|
|
135
138
|
end
|
|
136
139
|
|
|
137
140
|
Device.create({
|
|
@@ -171,7 +174,7 @@ module Mdq
|
|
|
171
174
|
end
|
|
172
175
|
|
|
173
176
|
# Appleデバイス一覧を取得する
|
|
174
|
-
def apple_discover
|
|
177
|
+
def apple_discover(is_physical = true, is_simulated = true) # rubocop:disable Style/OptionalBooleanParameter
|
|
175
178
|
file = [@home, 'mdq.json'].join(File::Separator)
|
|
176
179
|
result = apple_command("list devices -v -j #{file}")
|
|
177
180
|
k = 1000.0
|
|
@@ -193,6 +196,8 @@ module Mdq
|
|
|
193
196
|
reality == 'physical'
|
|
194
197
|
end
|
|
195
198
|
|
|
199
|
+
next if skip_device?(physical, is_physical, is_simulated)
|
|
200
|
+
|
|
196
201
|
Device.create({
|
|
197
202
|
udid: udid,
|
|
198
203
|
serial_number: device['hardwareProperties']['serialNumber'],
|
|
@@ -268,6 +273,14 @@ module Mdq
|
|
|
268
273
|
|
|
269
274
|
"#{(size * 100).round / 100.0}#{units[i]}"
|
|
270
275
|
end
|
|
276
|
+
|
|
277
|
+
# デバイスの物理/シミュレートのフラグをスキップするかどうか
|
|
278
|
+
# 物理デバイスの場合: is_physical が true ならスキップしない(false)、false ならスキップする(true)。
|
|
279
|
+
# シミュレータの場合: is_simulated が true ならスキップしない(false)、false ならスキップする(true)。
|
|
280
|
+
# 判定不能(nil)の場合: シミュレータとして扱い、is_simulated の設定に従う。
|
|
281
|
+
def skip_device?(physical, is_physical, is_simulated)
|
|
282
|
+
!((physical && is_physical) || (!physical && is_simulated))
|
|
283
|
+
end
|
|
271
284
|
end
|
|
272
285
|
end
|
|
273
286
|
|
data/lib/mdq/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mdq
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- arthur87
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-09-28 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rubocop
|