arql 0.3.2 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.solargraph.yml +10 -0
 - data/Gemfile.lock +6 -8
 - data/arql.gemspec +1 -1
 - data/lib/arql/commands/sandbox.rb +33 -0
 - data/lib/arql/commands/vd.rb +46 -0
 - data/lib/arql/commands.rb +2 -0
 - data/lib/arql/definition.rb +20 -0
 - data/lib/arql/ext/array.rb +29 -0
 - data/lib/arql/multi_io.rb +8 -1
 - data/lib/arql/repl.rb +6 -1
 - data/lib/arql/vd.rb +41 -0
 - data/lib/arql/version.rb +1 -1
 - data/lib/arql.rb +1 -0
 - metadata +10 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 26a222ddbbce9305531742f9b9f160406fe36351aaac3026a1c93879de257e35
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f324c816f59dc993fca822d5482f0ee43cd973f1659abcd2f2fa48b7fd80acd7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5935a72b159a97a09dbdcfa761ba57b4375c7d78a680569ba8cd88a6f95fb9543b9d70e56d62c0973dc6a99a11347d32f87bce5f8b9ea5335c35f3176b9e5ca4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 84313b888ed601eafdce1b5e1867ca7580058b575e34de9291c489b4e318966ec169bff22c1d070960f3d1cf55020e8930b2212d78300a331ce122ccc868c87e
         
     | 
    
        data/.solargraph.yml
    ADDED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                arql (0.3. 
     | 
| 
      
 4 
     | 
    
         
            +
                arql (0.3.6)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  activerecord (>= 6.0.3, < 6.2.0)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  activesupport (~> 6.0.3)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  caxlsx (~> 3.0.2)
         
     | 
| 
         @@ -10,7 +10,7 @@ PATH 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  net-ssh-gateway (~> 2.0.0)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  pry (~> 0.13.1)
         
     | 
| 
       12 
12 
     | 
    
         
             
                  pry-byebug (~> 3.9.0)
         
     | 
| 
       13 
     | 
    
         
            -
                  pry-doc ( 
     | 
| 
      
 13 
     | 
    
         
            +
                  pry-doc (>= 1.0.0)
         
     | 
| 
       14 
14 
     | 
    
         
             
                  rainbow (~> 3.0.0)
         
     | 
| 
       15 
15 
     | 
    
         
             
                  roo (~> 2.8.3)
         
     | 
| 
       16 
16 
     | 
    
         
             
                  sqlite3 (~> 1.4)
         
     | 
| 
         @@ -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. 
     | 
| 
      
 43 
     | 
    
         
            +
                concurrent-ruby (1.1.10)
         
     | 
| 
       44 
44 
     | 
    
         
             
                htmlentities (4.3.4)
         
     | 
| 
       45 
45 
     | 
    
         
             
                i18n (1.8.11)
         
     | 
| 
       46 
46 
     | 
    
         
             
                  concurrent-ruby (~> 1.0)
         
     | 
| 
         @@ -48,14 +48,12 @@ GEM 
     | 
|
| 
       48 
48 
     | 
    
         
             
                mimemagic (0.4.3)
         
     | 
| 
       49 
49 
     | 
    
         
             
                  nokogiri (~> 1)
         
     | 
| 
       50 
50 
     | 
    
         
             
                  rake
         
     | 
| 
       51 
     | 
    
         
            -
                mini_portile2 (2.6.1)
         
     | 
| 
       52 
51 
     | 
    
         
             
                minitest (5.15.0)
         
     | 
| 
       53 
52 
     | 
    
         
             
                mysql2 (0.5.3)
         
     | 
| 
       54 
53 
     | 
    
         
             
                net-ssh (6.1.0)
         
     | 
| 
       55 
54 
     | 
    
         
             
                net-ssh-gateway (2.0.0)
         
     | 
| 
       56 
55 
     | 
    
         
             
                  net-ssh (>= 4.0.0)
         
     | 
| 
       57 
     | 
    
         
            -
                nokogiri (1. 
     | 
| 
       58 
     | 
    
         
            -
                  mini_portile2 (~> 2.6.1)
         
     | 
| 
      
 56 
     | 
    
         
            +
                nokogiri (1.13.0-x86_64-darwin)
         
     | 
| 
       59 
57 
     | 
    
         
             
                  racc (~> 1.4)
         
     | 
| 
       60 
58 
     | 
    
         
             
                pry (0.13.1)
         
     | 
| 
       61 
59 
     | 
    
         
             
                  coderay (~> 1.1)
         
     | 
| 
         @@ -63,7 +61,7 @@ GEM 
     | 
|
| 
       63 
61 
     | 
    
         
             
                pry-byebug (3.9.0)
         
     | 
| 
       64 
62 
     | 
    
         
             
                  byebug (~> 11.0)
         
     | 
| 
       65 
63 
     | 
    
         
             
                  pry (~> 0.13.0)
         
     | 
| 
       66 
     | 
    
         
            -
                pry-doc (1. 
     | 
| 
      
 64 
     | 
    
         
            +
                pry-doc (1.3.0)
         
     | 
| 
       67 
65 
     | 
    
         
             
                  pry (~> 0.11)
         
     | 
| 
       68 
66 
     | 
    
         
             
                  yard (~> 0.9.11)
         
     | 
| 
       69 
67 
     | 
    
         
             
                racc (1.6.0)
         
     | 
| 
         @@ -84,7 +82,7 @@ GEM 
     | 
|
| 
       84 
82 
     | 
    
         
             
                webrick (1.7.0)
         
     | 
| 
       85 
83 
     | 
    
         
             
                yard (0.9.27)
         
     | 
| 
       86 
84 
     | 
    
         
             
                  webrick (~> 1.7.0)
         
     | 
| 
       87 
     | 
    
         
            -
                zeitwerk (2.5. 
     | 
| 
      
 85 
     | 
    
         
            +
                zeitwerk (2.5.3)
         
     | 
| 
       88 
86 
     | 
    
         | 
| 
       89 
87 
     | 
    
         
             
            PLATFORMS
         
     | 
| 
       90 
88 
     | 
    
         
             
              ruby
         
     | 
    
        data/arql.gemspec
    CHANGED
    
    | 
         @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       34 
34 
     | 
    
         
             
              spec.add_dependency 'net-ssh-gateway', '~> 2.0.0'
         
     | 
| 
       35 
35 
     | 
    
         
             
              spec.add_dependency 'pry', '~> 0.13.1'
         
     | 
| 
       36 
36 
     | 
    
         
             
              spec.add_dependency 'pry-byebug', '~> 3.9.0'
         
     | 
| 
       37 
     | 
    
         
            -
              spec.add_dependency 'pry-doc', ' 
     | 
| 
      
 37 
     | 
    
         
            +
              spec.add_dependency 'pry-doc', '>= 1.0.0'
         
     | 
| 
       38 
38 
     | 
    
         
             
              spec.add_dependency 'rainbow', '~> 3.0.0'
         
     | 
| 
       39 
39 
     | 
    
         
             
              spec.add_dependency 'terminal-table', '~> 1.8.0'
         
     | 
| 
       40 
40 
     | 
    
         
             
              spec.add_dependency 'table_print', '~> 1.5.6'
         
     | 
| 
         @@ -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
         
     | 
| 
         @@ -0,0 +1,46 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'arql/vd'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Arql::Commands
         
     | 
| 
      
 4 
     | 
    
         
            +
              module VD
         
     | 
| 
      
 5 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def get_table_name(name)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    name = name.to_s
         
     | 
| 
      
 8 
     | 
    
         
            +
                    return name if name =~ /^[a-z]/
         
     | 
| 
      
 9 
     | 
    
         
            +
                    if Object.const_defined?(name)
         
     | 
| 
      
 10 
     | 
    
         
            +
                      klass = Object.const_get(name)
         
     | 
| 
      
 11 
     | 
    
         
            +
                      return klass.table_name if klass < ActiveRecord::Base
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
      
 13 
     | 
    
         
            +
                    name
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def table_info_vd(table_name)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    Arql::VD.new do |vd|
         
     | 
| 
      
 18 
     | 
    
         
            +
                      table_info(table_name).each { |row| vd << row }
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def table_info(table_name)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    t = []
         
     | 
| 
      
 24 
     | 
    
         
            +
                    t << ['PK', 'Name', 'SQL Type', 'Ruby Type', 'Limit', 'Precision', 'Scale', 'Default', 'Nullable', 'Comment']
         
     | 
| 
      
 25 
     | 
    
         
            +
                    connection = ::ActiveRecord::Base.connection
         
     | 
| 
      
 26 
     | 
    
         
            +
                    connection.columns(table_name).each do |column|
         
     | 
| 
      
 27 
     | 
    
         
            +
                      pk = if [connection.primary_key(table_name)].flatten.include?(column.name)
         
     | 
| 
      
 28 
     | 
    
         
            +
                             'Y'
         
     | 
| 
      
 29 
     | 
    
         
            +
                           else
         
     | 
| 
      
 30 
     | 
    
         
            +
                             ''
         
     | 
| 
      
 31 
     | 
    
         
            +
                           end
         
     | 
| 
      
 32 
     | 
    
         
            +
                      t << [pk, column.name, column.sql_type,
         
     | 
| 
      
 33 
     | 
    
         
            +
                            column.sql_type_metadata.type, column.sql_type_metadata.limit || '',
         
     | 
| 
      
 34 
     | 
    
         
            +
                            column.sql_type_metadata.precision || '', column.sql_type_metadata.scale || '', column.default || '',
         
     | 
| 
      
 35 
     | 
    
         
            +
                            column.null, column.comment || '']
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                    t
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                Pry.commands.block_command 'vd' do |name|
         
     | 
| 
      
 42 
     | 
    
         
            +
                  table_name = VD::get_table_name(name)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  VD::table_info_vd(table_name)
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/arql/commands.rb
    CHANGED
    
    
    
        data/lib/arql/definition.rb
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'arql/concerns'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'arql/vd'
         
     | 
| 
       2 
3 
     | 
    
         
             
            module Arql
         
     | 
| 
       3 
4 
     | 
    
         
             
              module Extension
         
     | 
| 
       4 
5 
     | 
    
         
             
                extend ActiveSupport::Concern
         
     | 
| 
         @@ -9,6 +10,15 @@ module Arql 
     | 
|
| 
       9 
10 
     | 
    
         
             
                  }
         
     | 
| 
       10 
11 
     | 
    
         
             
                end
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
                def vd
         
     | 
| 
      
 14 
     | 
    
         
            +
                  VD.new do |vd|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    vd << ['Attribute Name', 'Attribute Value', 'SQL Type', 'Comment']
         
     | 
| 
      
 16 
     | 
    
         
            +
                    self.class.connection.columns(self.class.table_name).each do |column|
         
     | 
| 
      
 17 
     | 
    
         
            +
                      vd << [column.name, read_attribute(column.name), column.sql_type, column.comment || '']
         
     | 
| 
      
 18 
     | 
    
         
            +
                    end
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       12 
22 
     | 
    
         
             
                def v
         
     | 
| 
       13 
23 
     | 
    
         
             
                  t = []
         
     | 
| 
       14 
24 
     | 
    
         
             
                  t << ['Attribute Name', 'Attribute Value', 'SQL Type', 'Comment']
         
     | 
| 
         @@ -49,6 +59,12 @@ module Arql 
     | 
|
| 
       49 
59 
     | 
    
         
             
                    puts Commands::Table::table_info_table(table_name)
         
     | 
| 
       50 
60 
     | 
    
         
             
                  end
         
     | 
| 
       51 
61 
     | 
    
         | 
| 
      
 62 
     | 
    
         
            +
                  def vd
         
     | 
| 
      
 63 
     | 
    
         
            +
                    table_name = Commands::Table::get_table_name(name)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    Commands::VD::table_info_vd(table_name)
         
     | 
| 
      
 65 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
       52 
68 
     | 
    
         
             
                  def v
         
     | 
| 
       53 
69 
     | 
    
         
             
                    table_name = Commands::Table::get_table_name(name)
         
     | 
| 
       54 
70 
     | 
    
         
             
                    Commands::Table::table_info(table_name)
         
     | 
| 
         @@ -229,6 +245,10 @@ module Arql 
     | 
|
| 
       229 
245 
     | 
    
         
             
                    records.t(*attrs, **options)
         
     | 
| 
       230 
246 
     | 
    
         
             
                  end
         
     | 
| 
       231 
247 
     | 
    
         | 
| 
      
 248 
     | 
    
         
            +
                  def vd(*attrs, **options)
         
     | 
| 
      
 249 
     | 
    
         
            +
                    records.vd(*attrs, **options)
         
     | 
| 
      
 250 
     | 
    
         
            +
                  end
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
       232 
252 
     | 
    
         
             
                  def v
         
     | 
| 
       233 
253 
     | 
    
         
             
                    records.v
         
     | 
| 
       234 
254 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/arql/ext/array.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'arql/vd'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            class Array
         
     | 
| 
       2 
4 
     | 
    
         
             
              def to_insert_sql(batch_size=500)
         
     | 
| 
       3 
5 
     | 
    
         
             
                raise 'All element should be an ActiveRecord instance object' unless all? { |e| e.is_a?(ActiveRecord::Base) }
         
     | 
| 
         @@ -48,6 +50,33 @@ class Array 
     | 
|
| 
       48 
50 
     | 
    
         
             
                end
         
     | 
| 
       49 
51 
     | 
    
         
             
              end
         
     | 
| 
       50 
52 
     | 
    
         | 
| 
      
 53 
     | 
    
         
            +
              def vd(*attrs, **options)
         
     | 
| 
      
 54 
     | 
    
         
            +
                if (attrs.present? || options.present? && options[:except]) && present? && first.is_a?(ActiveRecord::Base)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  column_names = first.attribute_names.map(&:to_sym)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  attrs = attrs.flat_map { |e| e.is_a?(Regexp) ? column_names.grep(e) : e }.uniq
         
     | 
| 
      
 57 
     | 
    
         
            +
                  if options.present? && options[:except]
         
     | 
| 
      
 58 
     | 
    
         
            +
                    attrs = column_names if attrs.empty?
         
     | 
| 
      
 59 
     | 
    
         
            +
                    if options[:except].is_a?(Regexp)
         
     | 
| 
      
 60 
     | 
    
         
            +
                      attrs.reject! { |e| e =~ options[:except] }
         
     | 
| 
      
 61 
     | 
    
         
            +
                    else
         
     | 
| 
      
 62 
     | 
    
         
            +
                      attrs -= [options[:except]].flatten
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                  Arql::VD.new do |vd|
         
     | 
| 
      
 67 
     | 
    
         
            +
                    vd << attrs
         
     | 
| 
      
 68 
     | 
    
         
            +
                    each do |e|
         
     | 
| 
      
 69 
     | 
    
         
            +
                      vd << e.attributes.values_at(*attrs.map(&:to_s))
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
                else
         
     | 
| 
      
 73 
     | 
    
         
            +
                  Arql::VD.new do |vd|
         
     | 
| 
      
 74 
     | 
    
         
            +
                    v.each { |row| vd << row if row }
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
                nil
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
       51 
80 
     | 
    
         
             
              def v
         
     | 
| 
       52 
81 
     | 
    
         
             
                return self unless present?
         
     | 
| 
       53 
82 
     | 
    
         
             
                t = []
         
     | 
    
        data/lib/arql/multi_io.rb
    CHANGED
    
    
    
        data/lib/arql/repl.rb
    CHANGED
    
    | 
         @@ -35,7 +35,12 @@ module Arql 
     | 
|
| 
       35 
35 
     | 
    
         
             
                                             "(#{obj}:#{nest_level})"
         
     | 
| 
       36 
36 
     | 
    
         
             
                                           end
         
     | 
| 
       37 
37 
     | 
    
         
             
                     end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 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/vd.rb
    ADDED
    
    | 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'csv'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Arql
         
     | 
| 
      
 4 
     | 
    
         
            +
              class VD
         
     | 
| 
      
 5 
     | 
    
         
            +
                COMMAND = 'vd'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                attr_accessor :rows
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 10 
     | 
    
         
            +
                  return unless check_command_installation
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @rows = []
         
     | 
| 
      
 12 
     | 
    
         
            +
                  yield self
         
     | 
| 
      
 13 
     | 
    
         
            +
                  command = "#{COMMAND} -f csv"
         
     | 
| 
      
 14 
     | 
    
         
            +
                  IO.popen(command, 'w+') do |io|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    io.puts(csv)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    io.close_write
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                def <<(row)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  rows << row
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def csv
         
     | 
| 
      
 25 
     | 
    
         
            +
                  CSV.generate do |csv|
         
     | 
| 
      
 26 
     | 
    
         
            +
                    rows.each do |row|
         
     | 
| 
      
 27 
     | 
    
         
            +
                      csv << row
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                def check_command_installation
         
     | 
| 
      
 33 
     | 
    
         
            +
                  `which #{COMMAND}`
         
     | 
| 
      
 34 
     | 
    
         
            +
                  if $?.exitstatus != 0
         
     | 
| 
      
 35 
     | 
    
         
            +
                    puts "Please install vd (visidata) command, see: https://www.visidata.org/"
         
     | 
| 
      
 36 
     | 
    
         
            +
                  else
         
     | 
| 
      
 37 
     | 
    
         
            +
                    true
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/arql/version.rb
    CHANGED
    
    
    
        data/lib/arql.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.3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Liu Xiang
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-04-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: mysql2
         
     | 
| 
         @@ -132,16 +132,16 @@ dependencies: 
     | 
|
| 
       132 
132 
     | 
    
         
             
              name: pry-doc
         
     | 
| 
       133 
133 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       134 
134 
     | 
    
         
             
                requirements:
         
     | 
| 
       135 
     | 
    
         
            -
                - - " 
     | 
| 
      
 135 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       136 
136 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       137 
     | 
    
         
            -
                    version: 1. 
     | 
| 
      
 137 
     | 
    
         
            +
                    version: 1.0.0
         
     | 
| 
       138 
138 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       139 
139 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       140 
140 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       141 
141 
     | 
    
         
             
                requirements:
         
     | 
| 
       142 
     | 
    
         
            -
                - - " 
     | 
| 
      
 142 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       143 
143 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       144 
     | 
    
         
            -
                    version: 1. 
     | 
| 
      
 144 
     | 
    
         
            +
                    version: 1.0.0
         
     | 
| 
       145 
145 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       146 
146 
     | 
    
         
             
              name: rainbow
         
     | 
| 
       147 
147 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -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,8 +242,10 @@ 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
         
     | 
| 
      
 248 
     | 
    
         
            +
            - lib/arql/commands/vd.rb
         
     | 
| 
       246 
249 
     | 
    
         
             
            - lib/arql/concerns.rb
         
     | 
| 
       247 
250 
     | 
    
         
             
            - lib/arql/concerns/global_data_definition.rb
         
     | 
| 
       248 
251 
     | 
    
         
             
            - lib/arql/concerns/table_data_definition.rb
         
     | 
| 
         @@ -261,6 +264,7 @@ files: 
     | 
|
| 
       261 
264 
     | 
    
         
             
            - lib/arql/repl.rb
         
     | 
| 
       262 
265 
     | 
    
         
             
            - lib/arql/ssh_proxy.rb
         
     | 
| 
       263 
266 
     | 
    
         
             
            - lib/arql/ssh_proxy_patch.rb
         
     | 
| 
      
 267 
     | 
    
         
            +
            - lib/arql/vd.rb
         
     | 
| 
       264 
268 
     | 
    
         
             
            - lib/arql/version.rb
         
     | 
| 
       265 
269 
     | 
    
         
             
            homepage: https://github.com/lululau/arql
         
     | 
| 
       266 
270 
     | 
    
         
             
            licenses:
         
     |