mdq 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9ebf443d18d3239cbffab52e204afa1e07eeac2a984000f6b1afbc31855f1e7
4
- data.tar.gz: ad1c5a3e8cd2677d3e3de7fd63f5cde8d4622d0849aa5c153f559e6808dd5bef
3
+ metadata.gz: aa40709c2f0dca1610281b05d743cc6676126dd22e0c9ea8ee2a8b6719f97bdd
4
+ data.tar.gz: ced38027b22c1265d03b635f2530cb79972b8abaf786fcb00228bd59c77d379f
5
5
  SHA512:
6
- metadata.gz: 8521e42621c6a1ad2423e69c917dd1a13316827b7a3c2dac3ab357a48336b2ea7899c0028a8d2712f7caadb792930719b81dc5610c47be24806d3dc8e20d1b0c
7
- data.tar.gz: dd688ba27d82f27c1507c9d82e336ec3bd020955a3493e8df97ba7ac4c19325106cf4241db81da0b15a4e1d9c7b2fab4bdc99afd5af6755deedf6de06a4b77f8
6
+ metadata.gz: ce4c1cf1a3c96117646be0faac76fcec33e7e43b4badbf04ba7e5bf6dfbc5b9e058614934b51f34b19ec66f5b3fe9d501a91b5296d523d45e8df8b964cb020ea
7
+ data.tar.gz: 37a99b2f330e2dd227ccb500e038d9d5d28af8c2305a4405b7580b5c230829e50716dba9c7d2b18aa510212ab167572d57da92bb1719919eea2806f597663fef
data/.rubocop.yml CHANGED
@@ -1 +1,4 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: disable
data/README.base.md CHANGED
@@ -22,6 +22,21 @@ Check the software installation status.
22
22
  $ mdq check
23
23
  ```
24
24
 
25
+ The following versions have been tested and confirmed to work.
26
+
27
+ ```
28
+ $ adb --version
29
+ Android Debug Bridge version 1.0.41
30
+ Version 35.0.1-11580240
31
+ Installed as /opt/homebrew/bin/adb
32
+ Running on Darwin 25.5.0 (arm64)
33
+ ```
34
+
35
+ ```
36
+ $ xcrun --version
37
+ xcrun version 72.
38
+ ```
39
+
25
40
  ## Devices
26
41
 
27
42
  Show mobile devices.
@@ -38,6 +53,7 @@ $ mdq devices
38
53
  "platform": "Android",
39
54
  "marketing_name": null,
40
55
  "model": "Pixel 7",
56
+ "physical", true,
41
57
  "build_version": "16",
42
58
  "build_id": "BP31.250502.008",
43
59
  "battery_level": 88,
@@ -62,6 +78,7 @@ $ mdq devices
62
78
  "platform": "iOS",
63
79
  "marketing_name": "iPhone 16 Pro",
64
80
  "model": "iPhone17,1",
81
+ "physical", true,
65
82
  "build_version": "18.4.1",
66
83
  "build_id": "22E252",
67
84
  "battery_level": null,
@@ -105,6 +122,7 @@ $ mdq list -q="select * from devices where platform='iOS'"
105
122
  "platform": "iOS",
106
123
  "marketing_name": "iPhone 16 Pro",
107
124
  "model": "iPhone17,1",
125
+ "physical", true,
108
126
  "build_version": "18.4.1",
109
127
  "build_id": "22E252",
110
128
  "battery_level": null,
@@ -132,7 +150,8 @@ $ mdq list -q='select * from apps'
132
150
 
133
151
  ## Screenshot of a physical device
134
152
 
135
- Take a screenshot on Android.
153
+ Take a screenshot of the physical device.
154
+ For Apple devices, the physical column should be true.
136
155
 
137
156
  ```
138
157
  $ mdq cap -o='/Users/xxxxx/' -u='UDID'
@@ -190,6 +209,7 @@ Details of the devices table.
190
209
  | platform | Always "Android" | hardwareProperties.platform |
191
210
  | marketing_name | Always "null" | hardwareProperties.marketingName |
192
211
  | model | ro.product.model | hardwareProperties.productType |
212
+ | physical | Always true | hardwareProperties.reality |
193
213
  | build_version | ro.build.version.release | deviceProperties.osVersionNumber |
194
214
  | build_id | ro.build.id | deviceProperties.osBuildUpdate |
195
215
  | battery_level | battery | Always "null" |
data/README.ja.md CHANGED
@@ -17,6 +17,21 @@ Check the software installation status.
17
17
  $ mdq check
