Class: Crowbar::Client::Command::Database::Connect

Inherits:
Base
  • Object
show all
Includes:
Mixin::Database
Defined in:
lib/crowbar/client/command/database/connect.rb

Overview

Implementation for the database connect command

Constant Summary

Constants included from Mixin::Database

Mixin::Database::REGEX_DATABASE, Mixin::Database::REGEX_HOSTNAME, Mixin::Database::REGEX_IPV4, Mixin::Database::REGEX_PASSWORD, Mixin::Database::REGEX_PORT, Mixin::Database::REGEX_USERNAME

Instance Attribute Summary

Attributes inherited from Base

#args, #options, #stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Crowbar::Client::Command::Base

Instance Method Details

#args_with_optionsObject



29
30
31
32
33
34
35
36
37
# File 'lib/crowbar/client/command/database/connect.rb', line 29

def args_with_options
  args.easy_merge!(
    db_username: options.db_username,
    db_password: options.db_password,
    database: options.database,
    host: options.host,
    port: options.port
  )
end

#executeObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/crowbar/client/command/database/connect.rb', line 45

def execute
  request.process do |request|
    case request.code
    when 200
      say "Successfully connected to database"
    else
      err request.parsed_response["error"]
    end
  end
end

#requestObject



39
40
41
42
43
# File 'lib/crowbar/client/command/database/connect.rb', line 39

def request
  @request ||= Request::Database::Connect.new(
    args_with_options
  )
end