mdq 0.3.0 → 0.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: 11207ffa243aa9925a945ecf3e989f3ef136a36d3ef3d574e32372528097e09f
4
- data.tar.gz: 642365689def13a8c56769d3f070954b123f3c6ebf7ca23f2a781415a1a44f5d
3
+ metadata.gz: 7cac0bbdd587c39245b20565f173c940cc3820d013e85ea49cdeef449fbba699
4
+ data.tar.gz: 13ccafb7f07a7e52425f350d26315a0e6638cbd2f6cf07a83d3c2e58501b6293
5
5
  SHA512:
6
- metadata.gz: 9b8812fd72184096df44cec5361a071e7b3c6f0175768efb32ecd9e1149e9d73d9d334c82ea83764fab67415a7680c854ec97d9f31508649c7265a3db62b2358
7
- data.tar.gz: 74ff17f9a43ff731d42fff94055c718ce85408e1dc641d5d70bed51e4fff6cd8be3dcd39ddca65fed082ed8e2bda7e018c0a750bbff3009eb80aba79f2922a3f
6
+ metadata.gz: 7dc6da32e3ab760db20aa66e1c744506eacee4ab46f210f212742faac3622bddc9b340d9565c31466b20104fcec674f61eca9d5a26ab8d87343b5404a5745669
7
+ data.tar.gz: 853b11146f7ea736f48ef558e7d88eae4f43d4d55da1056dfaa00d1179fcba0cfea1812df5edc4e0a7ecc6f8784706fef394c4d58405c263e6ce8abb52c66b1e
data/README.base.md CHANGED
@@ -7,6 +7,8 @@
7
7
 
8
8
  # mdq - Mobile Device Query
9
9
 
10
+ [![Gem Version](https://badge.fury.io/rb/mdq.svg)](https://badge.fury.io/rb/mdq)
11
+
10
12
  MDQ stands for Mobile Device Query and is a command line tool for displaying information about Android and Apple devices.
11
13
 
12
14
  # Usage
@@ -127,7 +129,7 @@ Details of the devices table.
127
129
  | build_version | ro.build.version.release | deviceProperties.osVersionNumber |
128
130
  | build_id | ro.build.id | deviceProperties.osBuildUpdate |
129
131
  | battery_level | battery | Always "null" |
130
- | total_capacity | df | Always "null" |
132
+ | total_capacity | df | hardwareProperties.internalStorageCapacity |
131
133
  | free_capacity | df | Always "null" |
132
134
 
133
135
 
data/README.ja.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  # mdq - Mobile Device Query
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/mdq.svg)](https://badge.fury.io/rb/mdq)
6
+
5
7
  MDQ stands for Mobile Device Query and is a command line tool for displaying information about Android and Apple devices.
6
8
 
7
9
  # Usage
@@ -122,7 +124,7 @@ Details of the devices table.
122
124
  | build_version | ro.build.version.release | deviceProperties.osVersionNumber |
123
125
  | build_id | ro.build.id | deviceProperties.osBuildUpdate |
124
126
  | battery_level | battery | Always "null" |
125
- | total_capacity | df | Always "null" |
127
+ | total_capacity | df | hardwareProperties.internalStorageCapacity |
126
128
  | free_capacity | df | Always "null" |
127
129
 
128
130
 
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  # mdq - Mobile Device Query
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/mdq.svg)](https://badge.fury.io/rb/mdq)
6
+
5
7
  MDQ stands for Mobile Device Query and is a command line tool for displaying information about Android and Apple devices.
6
8
 
7
9
  # Usage
@@ -122,7 +124,7 @@ Details of the devices table.
122
124
  | build_version | ro.build.version.release | deviceProperties.osVersionNumber |
123
125
  | build_id | ro.build.id | deviceProperties.osBuildUpdate |
124
126
  | battery_level | battery | Always "null" |
125
- | total_capacity | df | Always "null" |
127
+ | total_capacity | df | hardwareProperties.internalStorageCapacity |
126
128
  | free_capacity | df | Always "null" |
127
129
 
128
130
 
data/lib/mdq/check.rb CHANGED
@@ -8,8 +8,18 @@ module Mdq
8
8
  class Check
9
9
  def initialize
10
10
  db = Mdq::DB.new
11
- db.show_version('adb', 'adb version')
12
- db.show_version('Xcode', 'xcrun devicectl --version')
11
+ show_message('adb', db.android_discoverable?)
12
+ show_message('Xcode', db.apple_discoverable?)
13
+ end
14
+
15
+ private
16
+
17
+ def show_message(name, discoverable)
18
+ if discoverable
19
+ puts "# #{name} is installed."
20
+ else
21
+ puts "# #{name} is not installed."
22
+ end
13
23
  end
14
24
  end
15
25
  end
data/lib/mdq/db.rb CHANGED
@@ -10,8 +10,7 @@ module Mdq
10
10
  class DB < Discovery
11
11
  # クエリの実行
12
12
  def get(sql)
13
- InitialSchema.migrate(:reset)
14
-
13
+ reset
15
14
  # デバイスの発見
16
15
  android_discover
17
16
  apple_discover
@@ -37,15 +36,6 @@ module Mdq
37
36
  end
38
37
  end
39
38
 
40
- # 指定したソフトウェアのインストール状況を表示する
41
- def show_version(name, command)
42
- output, = Open3.capture3(command)
43
- puts "# #{name} installed."
44
- puts output
45
- rescue StandardError
46
- puts "# #{name} is not installed."
47
- end
48
-
49
39
  # Androidデバイスのスクリーンショットを撮る
50
40
  def device_screencap(output, udid, is_android)
51
41
  return unless is_android
data/lib/mdq/discovery.rb CHANGED
@@ -9,8 +9,15 @@ module Mdq
9
9
  # Discovery
10
10
  class Discovery
11
11
  def initialize
12
- ActiveRecord::Schema.verbose = false
13
- InitialSchema.migrate(:up)
12
+ @home = FileUtils.mkdir_p([Dir.home, '.mdq'].join(File::Separator))
13
+ end
14
+
15
+ def android_discoverable?
16
+ adb_command('version').present?
17
+ end
18
+
19
+ def apple_discoverable?
20
+ apple_command('--version').present?
14
21
  end
15
22
 
16
23
  private
@@ -112,9 +119,9 @@ module Mdq
112
119
 
113
120
  # Appleデバイス一覧を取得する
114
121
  def apple_discover
115
- file = [Dir.home, '.mdq'].join(File::Separator)
122
+ file = [@home, 'mdq.json'].join(File::Separator)
116
123
  result = apple_command("list devices -v -j #{file}")
117
- return if result.nil?
124
+
118
125
  return unless File.exist?(file)
119
126
 
120
127
  File.open(file, 'r') do |f|
@@ -130,7 +137,8 @@ module Mdq
130
137
  marketing_name: device['hardwareProperties']['marketingName'],
131
138
  model: device['hardwareProperties']['productType'],
132
139
  build_version: device['deviceProperties']['osVersionNumber'],
133
- build_id: device['deviceProperties']['osBuildUpdate']
140
+ build_id: device['deviceProperties']['osBuildUpdate'],
141
+ total_capacity: device['hardwareProperties']['internalStorageCapacity']
134
142
  })