18
18
  ```
19
19
 
20
+ The following versions have been tested and confirmed to work.
21
+
22
+ ```
23
+ $ adb --version
24
+ Android Debug Bridge version 1.0.41
25
+ Version 35.0.1-11580240
26
+ Installed as /opt/homebrew/bin/adb
27
+ Running on Darwin 25.5.0 (arm64)
28
+ ```
29
+
30
+ ```
31
+ $ xcrun --version
32
+ xcrun version 72.
33
+ ```
34
+
20
35
  ## Devices
21
36
 
22
37
  Show mobile devices.
@@ -33,6 +48,7 @@ $ mdq devices
33
48
  "platform": "Android",
34
49
  "marketing_name": null,
35
50
  "model": "Pixel 7",
51
+ "physical", true,
36
52
  "build_version": "16",
37
53
  "build_id": "BP31.250502.008",
38
54
  "battery_level": 88,
@@ -57,6 +73,7 @@ $ mdq devices
57
73
  "platform": "iOS",
58
74
  "marketing_name": "iPhone 16 Pro",
59
75
  "model": "iPhone17,1",
76
+ "physical", true,
60
77
  "build_version": "18.4.1",
61
78
  "build_id": "22E252",
62
79
  "battery_level": null,
@@ -100,6 +117,7 @@ $ mdq list -q="select * from devices where platform='iOS'"
100
117
  "platform": "iOS",
101
118
  "marketing_name": "iPhone 16 Pro",
102
119
  "model": "iPhone17,1",
120
+ "physical", true,
103
121
  "build_version": "18.4.1",
104
122
  "build_id": "22E252",
105
123
  "battery_level": null,
@@ -127,7 +145,8 @@ $ mdq list -q='select * from apps'
127
145
 
128
146
  ## Screenshot of a physical device
129
147
 
130
- Take a screenshot on Android.
148
+ Take a screenshot of the physical device.
149
+ For Apple devices, the physical column should be true.
131
150
 
132
151
  ```
133
152
  $ mdq cap -o='/Users/xxxxx/' -u='UDID'
@@ -185,6 +204,7 @@ Details of the devices table.
185
204
  | platform | Always "Android" | hardwareProperties.platform |
186
205
  | marketing_name | Always "null" | hardwareProperties.marketingName |
187
206
  | model | ro.product.model | hardwareProperties.productType |
207
+ | physical | Always true | hardwareProperties.reality |
188
208
  | build_version | ro.build.version.release | deviceProperties.osVersionNumber |
189
209
  | build_id | ro.build.id | deviceProperties.osBuildUpdate |
190
210
  | battery_level | battery | Always "null" |
data/README.md CHANGED
@@ -17,6 +17,21 @@ Check the software installation status.
17
17
  $ mdq check
18
18
  ```
19
19
 
20
+ The following versions have been tested and confirmed to work.
21
+
22
+ ```
23
+ $ adb --version
24
+ Android Debug Bridge version 1.0.41
25
+ Version 35.0.1-11580240
26
+ Installed as /opt/homebrew/bin/adb
27
+ Running on Darwin 25.5.0 (arm64)
28
+ ```
29
+
30
+ ```
31
+ $ xcrun --version
32
+ xcrun version 72.
33
+ ```
34
+
20
35
  ## Devices
21
36
 
22
37
  Show mobile devices.
@@ -33,6 +48,7 @@ $ mdq devices
33
48
  "platform": "Android",
34
49
  "marketing_name": null,
35
50
  "model": "Pixel 7",
51
+ "physical", true,
36
52
  "build_version": "16",
37
53
  "build_id": "BP31.250502.008",
38
54
  "battery_level": 88,
@@ -57,6 +73,7 @@ $ mdq devices
57
73
  "platform": "iOS",
58
74
  "marketing_name": "iPhone 16 Pro",
59
75
  "model": "iPhone17,1",
76
+ "physical", true,
60
77
  "build_version": "18.4.1",
61
78
  "build_id": "22E252",
62
79
  "battery_level": null,
@@ -100,6 +117,7 @@ $ mdq list -q="select * from devices where platform='iOS'"
100
117
  "platform": "iOS",
101
118
  "marketing_name": "iPhone 16 Pro",
102
119
  "model": "iPhone17,1",
120
+ "physical", true,
103
121
  "build_version": "18.4.1",
104
122
  "build_id": "22E252",
105
123
  "battery_level": null,
@@ -127,7 +145,8 @@ $ mdq list -q='select * from apps'
127
145
 
128
146
  ## Screenshot of a physical device
129
147
 
130
- Take a screenshot on Android.
148
+ Take a screenshot of the physical device.
149
+ For Apple devices, the physical column should be true.
131
150
 
132
151
  ```
