arql 0.1.23 → 0.1.28

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: ebb803df936a94d7bb9599aff2dd0db0b625a576e6736799fb50c89d3402808e
4
- data.tar.gz: 72e84b31307d1bb6d0dad35eeb96702debb55a54a7db0f5a007cd0edd1bf0d28
3
+ metadata.gz: a60cf3e7b24cf3967d9e566fbb89011ce12b727bd6ef9f4e6e7b83aa2ef58bfc
4
+ data.tar.gz: 06152be12dff3594db513cbca09e8f53d0250d634d05b4a4bf1e1532c593097a
5
5
  SHA512:
6
- metadata.gz: a7e4905293900ad7e515c35fd8b96a16357dedd940d2f65473a5a087e84444585d335e9922225a87156a453c7eff439cf015b9fbaed318ae8a9c80018dd99350
7
- data.tar.gz: 69871e396b27eb0b9ceca1f5d3f66aef292d8eb82154018da720878373d95b5554971f5c492327d445bd5762fa1c118d299d9cacda3a163c8d75e94072cf4ddd
6
+ metadata.gz: b2a3f77a0119b6188437187fb23bc8da4d0129f038d325b2112dcc67eb4621484bed0c3cef28bcad6f7d2eb35957c3977ad923cdef667108b2ecfc15a4030296
7
+ data.tar.gz: 309d4f09b2b475625e006a66faea1cef2473368bab41933188de5f47cc75bd2b6a9ee47a6c86fa3096f84e118c1cce402be18b65605bf76564dee123c092364f
@@ -1,14 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arql (0.1.22)
4
+ arql (0.1.28)
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)
@@ -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/exe/arql CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ ArqlSetsidWrrapper = File.dirname(File.absolute_path(__FILE__)) + '/arql_setsid_wrapper'
4
+
3
5
  require "arql"
4
6
 
5
7
  Arql::Cli.start
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Process.setsid
4
+
5
+ exec(*ARGV)
@@ -4,7 +4,7 @@ module Arql
4
4
  class App
5
5
 
6
6
  class << self
7
- attr_accessor :log_io
7
+ attr_accessor :log_io, :env
8
8
 
9
9
  def config
10
10
  @@effective_config
@@ -17,6 +17,7 @@ module Arql
17
17
  require "arql/connection"
18
18
  require "arql/definition"
19
19
  @options = options
20
+ App.env = @options.env
20
21
  Connection.open(connect_options)
21
22
  @definition = Definition.new(effective_config)
22
23
  load_initializer!
@@ -2,12 +2,12 @@ module Arql::Commands
2
2
  module Reconnect
3
3
  class << self
4
4
  def reconnect
5
- Arql::SSHProxy.reconnect
5
+ Arql::SSHProxy.reconnect if Arql::App.config[:ssh].present?
6
6
  ActiveRecord::Base.connection.reconnect! unless ActiveRecord::Base.connection.active?
7
7
  end
8
8
 
9
9
  def reconnect!
10
- Arql::SSHProxy.reconnect!
10
+ Arql::SSHProxy.reconnect! if Arql::App.config[:ssh].present?
11
11
  ActiveRecord::Base.connection.reconnect!
12
12
  end
13
13
  end
@@ -9,7 +9,7 @@ class Time
9
9
  to_s
10
10
  end
11
11
 
12
- def as_json
12
+ def as_json(*args)
13
13
  to_s
14
14
  end
15
15
  end
@@ -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.env).yellow, Rainbow('❯').green]
35
35
  end]
36
36
  end
37
37
  end
@@ -1,4 +1,5 @@
1
1
  require 'net/ssh/gateway'
2
+ require 'arql/ssh_proxy_patch'
2
3
 
3
4
  module Arql
4
5
  class SSHProxy
@@ -8,7 +9,7 @@ module Arql
8
9
 
9
10
  def connect(config)
10
11
  @config = config
11
- @ssh_gateway = Net::SSH::Gateway.new(config[:host], config[:user], config.slice(:port, :password).symbolize_keys)
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))
12
13
  @local_ssh_proxy_port = @ssh_gateway.open(config[:forward_host], config[:forward_port], config[:local_port])
