Created
January 5, 2017 15:41
-
-
Save claudijd/4004ad6c601d6b199bdf704e022857d2 to your computer and use it in GitHub Desktop.
Proposal for SSHScan::Database abstraction layer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SSHScan | |
class Database | |
def initialize(opts = {}) | |
@db = opts[:database] # SSHScan::Database::MongoDb -or- # SSHScan::Database::SQLite | |
@username = opts[:username] | |
@password = opts[:password] | |
@password = opts[:password] | |
@server = opts[:server] | |
@port = opts[:port] | |
end | |
def self.from_config_file(config_file) | |
# logic to load config from file and to provide the options needed to return an instance of SSHScan::Database | |
config_opts = YAML.load_file(file_string) | |
# here we should figure out how to determine what DB it is and provide the exact DB object to the SSHScan::Database.new call | |
return SSHScan::Database.new(opts) | |
end | |
def add_scan(worker_id, uuid, result) | |
@db.add_scan(worker_id, uuid, result) | |
end | |
def delete_scan(uuid) | |
@db.delete_scan(uuid) | |
end | |
def delete_all | |
@db.delete_all | |
end | |
# continue doing this so that it's completely transparent to the end user what | |
# DB type their using, other than what they say in their config file | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment