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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ed88946e69a6690211fae5d85975ee9674f67cf865cbd8cc472f91cb053f5e6
4
- data.tar.gz: 44d68d0a13e023c5c69402f92a07fe356fd234a73ba3664becfc17c916c95815
3
+ metadata.gz: 720e28d1a714ac8e3d116c6f63ef734476895b28502df43a486a9f7f4348430f
4
+ data.tar.gz: 654c7011a05dc8631c418504953def7870d33d2fa22922fb3292992e8dbe6ff4
5
5
  SHA512:
6
- metadata.gz: 25a93383de5e12ec51a1b7986aeec653b0d7c54c75863deff606487ac4a07ee0baec5b52d56f9562900d91e74f14e964ee0d52662b45a02236cc9cb5ca2c9aa6
7
- data.tar.gz: 5fafcbe5ed60878e8614cacff2147eb0d29c58e39a30e4ca85e8c2d6d74d7ee2b70fabee880f275a3ae8194df5aa6d3c857396b3930ecb36d1f84087f348f1cd
6
+ metadata.gz: a5f9271ae382fa37b7ec06907d17a17b47129390f4f0f144aff1b0cf4bbb8ee9bad7fda54cf5afb8d4029d3b02f92725de51968a345367c06c2298eef54c91a6
7
+ data.tar.gz: 72cbb2b5895da48dcb93b252d43882b6f6005cbe1638d284135e61404fee9a0e96f0ce0db3d585a3b23b2fa256381b37ee05f5abec4072e8af4c452f61608747
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arql (0.1.26)
4
+ arql (0.1.31)
5
5
  activerecord (~> 6.0.3)
6
6
  activesupport (~> 6.0.3)
7
7
  mysql2 (~> 0.5.3)
@@ -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
- unless File.exists?(effective_config[:initializer])
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(effective_config[:initializer])
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
- config[@options.env]
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 ||= selected_config.deep_merge(@options.to_h)
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!
@@ -10,10 +10,7 @@ module Arql
10
10
  end
11
11
 
12
12
  def parse_options!
13
- @options = OpenStruct.new(adapter: 'mysql2',
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
 
@@ -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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Arql
2
- VERSION = "0.1.26"
2
+ VERSION = "0.1.31"
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.26
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-02 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2