arql 0.3.21 → 0.3.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/arql.gemspec +1 -1
- data/lib/arql/definition.rb +9 -4
- data/lib/arql/ext/array.rb +17 -6
- data/lib/arql/ext/hash.rb +1 -1
- data/lib/arql/ext.rb +1 -0
- data/lib/arql/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4178a1d360f59152ce5fac37b745a98a77ac744090114b6c9d70e89ec4dfe57
|
4
|
+
data.tar.gz: 46520be1d1411eb164160d7e42d81012f5147272014556b6825e3cd122ed483c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 377195d8ebfe1a1a1c5c0eac7d31533171bb95452eee33c2a74048b6d620e565d9ac804d821f1a9201ad803448717e20f50ad7e079065273e866e155535bae99
|
7
|
+
data.tar.gz: 3c2a29b255032fc6efc7dc109a557e3e9dc2d8145854fa1d514d9b14551278424b95b81fd6f02d59cfff33a6fa66ae21e1d6cde1a7f408f9ba784189b13d7626
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
arql (0.3.
|
4
|
+
arql (0.3.22)
|
5
5
|
activerecord (>= 6.1.5, < 7.1.0)
|
6
6
|
activesupport (>= 6.1.5, < 7.1.0)
|
7
7
|
caxlsx (~> 3.3.0)
|
@@ -11,7 +11,7 @@ PATH
|
|
11
11
|
net-ssh-gateway (~> 2.0.0)
|
12
12
|
pry (~> 0.14.1)
|
13
13
|
pry-byebug (~> 3.10.1)
|
14
|
-
pry-doc (>= 1.
|
14
|
+
pry-doc (>= 1.4.0)
|
15
15
|
rainbow (~> 3.0.0)
|
16
16
|
ransack (>= 3.2.1)
|
17
17
|
roo (~> 2.9.0)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
pry-byebug (3.10.1)
|
68
68
|
byebug (~> 11.0)
|
69
69
|
pry (>= 0.13, < 0.15)
|
70
|
-
pry-doc (1.
|
70
|
+
pry-doc (1.4.0)
|
71
71
|
pry (~> 0.11)
|
72
72
|
yard (~> 0.9.11)
|
73
73
|
racc (1.6.2)
|
data/arql.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency 'net-ssh-gateway', '~> 2.0.0'
|
36
36
|
spec.add_dependency 'pry', '~> 0.14.1'
|
37
37
|
spec.add_dependency 'pry-byebug', '~> 3.10.1'
|
38
|
-
spec.add_dependency 'pry-doc', '>= 1.
|
38
|
+
spec.add_dependency 'pry-doc', '>= 1.4.0'
|
39
39
|
spec.add_dependency 'rainbow', '~> 3.0.0'
|
40
40
|
spec.add_dependency 'terminal-table', '~> 1.8.0'
|
41
41
|
spec.add_dependency 'table_print', '~> 1.5.6'
|
data/lib/arql/definition.rb
CHANGED
@@ -5,9 +5,9 @@ module Arql
|
|
5
5
|
module Extension
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
-
def t
|
8
|
+
def t(**options)
|
9
9
|
puts Terminal::Table.new { |t|
|
10
|
-
v.each { |row| t << (row || :separator) }
|
10
|
+
v(**options).each { |row| t << (row || :separator) }
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
@@ -20,12 +20,17 @@ module Arql
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def v
|
23
|
+
def v(**options)
|
24
24
|
t = []
|
25
25
|
t << ['Attribute Name', 'Attribute Value', 'SQL Type', 'Comment']
|
26
26
|
t << nil
|
27
|
+
compact_mode = options[:compact] || false
|
27
28
|
self.class.connection.columns(self.class.table_name).each do |column|
|
28
|
-
|
29
|
+
value = read_attribute(column.name)
|
30
|
+
if compact_mode && value.blank?
|
31
|
+
next
|
32
|
+
end
|
33
|
+
t << [column.name, value, column.sql_type, column.comment || '']
|
29
34
|
end
|
30
35
|
t
|
31
36
|
end
|
data/lib/arql/ext/array.rb
CHANGED
@@ -27,6 +27,9 @@ class Array
|
|
27
27
|
attrs -= [options[:except]].flatten
|
28
28
|
end
|
29
29
|
end
|
30
|
+
# if options[:compact]
|
31
|
+
# attrs = attrs.select { |e| any { |r| r.attributes[e.to_s]&.present? } }
|
32
|
+
# end
|
30
33
|
puts Terminal::Table.new { |t|
|
31
34
|
t << attrs
|
32
35
|
t << :separator
|
@@ -36,7 +39,7 @@ class Array
|
|
36
39
|
}
|
37
40
|
else
|
38
41
|
table = Terminal::Table.new { |t|
|
39
|
-
v.each { |row| t << (row || :separator)}
|
42
|
+
v(**options).each { |row| t << (row || :separator)}
|
40
43
|
}.to_s
|
41
44
|
|
42
45
|
terminal_width = `tput cols`.to_i
|
@@ -77,23 +80,31 @@ class Array
|
|
77
80
|
nil
|
78
81
|
end
|
79
82
|
|
80
|
-
def v
|
83
|
+
def v(**options)
|
81
84
|
return self unless present?
|
82
85
|
t = []
|
83
86
|
if map(&:class).uniq.size == 1
|
84
87
|
if first.is_a?(ActiveRecord::Base)
|
85
|
-
|
88
|
+
attribute_names = first.attribute_names
|
89
|
+
if options[:compact]
|
90
|
+
attribute_names = attribute_names.select { |e| any? { |r| r.attributes[e]&.present? } }
|
91
|
+
end
|
92
|
+
t << attribute_names
|
86
93
|
t << nil
|
87
94
|
each do |e|
|
88
|
-
t << e.attributes.values_at(*
|
95
|
+
t << e.attributes.values_at(*attribute_names).map(&:as_json)
|
89
96
|
end
|
90
97
|
elsif first.is_a?(Array)
|
91
98
|
t = map { |a| a.map(&:as_json) }
|
92
99
|
elsif first.is_a?(Hash) || first.is_a?(ActiveSupport::HashWithIndifferentAccess)
|
93
|
-
|
100
|
+
keys = first.keys
|
101
|
+
if options[:compact]
|
102
|
+
keys = keys.select { |e| any? { |r| r[e]&.present? } }
|
103
|
+
end
|
104
|
+
t << keys
|
94
105
|
t << nil
|
95
106
|
each do |e|
|
96
|
-
t << e.values_at(*
|
107
|
+
t << e.values_at(*keys).map(&:as_json)
|
97
108
|
end
|
98
109
|
else
|
99
110
|
return self
|
data/lib/arql/ext/hash.rb
CHANGED
@@ -12,7 +12,7 @@ class Hash
|
|
12
12
|
end
|
13
13
|
|
14
14
|
if sheet_data.is_a?(Array)
|
15
|
-
if sheet_data.size > 0 && sheet_data.first.is_a?(
|
15
|
+
if sheet_data.size > 0 && sheet_data.first.is_a?(ActiveRecord::Base)
|
16
16
|
fields = sheet_data.first.attributes.keys
|
17
17
|
sheet.add_row(fields, types: [:string] * fields.size)
|
18
18
|
sheet_data.each do |row|
|
data/lib/arql/ext.rb
CHANGED
data/lib/arql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liu Xiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
@@ -154,14 +154,14 @@ dependencies:
|
|
154
154
|
requirements:
|
155
155
|
- - ">="
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 1.
|
157
|
+
version: 1.4.0
|
158
158
|
type: :runtime
|
159
159
|
prerelease: false
|
160
160
|
version_requirements: !ruby/object:Gem::Requirement
|
161
161
|
requirements:
|
162
162
|
- - ">="
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version: 1.
|
164
|
+
version: 1.4.0
|
165
165
|
- !ruby/object:Gem::Dependency
|
166
166
|
name: rainbow
|
167
167
|
requirement: !ruby/object:Gem::Requirement
|