135
143
  end
136
144
 
@@ -151,7 +159,7 @@ module Mdq
151
159
 
152
160
  # Appleデバイスのアプリを取得する
153
161
  def apple_apps(udid)
154
- file = [Dir.home, '.mdq-apps'].join(File::Separator)
162
+ file = [@home, 'mdq-apps.json'].join(File::Separator)
155
163
  apple_command("device info apps -j #{file}", udid)
156
164
  File.open(file, 'r') do |f|
157
165
  result = JSON.parse(f.read)
@@ -170,44 +178,44 @@ module Mdq
170
178
  end
171
179
  File.delete(file)
172
180
  end
181
+
182
+ def reset
183
+ Device.destroy_all
184
+ App.destroy_all
185
+ ActiveRecord::Base.connection.execute("delete from sqlite_sequence where name='devices'")
186
+ ActiveRecord::Base.connection.execute("delete from sqlite_sequence where name='apps'")
187
+ end
173
188
  end
174
189
  end
175
190
 
191
+ ActiveRecord::Schema.verbose = false
192
+ ActiveRecord::Migration.verbose = false
193
+
176
194
  ActiveRecord::Base.establish_connection(
177
195
  adapter: 'sqlite3',
178
196
  database: ':memory:'
179
197
  )
180
198
 
181
- # スキーマの設定
182
- class InitialSchema < ActiveRecord::Migration[5.1]
183
- def self.up
184
- create_table :devices do |t|
185
- t.string :udid
186
- t.string :serial_number
187
- t.string :name
188
- t.boolean :authorized
189
- t.string :platform
190
- t.string :marketing_name
191
- t.string :model
192
- t.string :build_version
193
- t.string :build_id
194
- t.integer :battery_level
195
- t.integer :total_capacity
196
- t.integer :free_capacity
197
- end
198
-
199
- create_table :apps do |t|
200
- t.string :udid
201
- t.string :name
202
- t.string :package_name
203
- t.string :version
204
- end
205
- end
199
+ ActiveRecord::Migration.create_table :devices do |t|
200
+ t.string :udid
201
+ t.string :serial_number
202
+ t.string :name
203
+ t.boolean :authorized
204
+ t.string :platform
205
+ t.string :marketing_name
206
+ t.string :model
207
+ t.string :build_version
208
+ t.string :build_id
209
+ t.integer :battery_level
210
+ t.integer :total_capacity
211
+ t.integer :free_capacity
212
+ end
206
213
 
207
- def self.down
208
- drop_table :devices
209
- drop_table :apps
210
- end
214
+ ActiveRecord::Migration.create_table :apps do |t|
215
+ t.string :udid
216
+ t.string :name
217
+ t.string :package_name
218
+ t.string :version
211
219
  end
212
220
 
213
221
  # Device
data/lib/mdq/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mdq
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arthur87
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-21 00:00:00.000000000 Z
11
+ date: 2025-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop