Sha256: cfd72474c19e65fee6f452140454500df813197acbe4ad94bc9c9185ff1161bd
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
class PgExport class Configuration DEFAULTS = { database: nil, dumpfile_dir: ENV['DUMPFILE_DIR'] || 'tmp/dumps', keep_dumps: ENV['KEEP_DUMPS'] || 10, keep_ftp_dumps: ENV['KEEP_FTP_DUMPS'] || 10, ftp_host: ENV['BACKUP_FTP_HOST'], ftp_user: ENV['BACKUP_FTP_USER'], ftp_password: ENV['BACKUP_FTP_PASSWORD'] }.freeze attr_accessor *DEFAULTS.keys def initialize DEFAULTS.each_pair do |key, value| send("#{key}=", value) end end def validate DEFAULTS.keys.each do |field| raise InvalidConfigurationError, "Field #{field} is required" if send(field).nil? end end def ftp_params { host: ftp_host, user: ftp_user, password: ftp_password } end def to_s DEFAULTS.keys.map(&method(:print_attr)) end private def print_attr(key) if key == :ftp_password if send(key) "#{key}: #{send(key)[0..2]}***\n" else "#{key}:\n" end else "#{key}: #{send(key)}\n" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pg_export-0.2.0 | lib/pg_export/configuration.rb |