mdq 1.4.0 → 1.5.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 +4 -4
- data/lib/mdq/cli.rb +9 -3
- data/lib/mdq/db.rb +29 -2
- data/lib/mdq/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ba84c3f7c666c4f32a57802aec86dc14dd3c213cc056bdb86b2ee2fa1bc7a1a
|
|
4
|
+
data.tar.gz: 16dffbcf4e63038c4976c95fe0763939b0c6c4736f24802a594f17a30f7e91b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5339784eaa9049ce0322ca19199c83d5ef6fd010db98f7ce67f40307861c92b33b9fd715494c440824c396406eff44190d169f955972dff1c920a079422eb4a3
|
|
7
|
+
data.tar.gz: cf3ff9fcc28b265b0f4616e9dae9f0afd714f3b05045c73ee6c8752f49791a3e11dead60f759a1befe048bd6f912271324f1a3fb93ae19bf0cffd8c61c9301db
|
data/lib/mdq/cli.rb
CHANGED
|
@@ -54,9 +54,15 @@ module Mdq
|
|
|
54
54
|
method_option :query, desc: 'SQL to filter devices or apps', aliases: '-q', required: true
|
|
55
55
|
def list
|
|
56
56
|
db = Mdq::DB.new
|
|
57
|
-
db.
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
is_apps = db.query_contains_apps_table?(options[:query])
|
|
58
|
+
db.get(is_android: options[:android], is_apple: options[:apple], is_apps: is_apps)
|
|
59
|
+
|
|
60
|
+
begin
|
|
61
|
+
result = db.query(options['query'])
|
|
62
|
+
puts(JSON.pretty_generate(result.as_json))
|
|
63
|
+
rescue StandardError => e
|
|
64
|
+
warn e.message
|
|
65
|
+
end
|
|
60
66
|
end
|
|
61
67
|
|
|
62
68
|
desc 'cap', 'Path to save screenshots of the physical device.'
|
data/lib/mdq/db.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'mdq'
|
|
4
4
|
require 'active_record'
|
|
5
5
|
require 'fileutils'
|
|
6
|
+
require 'sql-parser'
|
|
6
7
|
|
|
7
8
|
# Mdq
|
|
8
9
|
module Mdq
|
|
@@ -30,8 +31,8 @@ module Mdq
|
|
|
30
31
|
# クエリの実行
|
|
31
32
|
def query(sql)
|
|
32
33
|
ActiveRecord::Base.connection.execute(sql)
|
|
33
|
-
rescue StandardError
|
|
34
|
-
|
|
34
|
+
rescue StandardError => e
|
|
35
|
+
raise e
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
# Androidデバイスのスクリーンショットを撮る
|
|
@@ -115,5 +116,31 @@ module Mdq
|
|
|
115
116
|
puts output unless output.empty?
|
|
116
117
|
warn error unless error.empty?
|
|
117
118
|
end
|
|
119
|
+
|
|
120
|
+
# クエリにappsテーブルが含まれているかを判定する
|
|
121
|
+
def query_contains_apps_table?(query)
|
|
122
|
+
parser = SQLParser::Parser.new
|
|
123
|
+
ast = parser.scan_str(query)
|
|
124
|
+
find_tables(ast).uniq.include?('apps')
|
|
125
|
+
rescue StandardError
|
|
126
|
+
false
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
private
|
|
130
|
+
|
|
131
|
+
def find_tables(node)
|
|
132
|
+
tables = []
|
|
133
|
+
if node.is_a?(SQLParser::Statement::Table)
|
|
134
|
+
tables << node.name
|
|
135
|
+
elsif node.respond_to?(:each)
|
|
136
|
+
node.each { |child| tables += find_tables(child) }
|
|
137
|
+
elsif node.instance_variables.any?
|
|
138
|
+
node.instance_variables.each do |var|
|
|
139
|
+
val = node.instance_variable_get(var)
|
|
140
|
+
tables += find_tables(val)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
tables
|
|
144
|
+
end
|
|
118
145
|
end
|
|
119
146
|
end
|
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.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- arthur87
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-06-
|
|
10
|
+
date: 2026-06-18 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rubocop
|
|
@@ -51,6 +51,20 @@ dependencies:
|
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: sql-parser
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
54
68
|
- !ruby/object:Gem::Dependency
|
|
55
69
|
name: thor
|
|
56
70
|
requirement: !ruby/object:Gem::Requirement
|