arql 0.3.3 → 0.3.5

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: 9d10b12fd753e5e8970108008da89ed6dc25b0fd0a920e5a4d4ca52e1bfeed41
4
- data.tar.gz: 0b47045c868b4897b0fd0f4efbb59bc66257f572b04295f3d25a90fe3f633f0d
3
+ metadata.gz: 754f0123178d350470df65a3b627f3ae3890a3de7668d8422429d661e1d271cf
4
+ data.tar.gz: 5d8241b6d7ba7fca92cd3a645138276fc2c3b0c8fb7658ba514f16794f63e26a
5
5
  SHA512:
6
- metadata.gz: 5e7833f356b11d0b3840f5afddb4a6582173b67e4033a428cdb82c7933648921c090922a1168e01b4675d4cf49c4011de4b78bfe27cb0f93a98934527676538d
7
- data.tar.gz: b198b84d7b3cd9767bfb5f7a55f57e5bbed39a387fa080536c7c9ccfc65db16efa3d8b5bac51cb1d0801d04c14e102b723bd871f6ddff9872b27e62fedb1dd9b
6
+ metadata.gz: 85e3b47d182b593b9a34055141192073844d257d96fbd2319e83eb3b0444c3f747fcc460819a1f8d7b51110487f00afa27c61f8ef280d49724390123c8d759f1
7
+ data.tar.gz: a5c8898c8384a7ed8685fe0ce758f797cbb530c627e116ad58610b854496d388063dfb0278a5c53586bd17a38740925d39ff9cc9942bda200436da597abaf644
data/.solargraph.yml ADDED
@@ -0,0 +1,10 @@
1
+ require:
2
+ - actioncable
3
+ - actionmailer
4
+ - actionpack
5
+ - actionview
6
+ - activejob
7
+ - activemodel
8
+ - activerecord
9
+ - activestorage
10
+ - activesupport
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arql (0.3.3)
4
+ arql (0.3.5)
5
5
  activerecord (>= 6.0.3, < 6.2.0)
6
6
  activesupport (~> 6.0.3)
7
7
  caxlsx (~> 3.0.2)
@@ -40,7 +40,7 @@ GEM
40
40
  coderay (1.1.3)
41
41
  composite_primary_keys (12.0.10)
42
42
  activerecord (~> 6.0.0)
43
- concurrent-ruby (1.1.9)
43
+ concurrent-ruby (1.1.10)
44
44
  htmlentities (4.3.4)
45
45
  i18n (1.8.11)
46
46
  concurrent-ruby (~> 1.0)
@@ -0,0 +1,33 @@
1
+ module Arql::Commands
2
+ module Sandbox
3
+ class << self
4
+ attr_accessor :enabled
5
+
6
+ @sandbox_callback = proc do
7
+ begin_transaction(joinable: false)
8
+ end
9
+
10
+ def enter
11
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.set_callback(:checkout, :after, &@sandbox_callback)
12
+ ActiveRecord::Base.connection.begin_transaction(joinable: false)
13
+ @enabled = true
14
+ end
15
+
16
+ def quit
17
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.skip_callback(:checkout, :after, &@sandbox_callback)
18
+ @enabled = false
19
+
20
+ puts "begin_transaction callbacks removed."
21
+ puts "You still have open %d transactions open, don't forget commit or rollback them." % ActiveRecord::Base.connection.open_transactions if ActiveRecord::Base.connection.open_transactions > 0
22
+ end
23
+ end
24
+
25
+ Pry.commands.block_command 'sandbox-enter' do
26
+ Sandbox.enter
27
+ end
28
+
29
+ Pry.commands.block_command 'sandbox-quit' do
30
+ Sandbox.quit
31
+ end
32
+ end
33
+ end
data/lib/arql/commands.rb CHANGED
@@ -4,6 +4,7 @@ require 'arql/commands/table'
4
4
  require 'arql/commands/reconnect'
5
5
  require 'arql/commands/redefine'
6
6
  require 'arql/commands/show_sql'
7
+ require 'arql/commands/sandbox'
7
8
 
8
9
  module Arql::Commands
9
10
  end
data/lib/arql/multi_io.rb CHANGED
@@ -5,7 +5,14 @@ module Arql
5
5
  end
6
6
 
7
7
  def write(*args)
8
- @targets.each {|t| t.write(*args)}
8
+ @targets.each do |t|
9
+ if t.isatty
10
+ t.write(*args)
11
+ else
12
+ t.write(*(args.map { |str| str.gsub(/\e\[(\d+)m/, '')}))
13
+ end
14
+ t.flush
15
+ end
9
16
  end
10
17
 
11
18
  def close
data/lib/arql/repl.rb CHANGED
@@ -35,7 +35,12 @@ module Arql
35
35
  "(#{obj}:#{nest_level})"
36
36
  end
37
37
  end
38
- "%s#{Rainbow('@').green}%s#{nest_level_prompt} [%d] %s " % [Rainbow('ARQL').red, Rainbow(App.prompt).yellow, pry_instance.input_ring.count, Rainbow('❯').green]
38
+ if Arql::Commands::Sandbox.enabled
39
+ sandbox_indicator = ' [%s] ' % Rainbow('sandbox').green.bright
40
+ else
41
+ sandbox_indicator = ''
42
+ end
43
+ "%s#{Rainbow('@').green}%s%s#{nest_level_prompt} [%d] %s " % [Rainbow('ARQL').red, Rainbow(App.prompt).yellow, sandbox_indicator, pry_instance.input_ring.count, Rainbow('❯').green]
39
44
  end]
40
45
  end
41
46
  end
data/lib/arql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arql
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.5"
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.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -222,6 +222,7 @@ extensions: []
222
222
  extra_rdoc_files: []
223
223
  files:
224
224
  - ".gitignore"
225
+ - ".solargraph.yml"
225
226
  - CODE_OF_CONDUCT.md
226
227
  - Gemfile
227
228
  - Gemfile.lock
@@ -241,6 +242,7 @@ files:
241
242
  - lib/arql/commands/models.rb
242
243
  - lib/arql/commands/reconnect.rb
243
244
  - lib/arql/commands/redefine.rb
245
+ - lib/arql/commands/sandbox.rb
244
246
  - lib/arql/commands/show_sql.rb
245
247
  - lib/arql/commands/table.rb
246
248
  - lib/arql/concerns.rb