Sha256: c463ec09bda5b5b7228a8960ce45936dea42a0115d0428d0c97f3605f29b6e65

Contents?: true

Size: 946 Bytes

Versions: 5

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true

require_relative "../appmatcher"

module Fusuma
  module Plugin
    module Inputs
      # Get active application's name
      class AppmatcherInput < Input
        attr_reader :pid

        def io
          @backend ||= Appmatcher.backend_klass.new

          @pid ||= begin
            pid = @backend.watch_start
            # NOTE: Closing the parent process's pipe
            @backend.writer.close

            pid
          end

          @backend.reader
        end

        def shutdown
          # CustomProcess#shutdown
          @backend.shutdown
        end

        # @param record [String] application name
        # @return [Event]
        def create_event(record:)
          e = Events::Event.new(
            tag: tag,
            record: Events::Records::AppmatcherRecord.new(name: record)
          )
          MultiLogger.debug(input_event: e)
          e
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fusuma-plugin-appmatcher-0.7.1 lib/fusuma/plugin/inputs/appmatcher_input.rb
fusuma-plugin-appmatcher-0.7.0 lib/fusuma/plugin/inputs/appmatcher_input.rb
fusuma-plugin-appmatcher-0.6.1 lib/fusuma/plugin/inputs/appmatcher_input.rb
fusuma-plugin-appmatcher-0.6.0 lib/fusuma/plugin/inputs/appmatcher_input.rb
fusuma-plugin-appmatcher-0.5.0 lib/fusuma/plugin/inputs/appmatcher_input.rb