mdq 1.0.0 → 1.1.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: 29fbbd7bc987bc45f23473fff290c05f458f9677c0f95739c6cfab4ea0e4da13
4
- data.tar.gz: 7797f6cdaad6c791717a83bfa5bfb67d5a1f485bc84e8855a6e3f91adc26251b
3
+ metadata.gz: 7c36b341ecf3203e0d02c57d48b84f1f7c9baf26464170912aa2b8f4fcb45fb0
4
+ data.tar.gz: ecc41b8401ae612cd285a72fd78a1ff0e962b73465faf99e7771efa14474ab0f
5
5
  SHA512:
6
- metadata.gz: 6fa1379783a969a874b20beb37b02d7ea7134f55f4cfc41f69c7b41ad8e3ab1f293602e8aa3cc2a8557d40fe5c18a08bfee49c16e4e7aa84241aac161abadf30
7
- data.tar.gz: 7612066bfa36a5702c7194da49f1d562bed37ddbcf0537e510dfcb4260baab57047743af94e8b734cdcd001b9d94bcd704c557d2d6552a36c7d6835a28d3ceb8
6
+ metadata.gz: f98aec1c38480c9d34d5b7175e742614ee1beade579ea97d289c2142e20e04266fd55e89ba9a8648f12caf08c606d49a66666750e0297f3522055a15f7f4aae2
7
+ data.tar.gz: b1d857915379f24189a634029f7e2c2f2e772200bc85a50202793a3097d0f4d31c7541839f065327fceed36074f7bb0ce729b6e77b040b78c8b2b2a5c54b4e6f
data/README.base.md CHANGED
@@ -28,23 +28,6 @@ Show mobile devices.
28
28
 
29
29
  ```
30
30
  $ mdq devices
31
- ```
32
-
33
- ## Apss
34
-
35
- Show apps.
36
-
37
- ```
38
- $ mdq apps
39
- ```
40
-
41
-
42
- ## List
43
-
44
- It's easy to use.
45
-
46
- ```
47
- $ mdq list
48
31
  [
49
32
  {
50
33
  "id": 1,
@@ -97,6 +80,17 @@ $ mdq list
97
80
  ]
98
81
  ```
99
82
 
83
+ ## Apss
84
+
85
+ Show apps.
86
+
87
+ ```
88
+ $ mdq apps
89
+ ```
90
+
91
+
92
+ ## List
93
+
100
94
  You can filter using SQL.
101
95
 
102
96
  ```
data/README.ja.md CHANGED
@@ -23,23 +23,6 @@ Show mobile devices.
23
23
 
24
24
  ```
25
25
  $ mdq devices
