Class: Ronin::UI::CLI::Commands::Database
- Inherits:
-
Ronin::UI::CLI::Command
- Object
- Thor::Group
- Ronin::UI::CLI::Command
- Ronin::UI::CLI::Commands::Database
- Defined in:
- lib/ronin/ui/cli/commands/database.rb
Overview
The ronin database
command.
Instance Method Summary collapse
-
#add_repository ⇒ Object
protected
Adds a new Database repository.
-
#execute ⇒ Object
Displays or modifies the Ronin Database configuration.
-
#remove_repository ⇒ Object
protected
Removes an existing Database repository.
-
#repository_uri ⇒ Addressable::URI
protected
Creates a repository URI from the command options.
-
#set_repository ⇒ Object
protected
Sets the URI for an existing Database repository.
Methods inherited from Ronin::UI::CLI::Command
banner, command_name, #indent, inherited, #initialize, #print_array, #print_exception, #print_hash, #print_section, #print_title, #puts, run, #setup
Constructor Details
This class inherits a constructor from Ronin::UI::CLI::Command
Instance Method Details
#add_repository ⇒ Object (protected)
Adds a new Database repository.
105 106 107 108 109 110 111 112 113 |
# File 'lib/ronin/ui/cli/commands/database.rb', line 105 def add_repository name = [:add].to_sym Ronin::Database.save do Ronin::Database.repositories[name] = repository_uri end print_info "Database repository #{name} added." end |
#execute ⇒ Object
Displays or modifies the Ronin Database configuration.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ronin/ui/cli/commands/database.rb', line 53 def execute if [:clear] name = [:clear].to_sym print_info "Clearing the Database repository #{name} ..." Ronin::Database.clear(name) do print_info "Database repository #{name} cleared." end return end if [:add] add_repository elsif [:set] set_repository elsif [:delete] delete_repository else Ronin::Database.repositories.each do |name,uri| print_hash uri, :title => name end end end |
#remove_repository ⇒ Object (protected)
Removes an existing Database repository.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/ronin/ui/cli/commands/database.rb', line 136 def remove_repository name = [:remove].to_sym unless Ronin::Database.repository?(name) print_error "Unknown Database repository #{name}" return end Ronin::Database.save do Ronin::Database.repositories.delete(name) end print_info "Database repository #{name} removed." end |
#repository_uri ⇒ Addressable::URI (protected)
Creates a repository URI from the command options.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ronin/ui/cli/commands/database.rb', line 87 def repository_uri if [:uri] Addressable::URI.parse([:uri]).to_hash else { :adapter => [:adapter], :host => [:host], :port => [:port], :user => [:user], :password => [:password], :database => ([:database] || [:path]) } end end |
#set_repository ⇒ Object (protected)
Sets the URI for an existing Database repository.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ronin/ui/cli/commands/database.rb', line 118 def set_repository name = [:set].to_sym unless Ronin::Database.repository?(name) print_error "Unknown Database repository #{name}" return end Ronin::Database.save do Ronin::Database.repositories[name] = repository_uri end print_info "Database repository #{name} updated." end |