Class: DbAgile::Command::Db::Rm

Inherits:
DbAgile::Command show all
Defined in:
lib/dbagile/command/db/rm.rb

Overview

Remove a database configuration from the repository

Usage: dba #DbAgile::Command#command_name CONFIG

Constant Summary

Constants inherited from DbAgile::Command

CATEGORIES, CATEGORY_NAMES

Instance Attribute Summary collapse

Attributes inherited from DbAgile::Command

#environment

Attributes included from ClassMethods

#description, #summary, #usage

Instance Method Summary collapse

Methods inherited from DbAgile::Command

#add_options, #category, #check_command, #command_name, #description, #initialize, #options, #run, #set_default_options, #show_help, #summary, #unsecure_run, #usage

Methods included from ClassMethods

#build_command_options, #build_me, #category, #command_for, #command_name, #command_name_of, #each_subclass, #inherited, #ruby_method_for, #subclasses

Methods included from Robust

#ambigous_argument_list!, #assumption_error!, #bad_argument_list!, #has_command!, #is_in!, #valid_argument_list!, #valid_read_file!

Methods included from DbAgile::Core::IO::Robustness

#has_database!, #valid_database_name!, #valid_database_uri!, #valid_schema_files!

Constructor Details

This class inherits a constructor from DbAgile::Command

Instance Attribute Details

#matchObject

Name of the database to remove



13
14
15
# File 'lib/dbagile/command/db/rm.rb', line 13

def match
  @match
end

Instance Method Details

#execute_commandDbAgile::Core::Repository

Executes the command.

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dbagile/command/db/rm.rb', line 26

def execute_command
  cf = with_repository do |repository|
    db = has_database!(repository, self.match)

    # Move the current one if it was it
    if repository.current?(db)
      repository.current_db_name = nil
    end
      
    # Removes it from file
    repository.remove(db)
      
    # Flush the repository file
    repository.save!
  end

  # List available databases now
  DbAgile::dba(environment){|dba| dba.db_list %w{}}

  # Returns repository
  cf
end

#normalize_pending_arguments(arguments) ⇒ Object

Normalizes the pending arguments



16
17
18
19
# File 'lib/dbagile/command/db/rm.rb', line 16

def normalize_pending_arguments(arguments)
  self.match = valid_argument_list!(arguments, Symbol)
  self.match = valid_database_name!(self.match)
end