Sha256: e32cbd6a5729b529696c22bee5bec5d9542d907870fdc4f3174f6224793244d7

Contents?: true

Size: 776 Bytes

Versions: 6

Compression:

Stored size: 776 Bytes

Contents

module Writefully
  module Workers
    class Journalist < BaseWorker
      def publish
        Writefully.logger.info "Publishing #{message[:resource]} #{message[:slug]}"
        pencil = Tools::Pencil.new_link(message)
        pencil.perform
      end

      def remove
        eraser = Tools::Eraser.new_link(message)
        unless eraser.directory_exists?
          Writefully.logger.info "Removing #{message[:resource]} #{message[:slug]}"
          eraser.perform
        else
          eraser.terminate
        end
      end

      def message_with_tries
        message.merge({ tries: (message[:tries] || 1) + 1, run: false })
      end

      def on_death actor, reason
        Writefully.add_job :journalists, message_with_tries if message
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
writefully-0.8.2 lib/writefully/workers/journalist.rb
writefully-0.8.1 lib/writefully/workers/journalist.rb
writefully-0.8.0 lib/writefully/workers/journalist.rb
writefully-0.7.1 lib/writefully/workers/journalist.rb
writefully-0.6.12 lib/writefully/workers/journalist.rb
writefully-0.6.11 lib/writefully/workers/journalist.rb