arql 0.1.20 → 0.1.25
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 -10
- data/arql.gemspec +3 -3
- data/lib/arql.rb +1 -0
- data/lib/arql/app.rb +5 -7
- data/lib/arql/commands/info.rb +16 -1
- data/lib/arql/commands/reconnect.rb +10 -0
- data/lib/arql/definition.rb +13 -0
- data/lib/arql/ext/array.rb +1 -1
- data/lib/arql/ext/time.rb +1 -1
- data/lib/arql/ssh_proxy.rb +30 -0
- data/lib/arql/version.rb +1 -1
- metadata +3 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5129e08083a8abbbed19d1fc8e37d6c1cb5ec82116eb4915574ccf51fbab4604
|
4
|
+
data.tar.gz: 1743d1604a65793c6e36fa85ba1b6cc967a1b626bc2e0c6fb5e66611a9cec6d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bacfc17e2ddeb7791d6985a990fef8e1eec38a20f4073d6b2b878f0cbeacbcf1fd75b6e326b178d6c7767034810af11720bd1b6324bd5b22c817ee1d60cb79fe
|
7
|
+
data.tar.gz: c35ad64535fcd18840882ab2c415a68a6899db0227ed47a490560548972f2b5a1cb0533842f1d4f6714ce7b37e3c1b6605dbfb34a48090dc6cb12aca76af46bd
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
arql (0.1.
|
4
|
+
arql (0.1.25)
|
5
5
|
activerecord (~> 6.0.3)
|
6
|
-
activerecord-oracle_enhanced-adapter
|
7
|
-
activerecord-sqlserver-adapter
|
8
6
|
activesupport (~> 6.0.3)
|
9
7
|
mysql2 (~> 0.5.3)
|
10
8
|
net-ssh-gateway (~> 2.0.0)
|
11
|
-
pg (>= 0.18, < 2.0)
|
12
9
|
pry (~> 0.13.1)
|
13
10
|
pry-byebug (~> 3.9.0)
|
14
11
|
pry-doc (~> 1.1.0)
|
@@ -25,10 +22,6 @@ GEM
|
|
25
22
|
activerecord (6.0.3.1)
|
26
23
|
activemodel (= 6.0.3.1)
|
27
24
|
activesupport (= 6.0.3.1)
|
28
|
-
activerecord-oracle_enhanced-adapter (6.0.2)
|
29
|
-
activerecord (~> 6.0.0)
|
30
|
-
ruby-plsql (>= 0.6.0)
|
31
|
-
activerecord-sqlserver-adapter (2.3.8)
|
32
25
|
activesupport (6.0.3.1)
|
33
26
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
34
27
|
i18n (>= 0.7, < 2)
|
@@ -46,7 +39,6 @@ GEM
|
|
46
39
|
net-ssh (6.0.2)
|
47
40
|
net-ssh-gateway (2.0.0)
|
48
41
|
net-ssh (>= 4.0.0)
|
49
|
-
pg (1.2.3)
|
50
42
|
pry (0.13.1)
|
51
43
|
coderay (~> 1.1)
|
52
44
|
method_source (~> 1.0)
|
@@ -58,7 +50,6 @@ GEM
|
|
58
50
|
yard (~> 0.9.11)
|
59
51
|
rainbow (3.0.0)
|
60
52
|
rake (12.3.3)
|
61
|
-
ruby-plsql (0.7.1)
|
62
53
|
sqlite3 (1.4.2)
|
63
54
|
table_print (1.5.6)
|
64
55
|
terminal-table (1.8.0)
|
data/arql.gemspec
CHANGED
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
26
|
spec.add_dependency 'mysql2', '~> 0.5.3'
|
27
|
-
spec.add_dependency 'pg', '>= 0.18', '< 2.0'
|
27
|
+
# spec.add_dependency 'pg', '>= 0.18', '< 2.0'
|
28
28
|
spec.add_dependency 'sqlite3', '~> 1.4'
|
29
|
-
spec.add_dependency 'activerecord-sqlserver-adapter'
|
30
|
-
spec.add_dependency 'activerecord-oracle_enhanced-adapter'
|
29
|
+
# spec.add_dependency 'activerecord-sqlserver-adapter'
|
30
|
+
# spec.add_dependency 'activerecord-oracle_enhanced-adapter'
|
31
31
|
spec.add_dependency 'activerecord', '~> 6.0.3'
|
32
32
|
spec.add_dependency 'activesupport', '~> 6.0.3'
|
33
33
|
spec.add_dependency 'net-ssh-gateway', '~> 2.0.0'
|
data/lib/arql.rb
CHANGED
data/lib/arql/app.rb
CHANGED
@@ -9,10 +9,6 @@ module Arql
|
|
9
9
|
def config
|
10
10
|
@@effective_config
|
11
11
|
end
|
12
|
-
|
13
|
-
def local_ssh_proxy_port
|
14
|
-
@@local_ssh_proxy_port
|
15
|
-
end
|
16
12
|
end
|
17
13
|
|
18
14
|
def initialize(options)
|
@@ -48,11 +44,13 @@ module Arql
|
|
48
44
|
|
49
45
|
def start_ssh_proxy!
|
50
46
|
ssh_config = effective_config[:ssh]
|
51
|
-
|
52
|
-
|
47
|
+
local_ssh_proxy_port = Arql::SSHProxy.connect(ssh_config.slice(:host, :user, :port, :password).merge(
|
48
|
+
forward_host: effective_config[:host],
|
49
|
+
forward_port: effective_config[:port],
|
50
|
+
local_port: ssh_config[:local_port]))
|
53
51
|
{
|
54
52
|
host: '127.0.0.1',
|
55
|
-
port:
|
53
|
+
port: local_ssh_proxy_port
|
56
54
|
}
|
57
55
|
end
|
58
56
|
|
data/lib/arql/commands/info.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rainbow'
|
2
|
+
|
1
3
|
module Arql::Commands
|
2
4
|
module Info
|
3
5
|
class << self
|
@@ -5,6 +7,8 @@ module Arql::Commands
|
|
5
7
|
<<~EOF
|
6
8
|
|
7
9
|
Database Connection Information:
|
10
|
+
|
11
|
+
Active: #{color_boolean(ActiveRecord::Base.connection.active?)}
|
8
12
|
Host: #{Arql::App.config[:host]}
|
9
13
|
Port: #{Arql::App.config[:port]}
|
10
14
|
Username: #{Arql::App.config[:username]}
|
@@ -20,13 +24,24 @@ module Arql::Commands
|
|
20
24
|
<<~EOF
|
21
25
|
|
22
26
|
SSH Connection Information:
|
27
|
+
|
28
|
+
Active: #{color_boolean(Arql::SSHProxy.active?)}
|
23
29
|
Host: #{Arql::App.config[:ssh][:host]}
|
24
30
|
Port: #{Arql::App.config[:ssh][:port]}
|
25
31
|
Username: #{Arql::App.config[:ssh][:user]}
|
26
32
|
Password: #{(Arql::App.config[:ssh][:password] || '').gsub(/./, '*')}
|
27
|
-
Local Port: #{Arql::
|
33
|
+
Local Port: #{Arql::SSHProxy.local_ssh_proxy_port}
|
28
34
|
EOF
|
29
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def color_boolean(bool)
|
39
|
+
if bool
|
40
|
+
Rainbow('TRUE').green
|
41
|
+
else
|
42
|
+
Rainbow('FALSE').red
|
43
|
+
end
|
44
|
+
end
|
30
45
|
end
|
31
46
|
|
32
47
|
Pry.commands.block_command 'info' do
|
@@ -2,6 +2,12 @@ module Arql::Commands
|
|
2
2
|
module Reconnect
|
3
3
|
class << self
|
4
4
|
def reconnect
|
5
|
+
Arql::SSHProxy.reconnect if Arql::App.config[:ssh].present?
|
6
|
+
ActiveRecord::Base.connection.reconnect! unless ActiveRecord::Base.connection.active?
|
7
|
+
end
|
8
|
+
|
9
|
+
def reconnect!
|
10
|
+
Arql::SSHProxy.reconnect! if Arql::App.config[:ssh].present?
|
5
11
|
ActiveRecord::Base.connection.reconnect!
|
6
12
|
end
|
7
13
|
end
|
@@ -9,5 +15,9 @@ module Arql::Commands
|
|
9
15
|
Pry.commands.block_command 'reconnect' do
|
10
16
|
Reconnect.reconnect
|
11
17
|
end
|
18
|
+
|
19
|
+
Pry.commands.block_command 'reconnect!' do
|
20
|
+
Reconnect.reconnect!
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
data/lib/arql/definition.rb
CHANGED
@@ -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
|
data/lib/arql/ext/array.rb
CHANGED
@@ -28,7 +28,7 @@ class Array
|
|
28
28
|
}.to_s
|
29
29
|
|
30
30
|
terminal_width = `tput cols`.to_i
|
31
|
-
if table.first.size > terminal_width
|
31
|
+
if table.lines.first.size > terminal_width
|
32
32
|
table = table.lines.map(&:chomp)
|
33
33
|
puts table[0..2].join("\n")
|
34
34
|
puts table[3..-1].join("\n#{'-' * terminal_width}\n")
|
data/lib/arql/ext/time.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'net/ssh/gateway'
|
2
|
+
|
3
|
+
module Arql
|
4
|
+
class SSHProxy
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_accessor :config, :ssh_gateway, :local_ssh_proxy_port
|
8
|
+
|
9
|
+
def connect(config)
|
10
|
+
@config = config
|
11
|
+
@ssh_gateway = Net::SSH::Gateway.new(config[:host], config[:user], config.slice(:port, :password).symbolize_keys.merge(keepalive: true, keepalive_interval: 30))
|
12
|
+
@local_ssh_proxy_port = @ssh_gateway.open(config[:forward_host], config[:forward_port], config[:local_port])
|
13
|
+
end
|
14
|
+
|
15
|
+
def reconnect
|
16
|
+
reconnect! unless @ssh_gateway.active?
|
17
|
+
end
|
18
|
+
|
19
|
+
def reconnect!
|
20
|
+
@ssh_gateway.shutdown!
|
21
|
+
@ssh_gateway = Net::SSH::Gateway.new(@config[:host], @config[:user], @config.slice(:port, :password).symbolize_keys)
|
22
|
+
@ssh_gateway.open(config[:forward_host], config[:forward_port], @local_ssh_proxy_port)
|
23
|
+
end
|
24
|
+
|
25
|
+
def active?
|
26
|
+
@ssh_gateway.active?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
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.1.
|
4
|
+
version: 0.1.25
|
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-
|
11
|
+
date: 2020-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
@@ -24,26 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.5.3
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: pg
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.18'
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '2.0'
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0.18'
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '2.0'
|
47
27
|
- !ruby/object:Gem::Dependency
|
48
28
|
name: sqlite3
|
49
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,34 +38,6 @@ dependencies:
|
|
58
38
|
- - "~>"
|
59
39
|
- !ruby/object:Gem::Version
|
60
40
|
version: '1.4'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: activerecord-sqlserver-adapter
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
|
-
type: :runtime
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: activerecord-oracle_enhanced-adapter
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :runtime
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
41
|
- !ruby/object:Gem::Dependency
|
90
42
|
name: activerecord
|
91
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -252,6 +204,7 @@ files:
|
|
252
204
|
- lib/arql/id.rb
|
253
205
|
- lib/arql/multi_io.rb
|
254
206
|
- lib/arql/repl.rb
|
207
|
+
- lib/arql/ssh_proxy.rb
|
255
208
|
- lib/arql/version.rb
|
256
209
|
homepage: https://github.com/lululau/arql
|
257
210
|
licenses:
|