Module: Ronin::DB::CLI::DatabaseOptions Private
- Includes:
- URIMethods
- Included in:
- Commands::Irb, Commands::Migrate, ModelCommand
- Defined in:
- lib/ronin/db/cli/database_options.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Base class for all commands that access the database.
Constant Summary
Constants included from URIMethods
Class Method Summary collapse
-
.included(command) ⇒ Object
private
Adds the
--db
,--db-uri
, and--db-file
options to the command class including the DatabaseOptions module.
Instance Method Summary collapse
-
#db_config ⇒ Hash{Symbol => String,Integer}
private
The database connection configuration.
-
#db_connect ⇒ Object
private
Connects to the database.
Methods included from URIMethods
#normalize_adapter, #normalize_sqlite3_path, #parse_uri
Class Method Details
.included(command) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds the --db
, --db-uri
, and --db-file
options to the command
class including the Ronin::DB::CLI::DatabaseOptions module.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ronin/db/cli/database_options.rb', line 42 def self.included(command) command.option :db, value: { type: DB.config.keys, default: :default, usage: 'NAME' }, desc: 'The database to connect to' command.option :db_uri, value: { type: String, usage: 'URI' }, desc: 'The database URI to connect to' command.option :db_file, value: { type: String, usage: 'PATH' }, desc: 'The sqlite3 database file to use' end |
Instance Method Details
#db_config ⇒ Hash{Symbol => String,Integer}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The database connection configuration.
68 69 70 71 72 73 74 75 76 |
# File 'lib/ronin/db/cli/database_options.rb', line 68 def db_config if [:db_file] {sqlite3: normalize_sqlite3_path([:db_file])} elsif [:db_uri] parse_uri([:db_uri]) else DB.config[[:db]] end end |