Sha256: 811c7e9b7ed7dbda6759c71a197943684a985153d175a91c46a06b6f7bf7504d

Contents?: true

Size: 884 Bytes

Versions: 12

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

module Fusuma
  module Plugin
    module Detectors
      # Detect KeypressEvent from KeypressBuffer
      class AppmatcherDetector < Detector
        SOURCES = ["appmatcher"].freeze
        BUFFER_TYPE = "appmatcher"

        # 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

12 entries across 12 versions & 1 rubygems

Version Path
fusuma-plugin-appmatcher-0.7.1 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.7.0 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.6.1 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.6.0 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.5.0 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.4.0 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.3.1 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.3.0 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.2.3 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.2.2 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.2.1 lib/fusuma/plugin/detectors/appmatcher_detector.rb
fusuma-plugin-appmatcher-0.2.0 lib/fusuma/plugin/detectors/appmatcher_detector.rb