Sha256: 172a8f7c376e78f0e79a07cf33ea9372b16dae57fe8a75e184d2dc4f4706bd7c

Contents?: true

Size: 909 Bytes

Versions: 8

Compression:

Stored size: 909 Bytes

Contents

# frozen_string_literal: true

module Fusuma
  module Plugin
    module Detectors
      # Detect KeypressEvent from KeypressBuffer
      class AppmatcherDetector < Detector
        SOURCES = ['appmatcher']
        BUFFER_TYPE = 'appmatcher'
        DEFAULT_NAME = 'global'

        # Always watch buffers and detect them.
        def watch?
          true
        end

        # @param buffers [Array<Event>]
        # @return [Event] if event is detected
        # @return [NilClass] if event is NOT detected
        def detect(buffers)
          buffer = buffers.find { |b| b.type == BUFFER_TYPE }

          return if buffer.empty?

          record = buffer.events.last.record

          context_record = Events::Records::ContextRecord.new(
            name: 'application',
            value: record.name
          )

          create_event(record: context_record)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fusuma-plugin-appmatcher-0.1.6 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.1.5 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.1.4 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.1.3 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.1.2 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.1.1 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.1.0 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.1.0.pre2 lib/fusuma/plugin/detectors/appmatcher_detector.rb