133
152
  $ mdq cap -o='/Users/xxxxx/' -u='UDID'
@@ -185,6 +204,7 @@ Details of the devices table.
185
204
  | platform | Always "Android" | hardwareProperties.platform |
186
205
  | marketing_name | Always "null" | hardwareProperties.marketingName |
187
206
  | model | ro.product.model | hardwareProperties.productType |
207
+ | physical | Always true | hardwareProperties.reality |
188
208
  | build_version | ro.build.version.release | deviceProperties.osVersionNumber |
189
209
  | build_id | ro.build.id | deviceProperties.osBuildUpdate |
190
210
  | battery_level | battery | Always "null" |
data/lib/mdq/cli.rb CHANGED
@@ -12,19 +12,19 @@ module Mdq
12
12
  end
13
13
  end
14
14
 
15
- desc 'version', 'Show Version'
15
+ desc 'version', 'Show Version.'
16
16
  def version
17
17
  puts(Mdq::VERSION)
18
18
  end
19
19
 
20
- desc 'check', 'Check the software installation status'
20
+ desc 'check', 'Check the software installation status.'
21
21
  def check
22
22
  db = Mdq::DB.new
23
23
  puts "adb is installed: #{db.android_discoverable?}"
24
24
  puts "Xcode is installed: #{db.apple_discoverable?}"
25
25
  end
26
26
 
27
- desc 'devices', 'Show mobile devices'
27
+ desc 'devices', 'Show mobile devices.'
28
28
  method_option :android, desc: 'Show Android devices', default: true,
29
29
  type: :boolean
30
30
  method_option :apple, desc: 'Show Apple devices', default: true,
@@ -35,7 +35,7 @@ module Mdq
35
35
  puts(JSON.pretty_generate(Device.all.as_json))
36
36
  end
37
37
 
38
- desc 'apps', 'Show mobile apps'
38
+ desc 'apps', 'Show mobile apps.'
39
39
  method_option :android, desc: 'Show Android devices', default: true,
40
40
  type: :boolean
41
41
  method_option :apple, desc: 'Show Apple devices', default: true,
@@ -46,17 +46,21 @@ module Mdq
46
46
  puts(JSON.pretty_generate(App.all.as_json))
47
47
  end
48
48
 
49
- desc 'list', 'Show mobile devices or apps'
49
+ desc 'list', 'Show mobile devices or apps.'
50
+ method_option :android, desc: 'Show Android devices', default: true,
51
+ type: :boolean
52
+ method_option :apple, desc: 'Show Apple devices', default: true,
53
+ type: :boolean
50
54
  method_option :query, desc: 'SQL to filter devices or apps', aliases: '-q', required: true
51
55
  def list
52
56
  db = Mdq::DB.new
53
- db.get
57
+ db.get(is_android: options[:android], is_apple: options[:apple])
54
58
  result = db.query(options['query'])
55
59
  puts(JSON.pretty_generate(result.as_json))
56
60
  end
57
61
 
58
- desc 'cap', 'Path to save screenshots(Android only)'
59
- method_option :udid, desc: 'Specify the device UDID', aliases: '-u', required: true
62
+ desc 'cap', 'Path to save screenshots of the physical device.'
63
+ method_option :udid, desc: 'Specify the device UDID', aliases: '-u'
60
64
  method_option :output, desc: 'Save to file', aliases: '-o', required: true
61
65
  def cap
62
66
  db = Mdq::DB.new
@@ -73,7 +77,7 @@ module Mdq
73
77
  db.sim_screencap(options[:output], is_android: options[:platform] == 'android')
74
78
  end
75
79
 
76
- desc 'install', 'Installing the app(apk, apex, ipa)'
80
+ desc 'install', 'Installing the app(apk, apex, ipa).'
77
81
  method_option :udid, desc: 'Specify the device UDID', aliases: '-u', required: true
78
82
  method_option :input, desc: 'Path to the app file', aliases: '-i', required: true
79
83
  method_option :replace, desc: 'Replace the app if it is already installed', aliases: '-r', default: false,
@@ -84,7 +88,7 @@ module Mdq
84
88
  db.app_install(options[:input], options[:udid], options[:replace])
85
89
  end
86
90
 
