arql 0.1.26 → 0.1.31
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/app.rb +28 -6
- data/lib/arql/cli.rb +1 -4
- data/lib/arql/repl.rb +1 -1
- data/lib/arql/ssh_proxy.rb +1 -1
- 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: 720e28d1a714ac8e3d116c6f63ef734476895b28502df43a486a9f7f4348430f
|
4
|
+
data.tar.gz: 654c7011a05dc8631c418504953def7870d33d2fa22922fb3292992e8dbe6ff4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f9271ae382fa37b7ec06907d17a17b47129390f4f0f144aff1b0cf4bbb8ee9bad7fda54cf5afb8d4029d3b02f92725de51968a345367c06c2298eef54c91a6
|
7
|
+
data.tar.gz: 72cbb2b5895da48dcb93b252d43882b6f6005cbe1638d284135e61404fee9a0e96f0ce0db3d585a3b23b2fa256381b37ee05f5abec4072e8af4c452f61608747
|
data/Gemfile.lock
CHANGED
data/lib/arql/app.rb
CHANGED
@@ -4,11 +4,19 @@ module Arql
|
|
4
4
|
class App
|
5
5
|
|
6
6
|
class << self
|
7
|
-
attr_accessor :log_io
|
7
|
+
attr_accessor :log_io, :env, :prompt
|
8
8
|
|
9
9
|
def config
|
10
10
|
@@effective_config
|
11
11
|
end
|
12
|
+
|
13
|
+
def prompt
|
14
|
+
if env
|
15
|
+
env
|
16
|
+
else
|
17
|
+
File.basename(@@effective_config[:database])
|
18
|
+
end
|
19
|
+
end
|
12
20
|
end
|
13
21
|
|
14
22
|
def initialize(options)
|
@@ -17,6 +25,7 @@ module Arql
|
|
17
25
|
require "arql/connection"
|
18
26
|
require "arql/definition"
|
19
27
|
@options = options
|
28
|
+
App.env = @options.env
|
20
29
|
Connection.open(connect_options)
|
21
30
|
@definition = Definition.new(effective_config)
|
22
31
|
load_initializer!
|
@@ -35,11 +44,12 @@ module Arql
|
|
35
44
|
|
36
45
|
def load_initializer!
|
37
46
|
return unless effective_config[:initializer]
|
38
|
-
|
47
|
+
initializer_file = File.expand_path(effective_config[:initializer])
|
48
|
+
unless File.exists?(initializer_file)
|
39
49
|
STDERR.puts "Specified initializer file not found, #{effective_config[:initializer]}"
|
40
50
|
exit(1)
|
41
51
|
end
|
42
|
-
load(
|
52
|
+
load(initializer_file)
|
43
53
|
end
|
44
54
|
|
45
55
|
def start_ssh_proxy!
|
@@ -55,18 +65,30 @@ module Arql
|
|
55
65
|
end
|
56
66
|
|
57
67
|
def config
|
58
|
-
@config ||= YAML.load(IO.read(@options.config_file)).with_indifferent_access
|
68
|
+
@config ||= YAML.load(IO.read(File.expand_path(@options.config_file))).with_indifferent_access
|
59
69
|
end
|
60
70
|
|
61
71
|
def selected_config
|
62
72
|
if @options.env.present? && !config[@options.env].present?
|
63
73
|
STDERR.puts "Specified ENV `#{@options.env}' not exists"
|
64
74
|
end
|
65
|
-
|
75
|
+
if env = @options.env
|
76
|
+
config[env]
|
77
|
+
else
|
78
|
+
{}
|
79
|
+
end
|
66
80
|
end
|
67
81
|
|
68
82
|
def effective_config
|
69
|
-
@@effective_config ||=
|
83
|
+
@@effective_config ||= nil
|
84
|
+
unless @@effective_config
|
85
|
+
@@effective_config = selected_config.deep_merge(@options.to_h)
|
86
|
+
if @@effective_config[:adapter].blank?
|
87
|
+
@@effective_config[:adapter] = 'sqlite3'
|
88
|
+
end
|
89
|
+
@@effective_config[:database] = File.expand_path(@@effective_config[:database]) if @@effective_config[:adapter] == 'sqlite3'
|
90
|
+
end
|
91
|
+
@@effective_config
|
70
92
|
end
|
71
93
|
|
72
94
|
def run!
|
data/lib/arql/cli.rb
CHANGED
@@ -10,10 +10,7 @@ module Arql
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def parse_options!
|
13
|
-
@options = OpenStruct.new(
|
14
|
-
encoding: 'utf8',
|
15
|
-
pool: 5,
|
16
|
-
config_file: default_config_file,
|
13
|
+
@options = OpenStruct.new(config_file: default_config_file,
|
17
14
|
initializer: default_initializer,
|
18
15
|
ssh: {})
|
19
16
|
|
data/lib/arql/repl.rb
CHANGED
@@ -31,7 +31,7 @@ module Arql
|
|
31
31
|
else
|
32
32
|
nest_level_prompt = "(#{obj}:#{nest_level})"
|
33
33
|
end
|
34
|
-
"%s#{nest_level_prompt} %s " % [Rainbow('ARQL').red, Rainbow('❯').green]
|
34
|
+
"%s#{Rainbow('@').green}%s#{nest_level_prompt} %s " % [Rainbow('ARQL').red, Rainbow(App.prompt).yellow, Rainbow('❯').green]
|
35
35
|
end]
|
36
36
|
end
|
37
37
|
end
|
data/lib/arql/ssh_proxy.rb
CHANGED
@@ -9,7 +9,7 @@ module Arql
|
|
9
9
|
|
10
10
|
def connect(config)
|
11
11
|
@config = config
|
12
|
-
@ssh_gateway = Net::SSH::Gateway.new(config[:host], config[:user], config.slice(:port, :password).symbolize_keys.merge(keepalive: true, keepalive_interval: 30))
|
12
|
+
@ssh_gateway = Net::SSH::Gateway.new(config[:host], config[:user], config.slice(:port, :password).symbolize_keys.merge(keepalive: true, keepalive_interval: 30, loop_wait: 1))
|
13
13
|
@local_ssh_proxy_port = @ssh_gateway.open(config[:forward_host], config[:forward_port], config[:local_port])
|
14
14
|
end
|
15
15
|
|
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.31
|
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-07-
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|