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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ba84c3f7c666c4f32a57802aec86dc14dd3c213cc056bdb86b2ee2fa1bc7a1a
4
- data.tar.gz: 16dffbcf4e63038c4976c95fe0763939b0c6c4736f24802a594f17a30f7e91b9
3
+ metadata.gz: eec98441746fbb4662ed354d93d0f228e07b71bb51e1c6e377ad999e13b6b97e
4
+ data.tar.gz: f08772d007547d4b559d29de26fd15197c69f845eff048fe4343cb23f9ce5148
5
5
  SHA512:
6
- metadata.gz: 5339784eaa9049ce0322ca19199c83d5ef6fd010db98f7ce67f40307861c92b33b9fd715494c440824c396406eff44190d169f955972dff1c920a079422eb4a3
7
- data.tar.gz: cf3ff9fcc28b265b0f4616e9dae9f0afd714f3b05045c73ee6c8752f49791a3e11dead60f759a1befe048bd6f912271324f1a3fb93ae19bf0cffd8c61c9301db
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], is_apple: options[:apple], is_apps: false)
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
- lines1, = adb_command('shell dumpsys battery', udid)
97
- if (match = lines1.match(/level: (\d*)/))
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
- lines2, = adb_command('shell df', udid)
103
- lines2.split("\n").each_with_index do |line, index|
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
- lines3, = adb_command('shell ip addr show wlan0', udid)
116
- lines3.split("\n").each do |line|
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
- lines4, = adb_command("shell dumpsys netstats | grep -E 'iface=wlan0'", udid)
129
- lines4.split("\n").each do |line|
130
- match = line.match(' wifiNetworkKey="(.*?)"')
131
- next if match[1].nil?
132
-
133
- wifi_network = match[1]
134
- break
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mdq
4
- VERSION = '1.5.0'
4
+ VERSION = '1.5.2'
5
5
  end
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.0
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-06-18 00:00:00.000000000 Z
10
+ date: 2026-09-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rubocop