<commit_before>require 'avocado/engine'
require 'avocado/config'
require 'avocado/controller'
require 'avocado/cache'
require 'avocado/middleware'
require 'avocado/middleware/defaults'

require 'yaml'
require 'net/http/post/multipart'

module Avocado
  @payload = []

  class << self
    attr_accessor :payload
  end

  def self.upload!
    return if @payload.size.zero?
    yaml = write_payload_to_yaml_file
    WebMock.allow_net_connect!

    # read the file and upload it
    File.open('avocado.yml') do |file|
      uri = URI.parse Avocado::Config.url
      req = Net::HTTP::Post::Multipart.new uri.path, 'file' => UploadIO.new(file, 'text/yaml', 'avocado.yml')
      response = Net::HTTP.start(uri.host, uri.port) do |http|
        http.request(req)
      end

      p "Uploaded to #{uri.host} #{uri.port}"
      p response
    end
  rescue URI::InvalidURIError
    raise "Avocado::Config.url should point to your mounted Avocado documentation engine, it is currently not a valid URL"
  ensure<commit_msg>More logging<commit_after>require 'avocado/engine'
require 'avocado/config'
require 'avocado/controller'
require 'avocado/cache'
require 'avocado/middleware'
require 'avocado/middleware/defaults'

require 'yaml'
require 'net/http/post/multipart'

module Avocado
  @payload = []

  class << self
    attr_accessor :payload
  end

  def self.upload!
    return if @payload.size.zero?
    yaml = write_payload_to_yaml_file
    WebMock.allow_net_connect!

    # read the file and upload it
    File.open('avocado.yml') do |file|
      uri = URI.parse Avocado::Config.url
      req = Net::HTTP::Post::Multipart.new uri.path, 'file' => UploadIO.new(file, 'text/yaml', 'avocado.yml')
      response = Net::HTTP.start(uri.host, uri.port) do |http|
        http.request(req)
      end

      p "Uploaded to #{uri.host} #{uri.path} #{uri.port}"
      p response.body
    end
  rescue URI::InvalidURIError
    raise "Avocado::Config.url should point to your mounted Avocado documentation engine, it is currently not a valid URL"
  ensure
{'fraction_non_alphanumeric': 0.11640471512770137, 'fraction_numerical': 0.0, 'mean_word_length': 3.619047619047619, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1722760', 'n_tokens_mistral': 687, 'n_tokens_neox': 650, 'n_words': 173}