Sha256: 79b3efbd40bc24077050574bc2ed8b6eeee9a86cd33a060dd6777a45ada4ba33

Contents?: true

Size: 1.5 KB

Versions: 7

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require "mihari/feed/reader"
require "mihari/feed/parser"

module Mihari
  module Analyzers
    #
    # Feed analyzer
    #
    class Feed < Base
      # @return [Hash, nil]
      attr_reader :data

      # @return [Hash, nil]
      attr_reader :json

      # @return [Hash, nil]
      attr_reader :params

      # @return [Hash]
      attr_reader :headers

      # @return [String]
      attr_reader :method

      # @return [String]
      attr_reader :selector

      # @return [String]
      attr_reader :query

      #
      # @param [String] query
      # @param [Hash, nil] options
      # @param [String] method
      # @param [Hash, nil] headers
      # @param [Hash, nil] params
      # @param [Hash, nil] json
      # @param [Hash, nil] data
      # @param [String] selector
      #
      def initialize(query, options: nil, method: "GET", headers: nil, params: nil, json: nil, data: nil, selector: "")
        super(query, options: options)

        @method = method
        @headers = headers || {}
        @params = params
        @json = json
        @data = data
        @selector = selector
      end

      def artifacts
        Mihari::Feed::Parser.new(results).parse selector
      end

      private

      def results
        reader = Mihari::Feed::Reader.new(
          query,
          method: method,
          headers: headers,
          timeout: timeout,
          params: params,
          json: json,
          data: data
        )
        reader.read
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/analyzers/feed.rb
mihari-6.2.0 lib/mihari/analyzers/feed.rb
mihari-6.1.0 lib/mihari/analyzers/feed.rb
mihari-6.0.0 lib/mihari/analyzers/feed.rb
mihari-5.7.2 lib/mihari/analyzers/feed.rb
mihari-5.7.1 lib/mihari/analyzers/feed.rb
mihari-5.7.0 lib/mihari/analyzers/feed.rb