Sha256: 86024007f024e70e9a7799498a152c55c706d28fd3d5797b530c2ca7c8083dd2

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_export-0.1.3 lib/pg_export/configuration.rb
pg_export-0.1.1 lib/pg_export/configuration.rb
pg_export-0.1.0 lib/pg_export/configuration.rb