87
- desc 'uninstall', 'Uninstalling the app'
91
+ desc 'uninstall', 'Uninstalling the app.'
88
92
  method_option :udid, desc: 'Specify the device UDID', aliases: '-u', required: true
89
93
  method_option :input, desc: 'Path to the app', aliases: '-i', required: true
90
94
  def uninstall
@@ -93,7 +97,7 @@ module Mdq
93
97
  db.app_uninstall(options[:input], options[:udid])
94
98
  end
95
99
 
96
- def help
100
+ def self.help(shell, subcommand)
97
101
  super
98
102
  puts 'Online documentation: https://github.com/arthur87/mdq'
99
103
  end
data/lib/mdq/db.rb CHANGED
@@ -35,19 +35,34 @@ module Mdq
35
35
  end
36
36
 
37
37
  # Androidデバイスのスクリーンショットを撮る
38
- def device_screencap(output, udid)
39
- device = Device.find_by(udid: udid)
40
- if device.nil? || !device.android?
41
- warn 'Device not found or not an Android device.'
38
+ def device_screencap(output, udid = nil)
39
+ devices = if udid.nil?
40
+ Device.where(physical: true)
41
+ else
42
+ Device
43
+ .where('udid LIKE ?', "#{udid}%")
44
+ .where(physical: true)
45
+ end
46
+
47
+ if devices.empty?
48
+ warn 'Device not found.'
42
49
  return
43
50
  end
44
51
 
45
52
  FileUtils.mkdir_p(output)
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)
53
+
54
+ devices.each do |device|
55
+ file = "#{device.udid}-#{Time.now.strftime('%y%m%d-%H%M%S')}.png"
56
+
57
+ if device.android?
58
+ full_path = "/sdcard/#{file}"
59
+ adb_command("shell screencap -p #{full_path}", device.udid)
60
+ adb_command("pull #{full_path} #{output}", device.udid)
61
+ adb_command("shell rm #{full_path}", device.udid)
62
+ else
63
+ apple_command("device capture screenshot --destination #{output}/#{file}", device.udid)
64
+ end
65
+ end
51
66
  end
52
67
 
53
68
  def sim_screencap(output, is_android: true)
data/lib/mdq/discovery.rb CHANGED
@@ -154,7 +154,8 @@ module Mdq
154
154
  mac_address: mac_address,
155
155
  ip_address: ip_address,
156
156
  ipv6_address: ipv6_address.join(','),
157
- wifi_network: wifi_network
157
+ wifi_network: wifi_network,
158
+ physical: true
158
159
  })
159
160
 
160
161
  else
@@ -162,7 +163,8 @@ module Mdq
162
163
  udid: udid,
163
164
  serial_number: udid,
164
165
  authorized: false,
165
- platform: 'Android'
166
+ platform: 'Android',
167
+ physical: true
166
168
  })
167
169
  end
168
170
  end
@@ -181,6 +183,16 @@ module Mdq
181
183
  result['result']['devices'].each do |device|
182
184
  udid = device['hardwareProperties']['udid']
183
185
  total_disk = device['hardwareProperties']['internalStorageCapacity']
186
+
187
+ # 物理デバイスかどうか
188
+ # 判定できないときはnilにする
189
+ reality = device['hardwareProperties']['reality']
190
+ physical = if reality.nil?
191
+ nil
192
+ else
193
+ reality == 'physical'
194
+ end
195
+
184
196
  Device.create({
185
197
  udid: udid,
186
198
  serial_number: device['hardwareProperties']['serialNumber'],
@@ -192,7 +204,8 @@ module Mdq
192
204
  build_version: device['deviceProperties']['osVersionNumber'],
193
205
  build_id: device['deviceProperties']['osBuildUpdate'],
194
206
  total_disk: total_disk,
195
- human_readable_total_disk: number_to_human_size(total_disk, k)
207
+ human_readable_total_disk: number_to_human_size(total_disk, k),
208
+ physical: physical
196
209
  })
197
210
  end
198
211
 
@@ -274,6 +287,7 @@ ActiveRecord::Migration.create_table :devices do |t|
274
287
  t.string :platform
275
288
  t.string :marketing_name
276
289
  t.string :model
290
+ t.boolean :physical
277
291
  t.string :build_version
278
292
  t.string :build_id
279
293
  t.integer :battery_level
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.3.0'
4
+ VERSION = '1.4.0'
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.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arthur87
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-05-22 00:00:00.000000000 Z
10
+ date: 2026-06-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rubocop