Sha256: 11d16833329d3714d17ce7f9493b84e524732b05d905c0e43a84cc3e2614d930

Contents?: true

Size: 720 Bytes

Versions: 5

Compression:

Stored size: 720 Bytes

Contents

module HerokuPgBackupsArchive
  class Backup
    def self.create
      backup_output = ToolbeltHelper.capture_backup
      new(backup_output)
    end

    attr_reader :id

    def initialize(backup_output)
      @id = extract_id(backup_output)
    end

    def url
      @url ||= ToolbeltHelper.fetch_backup_public_url(id).chomp
    end

    def finished_at
      @finished_at ||= begin
        info = ToolbeltHelper.fetch_backup_info(id)
        Time.parse(info.match(/Finished:\s*(.*)\n/)[1])
      end
    end

    private

    def extract_id(backup_output)
      matches = backup_output.match(/---backup---> (.*)\n/)
      raise BackupFailedError.new(backup_output) unless matches
      matches[1]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
heroku_pg_backups_archive-0.2.0 lib/heroku_pg_backups_archive/backup.rb
heroku_pg_backups_archive-0.1.3 lib/heroku_pg_backups_archive/backup.rb
heroku_pg_backups_archive-0.1.2 lib/heroku_pg_backups_archive/backup.rb
heroku_pg_backups_archive-0.1.1 lib/heroku_pg_backups_archive/backup.rb
heroku_pg_backups_archive-0.1.0 lib/heroku_pg_backups_archive/backup.rb