Sha256: 648de01627ecd0500bc59d11c9b436323129e0ccf90d4197f6a3158c267c6150

Contents?: true

Size: 944 Bytes

Versions: 49

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

require 'active_support/core_ext/hash/indifferent_access'
require 'httpclient'
require 'yaml'

module Aranha
  module Parsers
    class SourceAddress
      class HashHttpPost
        class << self
          def valid_source?(source)
            source.is_a?(::Hash) &&
              source.with_indifferent_access[:method].to_s.downcase.strip == 'post'
          end
        end

        attr_reader :source

        def initialize(source)
          @source = source.with_indifferent_access
        end

        def ==(other)
          self.class == other.class && source == other.source
        end

        def url
          source.fetch(:url)
        end

        def serialize
          source.to_yaml
        end

        def content
          HTTPClient.new.post_content(
            source[:url],
            source[:params].merge(follow_redirect: true)
          )
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 3 rubygems

Version Path
aranha-parsers-0.7.2 lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.7.1 lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.22.0 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.21.0 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.20.0 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.19.0 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.18.0 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.17.0 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.16.5 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.16.4 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.16.3 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.16.2 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.7.0 lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.6.1 lib/aranha/parsers/source_address/hash_http_post.rb
ehbrs-tools-0.16.1 vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.6.0 lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.5.0 lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.4.0 lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.3.0 lib/aranha/parsers/source_address/hash_http_post.rb
aranha-parsers-0.2.2 lib/aranha/parsers/source_address/hash_http_post.rb