13
14
  end
14
15
 
@@ -0,0 +1,88 @@
1
+ require 'net/ssh/proxy/command'
2
+
3
+ module Net
4
+ module SSH
5
+ module Proxy
6
+ class Command
7
+
8
+ # Return a new socket connected to the given host and port via the
9
+ # proxy that was requested when the socket factory was instantiated.
10
+ def open(host, port, connection_options = nil)
11
+ command_line = @command_line_template.gsub(/%(.)/) {
12
+ case $1
13
+ when 'h'
14
+ host
15
+ when 'p'
16
+ port.to_s
17
+ when 'r'
18
+ remote_user = connection_options && connection_options[:remote_user]
19
+ if remote_user
20
+ remote_user
21
+ else
22
+ raise ArgumentError, "remote user name not available"
23
+ end
24
+ when '%'
25
+ '%'
26
+ else
27
+ raise ArgumentError, "unknown key: #{$1}"
28
+ end
29
+ }
30
+ command_line = '%s %s' % [ArqlSetsidWrrapper, command_line]
31
+ begin
32
+ io = IO.popen(command_line, "r+")
33
+ begin
34
+ if result = IO.select([io], nil, [io], @timeout)
35
+ if result.last.any? || io.eof?
36
+ raise "command failed"
37
+ end
38
+ else
39
+ raise "command timed out"
40
+ end
41
+ rescue StandardError
42
+ close_on_error(io)
43
+ raise
44
+ end
45
+ rescue StandardError => e
46
+ raise ConnectError, "#{e}: #{command_line}"
47
+ end
48
+ @command_line = command_line
49
+ if Gem.win_platform?
50
+ # read_nonblock and write_nonblock are not available on Windows
51
+ # pipe. Use sysread and syswrite as a replacement works.
52
+ def io.send(data, flag)
53
+ syswrite(data)
54
+ end
55
+
56
+ def io.recv(size)
57
+ sysread(size)
58
+ end
59
+ else
60
+ def io.send(data, flag)
61
+ begin
62
+ result = write_nonblock(data)
63
+ rescue IO::WaitWritable, Errno::EINTR
64
+ IO.select(nil, [self])
65
+ retry
66
+ end
67
+ result
68
+ end
69
+
70
+ def io.recv(size)
71
+ begin
72
+ result = read_nonblock(size)
73
+ rescue IO::WaitReadable, Errno::EINTR
74
+ timeout_in_seconds = 20
75
+ if IO.select([self], nil, [self], timeout_in_seconds) == nil
76
+ raise "Unexpected spurious read wakeup"
77
+ end
78
+ retry
79
+ end
80
+ result
81
+ end
82
+ end
83
+ io
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,3 +1,3 @@
1
1
  module Arql
2
- VERSION = "0.1.23"
2
+ VERSION = "0.1.28"
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.23
4
+ version: 0.1.28
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-06-22 00:00:00.000000000 Z
11
+ date: 2020-07-06 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
@@ -217,6 +169,7 @@ email:
217
169
  - liuxiang921@gmail.com
218
170
  executables:
219
171
  - arql
172
+ - arql_setsid_wrapper
220
173
  extensions: []
221
174
  extra_rdoc_files: []
222
175
  files:
@@ -231,6 +184,7 @@ files:
231
184
  - bin/console
232
185
  - bin/setup
233
186
  - exe/arql
187
+ - exe/arql_setsid_wrapper
234
188
  - lib/arql.rb
235
189
  - lib/arql/app.rb
236
190
  - lib/arql/cli.rb
@@ -253,6 +207,7 @@ files:
253
207
  - lib/arql/multi_io.rb
254
208
  - lib/arql/repl.rb
255
209
  - lib/arql/ssh_proxy.rb
210
+ - lib/arql/ssh_proxy_patch.rb
256
211
  - lib/arql/version.rb
257
212
  homepage: https://github.com/lululau/arql
258
213
  licenses: