Sha256: e7cca3e5051d383aeff984c10414bd8c056180486fc86f7e21d2911075e89eaf

Contents?: true

Size: 1.45 KB

Versions: 57

Compression:

Stored size: 1.45 KB

Contents

require 'rainbow'

module Arql::Commands
  module Info
    class << self
      def db_info
        <<~EOF

        Database Connection Information:

            Active:    #{color_boolean(ActiveRecord::Base.connection.active?)}
            Host:      #{Arql::App.config[:host]}
            Port:      #{Arql::App.config[:port]}
            Username:  #{Arql::App.config[:username]}
            Password:  #{(Arql::App.config[:password] || '').gsub(/./, '*')}
            Database:  #{Arql::App.config[:database]}
            Adapter:   #{Arql::App.config[:adapter]}
            Encoding:  #{Arql::App.config[:encoding]}
            Pool Size: #{Arql::App.config[:pool]}
        EOF
      end

      def ssh_info
        <<~EOF

        SSH Connection Information:

            Active:     #{color_boolean(Arql::SSHProxy.active?)}
            Host:       #{Arql::App.config[:ssh][:host]}
            Port:       #{Arql::App.config[:ssh][:port]}
            Username:   #{Arql::App.config[:ssh][:user]}
            Password:   #{(Arql::App.config[:ssh][:password] || '').gsub(/./, '*')}
            Local Port: #{Arql::SSHProxy.local_ssh_proxy_port}
        EOF
      end

      private
      def color_boolean(bool)
        if bool
          Rainbow('TRUE').green
        else
          Rainbow('FALSE').red
        end
      end
    end

    Pry.commands.block_command 'info' do
      puts Info::db_info
      puts Info::ssh_info if Arql::App.config[:ssh].present?
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
arql-0.3.31 lib/arql/commands/info.rb
arql-0.3.30 lib/arql/commands/info.rb
arql-0.3.29 lib/arql/commands/info.rb
arql-0.3.28 lib/arql/commands/info.rb
arql-0.3.27 lib/arql/commands/info.rb
arql-0.3.26 lib/arql/commands/info.rb
arql-0.3.25 lib/arql/commands/info.rb
arql-0.3.24 lib/arql/commands/info.rb
arql-0.3.23 lib/arql/commands/info.rb
arql-0.3.22 lib/arql/commands/info.rb
arql-0.3.21 lib/arql/commands/info.rb
arql-0.3.20 lib/arql/commands/info.rb
arql-0.3.19 lib/arql/commands/info.rb
arql-0.3.18 lib/arql/commands/info.rb
arql-0.3.17 lib/arql/commands/info.rb
arql-0.3.16 lib/arql/commands/info.rb
arql-0.3.15 lib/arql/commands/info.rb
arql-0.3.14 lib/arql/commands/info.rb
arql-0.3.13 lib/arql/commands/info.rb
arql-0.3.12 lib/arql/commands/info.rb