26
- ```
27
-
28
- ## Apss
29
-
30
- Show apps.
31
-
32
- ```
33
- $ mdq apps
34
- ```
35
-
36
-
37
- ## List
38
-
39
- It's easy to use.
40
-
41
- ```
42
- $ mdq list
43
26
  [
44
27
  {
45
28
  "id": 1,
@@ -92,6 +75,17 @@ $ mdq list
92
75
  ]
93
76
  ```
94
77
 
78
+ ## Apss
79
+
80
+ Show apps.
81
+
82
+ ```
83
+ $ mdq apps
84
+ ```
85
+
86
+
87
+ ## List
88
+
95
89
  You can filter using SQL.
96
90
 
97
91
  ```
data/README.md CHANGED
@@ -23,23 +23,6 @@ Show mobile devices.
23
23
 
24
24
  ```
25
25
  $ mdq devices
26
- ```
27
-
28
- ## Apss
29
-
30
- Show apps.
31
-
32
- ```
33
- $ mdq apps
34
- ```
35
-
36
-
37
- ## List
38
-
39
- It's easy to use.
40
-
41
- ```
42
- $ mdq list
43
26
  [
44
27
  {
45
28
  "id": 1,
@@ -92,6 +75,17 @@ $ mdq list
92
75
  ]
93
76
  ```
94
77
 
78
+ ## Apss
79
+
80
+ Show apps.
81
+
82
+ ```
83
+ $ mdq apps
84
+ ```
85
+
86
+
87
+ ## List
88
+
95
89
  You can filter using SQL.
96
90
 
97
91
  ```
data/lib/mdq/cli.rb CHANGED
@@ -47,7 +47,7 @@ module Mdq
47
47
  end
48
48
 
49
49
  desc 'list', 'Show mobile devices or apps'
50
- method_option :query, desc: 'SQL to filter devices or apps', aliases: '-q'
50
+ method_option :query, desc: 'SQL to filter devices or apps', aliases: '-q', required: true
51
51
  def list
52
52
  db = Mdq::DB.new
53
53
  db.get
@@ -64,7 +64,16 @@ module Mdq
64
64
  db.device_screencap(options[:output], options[:udid])
65
65
  end
66
66
 
67
- desc 'install', 'Installing the app(apk, ipa)'
67
+ desc 'simcap', 'Take a screenshot of the simulator.'
68
+ method_option :android, desc: 'Android emulator screenshot file name'
69
+ method_option :apple, desc: 'Apple simulator screenshot file name'
70
+ def simcap
71
+ db = Mdq::DB.new
72
+ db.sim_screencap(options[:android], is_android: true) if options[:android]
73
+ db.sim_screencap(options[:apple], is_android: false) if options[:apple]
74
+ end
75
+
76
+ desc 'install', 'Installing the app(apk, apex, ipa)'
68
77
  method_option :udid, desc: 'Specify the device UDID', aliases: '-u', required: true
69
78
  method_option :input, desc: 'Path to the app file', aliases: '-i', required: true
70
79
  method_option :replace, desc: 'Replace the app if it is already installed', aliases: '-r', default: false,
@@ -75,9 +84,9 @@ module Mdq
75
84
  db.app_install(options[:input], options[:udid], options[:replace])
76
85
  end
77
86
 
78
- desc 'uninstall', 'Uninstalling the app(apk, ipa)'
87
+ desc 'uninstall', 'Uninstalling the app'
79
88
  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
89
+ method_option :input, desc: 'Path to the app', aliases: '-i', required: true
81
90
  def uninstall
82
91
  db = Mdq::DB.new
83
92
  db.get(is_apps: false)
data/lib/mdq/db.rb CHANGED
@@ -38,7 +38,7 @@ module Mdq
38
38
  def device_screencap(output, udid)
39
39
  device = Device.find_by(udid: udid)
40
40
  if device.nil? || !device.android?
41
- puts 'Device not found or not an Android device.'
41
+ warn 'Device not found or not an Android device.'
42
42
  return
43
43
  end
44
44
 
@@ -50,46 +50,55 @@ module Mdq
50
50
  adb_command("shell rm #{full_path}", udid)
51
51
  end
52
52
 
53
- # Appをインストールする
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
53
+ def sim_screencap(output, is_android: true)
54
+ if is_android
55
+ output, error = adb_command("emu screenrecord #{output}}")
56
+ else
57
+ output, error = apple_sim_command("io booted screenshot #{output}")
59
58
  end
60
59
 
60
+ puts output unless output.empty?
61
+ warn error unless error.empty?
62
+ end
63
+
64
+ # Appをインストールする
65
+ def app_install(input, udid, is_replace)
61
66
  device = Device.find_by(udid: udid)
62
67
  if device.nil?
63
- puts 'Device not found.'
68
+ warn 'Device not found.'
64
69
  return
65
70
  end
66
71
 
67
- if device.android? && input.end_with?('.apk')
72
+ if device.android?
68
73
  if is_replace
69
- adb_command("install -r #{input}", udid)
74
+ output, error = adb_command("install -r #{input}", udid)
70
75
  else
71
- adb_command("install #{input}", udid)
76
+ output, error = adb_command("install #{input}", udid)
72
77
  end
73
- elsif !device.android? && input.end_with?('.ipa')
74
- apple_command("device install app #{input}", udid)
75
78
  else
76
- puts file_error_message
79
+ output, error = apple_command("device install app #{input}", udid)
77
80
  end
81
+
82
+ puts output unless output.empty?
83
+ warn error unless error.empty?
78
84
  end
79
85
 
80
86
  # Appをアンインストールする
81
87
  def app_uninstall(input, udid)
82
88
  device = Device.find_by(udid: udid)
83
89
  if device.nil?
84
- puts 'Device not found.'
90
+ warn 'Device not found.'
85
91
  return
86
92
  end
87
93
 
88
94
  if device.android?
89
- adb_command("uninstall #{input}", udid)
95
+ output, error = adb_command("uninstall #{input}", udid)
90
96
  else
91
- apple_command("device uninstall app #{input}", udid)
97
+ output, error = apple_command("device uninstall app #{input}", udid)
92
98
  end
99
+
100
+ puts output unless output.empty?
101
+ warn error unless error.empty?
93
102
  end
94
103
  end
95
104
  end
data/lib/mdq/discovery.rb CHANGED
@@ -52,6 +52,17 @@ module Mdq
52
52
  end
53
53
  end
54
54
 
55
+ # simctlコマンド
56
+ def apple_sim_command(arg)
57
+ command = "xcrun simctl #{arg}"
58
+
59
+ begin
60
+ Open3.capture3(command)
61
+ rescue StandardError
62
+ nil
63
+ end
64
+ end
65
+
55
66
  # Androidデバイス一覧を取得する
56
67
  def android_discover # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
57
68
  output, = adb_command('devices -l')
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.0.0'
4
+ VERSION = '1.1.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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arthur87
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-04-01 00:00:00.000000000 Z
10
+ date: 2026-04-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rubocop