<commit_before>require "net/http"
require "net/https" # Obsolete as of what ruby version?
require "uri"

# slack_options
# {
#   "channel"    => "#myroom",
#   "username"   => "my_bot_name",
#   "icon_url"   => "https://slack.com/img/icons/app-57.png",
#   "icon_emoji" => ":ghost:"
# }
module Slackr
  class Connection
    attr_accessor :http, :uri, :options, :team, :token

    def initialize(team, token, options={})
      @team, @token, @options = team, token, options
    end

    def init
      validate_options
      setup_connection
    end

    def base_url
      "https://#{@team}.slack.com"
    end

    def uri_request_uri
      uri.request_uri
    end

    def http_request(request)
      http.request(request)
    end

  private

    def validate_options
      (options.has_key?("channel") && options.has_key?("username")) && !options["channel"].match(/^#/).nil?
    end

    def setup_connection
      @uri  = URI.parse(base_url)
      @http = Net::HTTP.new(@uri.host, @uri.port)
      @http.use_ssl = true<commit_msg>Returns self from Connection#init<commit_after>require "net/http"
require "net/https" # Obsolete as of what ruby version?
require "uri"

# slack_options
# {
#   "channel"    => "#myroom",
#   "username"   => "my_bot_name",
#   "icon_url"   => "https://slack.com/img/icons/app-57.png",
#   "icon_emoji" => ":ghost:"
# }
module Slackr
  class Connection
    attr_accessor :http, :uri, :options, :team, :token

    def initialize(team, token, options={})
      @team, @token, @options = team, token, options
    end

    def init
      validate_options
      setup_connection
      return self
    end

    def base_url
      "https://#{@team}.slack.com"
    end

    def uri_request_uri
      uri.request_uri
    end

    def http_request(request)
      http.request(request)
    end

  private

    def validate_options
      (options.has_key?("channel") && options.has_key?("username")) && !options["channel"].match(/^#/).nil?
    end

    def setup_connection
      @uri  = URI.parse(base_url)
      @http = Net::HTTP.new(@uri.host, @uri.port)
      @http.use_ssl = true
{'fraction_non_alphanumeric': 0.14686311787072243, 'fraction_numerical': 0.0019011406844106464, 'mean_word_length': 2.869485294117647, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7024436', 'n_tokens_mistral': 736, 'n_tokens_neox': 715, 'n_words': 154}