arql 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/arql/commands/models.rb +10 -6
- data/lib/arql/definition.rb +6 -2
- data/lib/arql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92f3117b0baa9b0c54cc683a73251094697b5e2fb8ed7cb329f37b43ad0bbe2e
|
4
|
+
data.tar.gz: 2b839cf6ec293f162faa2f29c7d7421679185c4874f1a4c826d13d4be26350a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07790dbd1bbff85f9fee6f86346967ecac0e70c0334255eb7041b475a41b7d569a01f40d0d2f8757de34362dcaaff839e31a27d13865f1f40f533ce409388fc
|
7
|
+
data.tar.gz: a82ae15b63a25e22e7a50e6a1a1dc8173dc5881c5c032851fe69e8639dcfc860d734a557f74dfce38868dac2dd86b2f9e2c94b8e487fa17271967b0eb56d6367
|
data/Gemfile.lock
CHANGED
data/lib/arql/commands/models.rb
CHANGED
@@ -5,25 +5,29 @@ module Arql::Commands
|
|
5
5
|
class << self
|
6
6
|
def models
|
7
7
|
t = []
|
8
|
-
t << ['Table Name', 'Model Class', 'Abbr']
|
8
|
+
t << ['Table Name', 'Model Class', 'Abbr', 'Comment']
|
9
9
|
t << nil
|
10
10
|
Arql::Definition.models.each do |definition|
|
11
|
-
t << [definition[:table], definition[:model].name, definition[:abbr] || '']
|
11
|
+
t << [definition[:table], definition[:model].name, definition[:abbr] || '', definition[:comment] || '']
|
12
12
|
end
|
13
13
|
t
|
14
14
|
end
|
15
15
|
|
16
|
-
def models_table
|
16
|
+
def models_table(regexp)
|
17
17
|
Terminal::Table.new do |t|
|
18
|
-
models.
|
18
|
+
models.each_with_index { |row, idx| t << (row || :separator) if row.nil? ||
|
19
|
+
regexp.nil? ||
|
20
|
+
idx.zero? ||
|
21
|
+
row.any? { |e| e =~ regexp }
|
22
|
+
}
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
Pry.commands.block_command 'm' do
|
28
|
+
Pry.commands.block_command 'm' do |regexp|
|
25
29
|
puts
|
26
|
-
puts Models::models_table
|
30
|
+
puts Models::models_table(regexp.try { |e| eval(e) })
|
27
31
|
end
|
28
32
|
|
29
33
|
Pry.commands.alias_command 'l', 'm'
|
data/lib/arql/definition.rb
CHANGED
@@ -83,6 +83,7 @@ module Arql
|
|
83
83
|
@@models = []
|
84
84
|
ActiveRecord::Base.connection.tap do |conn|
|
85
85
|
conn.tables.each do |table_name|
|
86
|
+
table_comment = conn.table_comment(table_name)
|
86
87
|
conn.primary_key(table_name).tap do |pkey|
|
87
88
|
table_name.camelize.tap do |const_name|
|
88
89
|
const_name = 'Modul' if const_name == 'Module'
|
@@ -115,7 +116,8 @@ module Arql
|
|
115
116
|
@@models << {
|
116
117
|
model: const,
|
117
118
|
abbr: abbr_const,
|
118
|
-
table: table_name
|
119
|
+
table: table_name,
|
120
|
+
comment: table_comment
|
119
121
|
}
|
120
122
|
end
|
121
123
|
end
|
@@ -135,6 +137,7 @@ module Arql
|
|
135
137
|
ActiveRecord::Base.connection.tap do |conn|
|
136
138
|
Object.const_set('ArqlModel', Class.new(ActiveRecord::Base) { self.abstract_class = true })
|
137
139
|
conn.tables.each do |table_name|
|
140
|
+
table_comment = conn.table_comment(table_name)
|
138
141
|
conn.primary_key(table_name).tap do |pkey|
|
139
142
|
table_name.camelize.tap do |const_name|
|
140
143
|
const_name = 'Modul' if const_name == 'Module'
|
@@ -167,7 +170,8 @@ module Arql
|
|
167
170
|
@@models << {
|
168
171
|
model: const,
|
169
172
|
abbr: abbr_const,
|
170
|
-
table: table_name
|
173
|
+
table: table_name,
|
174
|
+
comment: table_comment
|
171
175
|
}
|
172
176
|
end
|
173
177
|
end
|
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liu Xiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|