arql 0.1.17 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 811e8dae81062f4ea1204c7c4cebb854242814508548871ee71701e9edcdab75
4
- data.tar.gz: ee843b527ff37e365be55e56f8efc7665a134540a5039c8f802ad4338377bbcf
3
+ metadata.gz: 8f5c7a264d240ee1cac06ad0f79ebf578f877e5e151f7ab294c43f742ba110d2
4
+ data.tar.gz: 738eb831752775b5c55fa919e9a064eca8439e239a4b345aea36c3cbab9e0500
5
5
  SHA512:
6
- metadata.gz: 9f7f59f9b49504d801d07080e0b0ee53132efd057560398e186a34d5a2e1c67c31975616aa070fed0b9401c90c3a37a60a7a4537bf3bd74cd4ff10f5b50c9cbb
7
- data.tar.gz: 66ec1f0ba4a2c48ad3e89e145b063be6843edaf1c8e0bdd7412cacbd56d11f2bec4369b9d916dec8940211a1cdf74943e7ec0639484f89332f2b344bcada793d
6
+ metadata.gz: 3e6f61c3cf125f1cfa81be9737ed7aa54857651344916d10ba587580842d4985b4873fb6ae042cac917dbdfe73a0306e4ead523d4f99613e0786f377da10b228
7
+ data.tar.gz: 5c6ba812cde58dfb5ece38cbb89d369c078d4c06d42a48df55eba59a064eaeeae4de9a1273b3b0f882acc88130d0379d1800fa4f9cadd316cc8dc67683d0a75f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arql (0.1.17)
4
+ arql (0.1.21)
5
5
  activerecord (~> 6.0.3)
6
6
  activerecord-oracle_enhanced-adapter
7
7
  activerecord-sqlserver-adapter
data/README.md CHANGED
@@ -284,7 +284,7 @@ ARQL ❯ Person.all.to_a.to_insert_sql
284
284
 
285
285
  #### to_create_sql
286
286
 
287
- You can call `to_create_sql` on any ActiveRecord model clas to get create table SQL of the model class / table.
287
+ You can call `to_create_sql` on any ActiveRecord model class to get create table SQL of the model class / table.
288
288
 
289
289
  #### t
290
290
 
@@ -26,6 +26,9 @@ module Arql
26
26
  self.class.to_upsert_sql([self])
27
27
  end
28
28
 
29
+ included do
30
+ end
31
+
29
32
  class_methods do
30
33
  def t
31
34
  table_name = Commands::Table::get_table_name(name)
@@ -163,5 +166,15 @@ module Arql
163
166
  end
164
167
  end
165
168
  end
169
+
170
+ ::ActiveRecord::Relation.class_eval do
171
+ def t
172
+ records.t
173
+ end
174
+
175
+ def v
176
+ records.v
177
+ end
178
+ end
166
179
  end
167
180
  end
@@ -13,6 +13,31 @@ class Array
13
13
  end.join("\n")
14
14
  end
15
15
 
16
+ def t(*attrs)
17
+ if attrs.present? && present? && first.is_a?(ActiveRecord::Base)
18
+ puts Terminal::Table.new { |t|
19
+ t << attrs
20
+ t << :separator
21
+ each do |e|
22
+ t << e.attributes.values_at(*attrs.map(&:to_s))
23
+ end
24
+ }
25
+ else
26
+ table = Terminal::Table.new { |t|
27
+ v.each { |row| t << (row || :separator)}
28
+ }.to_s
29
+
30
+ terminal_width = `tput cols`.to_i
31
+ if table.lines.first.size > terminal_width
32
+ table = table.lines.map(&:chomp)
33
+ puts table[0..2].join("\n")
34
+ puts table[3..-1].join("\n#{'-' * terminal_width}\n")
35
+ else
36
+ puts table
37
+ end
38
+ end
39
+ end
40
+
16
41
  def v
17
42
  return self unless present?
18
43
  t = []
@@ -1,3 +1,3 @@
1
1
  module Arql
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.22"
3
3
  end
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.1.17
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2020-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -257,7 +257,7 @@ homepage: https://github.com/lululau/arql
257
257
  licenses:
258
258
  - MIT
259
259
  metadata: {}
260
- post_install_message:
260
+ post_install_message:
261
261
  rdoc_options: []
262
262
  require_paths:
263
263
  - lib
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  version: '0'
274
274
  requirements: []
275
275
  rubygems_version: 3.1.2
276
- signing_key:
276
+ signing_key:
277
277
  specification_version: 4
278
278
  summary: Rails ActiveRecord + Pry is the best SQL query editor
279
279
  test_files: []