Sha256: c485c36710edc005c485928eb7eeb7ce3d36df35dd93be966f715af5e2df3451

Contents?: true

Size: 513 Bytes

Versions: 5

Compression:

Stored size: 513 Bytes

Contents

# frozen_string_literal: true

require 'uri'
require 'json'

module SlackWebhookLogger
  class RequestIO
    def self.close
      true
    end

    def self.write(hash)
      return if hash.blank?

      return if SlackWebhookLogger.ignore_patterns.any? { |ignore_pattern| hash[:text].match(ignore_pattern) }

      payload = hash.to_json

      req = Net::HTTP::Post.new(SlackWebhookLogger.webhook_uri.path)
      req.set_form_data(payload: payload)
      SlackWebhookLogger.https.request(req)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack_webhook_logger-0.3.1 lib/slack_webhook_logger/request_io.rb
slack_webhook_logger-0.3.0 lib/slack_webhook_logger/request_io.rb
slack_webhook_logger-0.2.2 lib/slack_webhook_logger/request_io.rb
slack_webhook_logger-0.2.1 lib/slack_webhook_logger/request_io.rb
slack_webhook_logger-0.2.0 lib/slack_webhook_logger/request_io.rb