Sha256: 6906bbf9129c70d55534bfcf2f0739e64928a770ad837366c33352a30a40c389

Contents?: true

Size: 700 Bytes

Versions: 5

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

require 'notifier'

module Riserva::Listeners
  class Backup < ApplicationListener
    def initialize
      notify('Starting backup...')
      Riserva.logger.info('Starting backup...')
    end

    def ok
      notify('Backup successfully completed')
    end

    def failed
      notify('Backup failed')
    end

    private

    def notify(message)
      return unless enabled?
      Notifier.notify(image: notification_icon, title: 'Riserva', message: message)
    end

    def enabled?
      Riserva::Config.read('system_notifications')
    end

    def notification_icon
      Riserva::Config.read('notification_icon') || 'media-floppy-symbolic'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
riserva-0.1.6 lib/riserva/listeners/backup.rb
riserva-0.1.5 lib/riserva/listeners/backup.rb
riserva-0.1.4 lib/riserva/listeners/backup.rb
riserva-0.1.3 lib/riserva/listeners/backup.rb
riserva-0.1.2 lib/riserva/listeners/backup.rb