class Evesync::OS::PackageWatcher

Watcher for package changes for Arch Linux

Example

Thread.new { IPC::Data::PackageWatcher.new(queue).run }

Constants

ARCH_LOG_FILE
PKG_REGEXP

Public Class Methods

new(queue) click to toggle source
# File lib/evesync/os/linux/arch/package_watcher.rb, line 26
def initialize(queue)
  @queue = queue
  Log.debug('Arch Package watcher initialized')
end

Public Instance Methods

start() click to toggle source
# File lib/evesync/os/linux/arch/package_watcher.rb, line 31
def start
  Log.debug('Arch Package watcher started')
  @thr = Thread.new do
    File.open(ARCH_LOG_FILE) do |log|
      log.extend(File::Tail)
      log.interval = Config[:evemond]['watch-interval']
      log.backward(1)
      log.tail do |line|
        m = line.match(PKG_REGEXP)
        next unless m

        pkg = IPC::Data::Package.new(
          name: m[:package],
          version: m[:version],
          command: m[:command]
        )
        @queue << pkg
        Log.debug 'Arch package watcher enqued:', pkg
      end
    end
  end
end
stop() click to toggle source
# File lib/evesync/os/linux/arch/package_watcher.rb, line 54
def stop
  @thr.exit
end