Sha256: 38c2a54cb2db4b6e913cf5c430320e99afc7b54de4c605d4efea3fc6c3f0d9b8

Contents?: true

Size: 1.42 KB

Versions: 9

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

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

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

      # @return [Hash, nil]
      attr_reader :json

      # @return [Hash, nil]
      attr_reader :params

      # @return [Hash, nil]
      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] headers
      # @param [Hash] params
      # @param [Hash] json
      # @param [Hash] data
      # @param [String] selector
      #
      def initialize(query, options: nil, method: "GET", headers: {}, params: {}, json: {}, data: {}, 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,
          params: params,
          json: json,
          data: data
        )
        reader.read
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mihari-5.4.5 lib/mihari/analyzers/feed.rb
mihari-5.4.4 lib/mihari/analyzers/feed.rb
mihari-5.4.3 lib/mihari/analyzers/feed.rb
mihari-5.4.2 lib/mihari/analyzers/feed.rb
mihari-5.4.1 lib/mihari/analyzers/feed.rb
mihari-5.4.0 lib/mihari/analyzers/feed.rb
mihari-5.3.2 lib/mihari/analyzers/feed.rb
mihari-5.3.1 lib/mihari/analyzers/feed.rb
mihari-5.3.0 lib/mihari/analyzers/feed.rb