<commit_before># frozen_string_literal: true

require "net/http"
require "yaml"

module Docker
  #
  # Manages byebug docker images
  #
  class Manager
    VERSIONS = %w[
      2.3.7
      2.4.4
      2.5.1
    ].freeze

    LINE_EDITORS = %w[
      readline
      libedit
    ].freeze

    COMPILERS = %w[
      gcc
      clang
    ].freeze

    attr_reader :version, :line_editor, :compiler

    def initialize(version:, line_editor:, compiler:)
      @version = version
      @line_editor = line_editor
      @compiler = compiler
    end

    def build
      print "Building image #{tag}... "

      status = system <<-COMMAND, out: File::NULL
        docker build \
          --tag "#{tag}" \
          --build-arg "ruby_version=#{version}" \
          --build-arg "ruby_download_sha256=#{sha256}" \
          --build-arg "compiler=#{compiler}" \
          --build-arg "line_edit_lib=#{line_editor_package}" \
          --build-arg "line_edit_config=#{line_editor_configure_flag}" \
          --file "docker/Dockerfile" \
          .
      COMMAND

      puts(status ? "✔" : "❌")
    end

    def test
      print "Testing image #{tag}... "

      status = system <<-COMMAND, out: File::NULL, err: File::NULL
        docker run --rm -v$(pwd):/byebug #{tag} bash -c 'bundle && bundle exec rake'
      COMMAND

      puts(status ? "✔" : "❌")
    end
<commit_msg>Better logging in docker manager<commit_after># frozen_string_literal: true

require "net/http"
require "yaml"

module Docker
  #
  # Manages byebug docker images
  #
  class Manager
    VERSIONS = %w[
      2.3.7
      2.4.4
      2.5.1
    ].freeze

    LINE_EDITORS = %w[
      readline
      libedit
    ].freeze

    COMPILERS = %w[
      gcc
      clang
    ].freeze

    attr_reader :version, :line_editor, :compiler

    def initialize(version:, line_editor:, compiler:)
      @version = version
      @line_editor = line_editor
      @compiler = compiler
    end

    def build
      command = <<-COMMAND
        docker build \
          --tag "#{tag}" \
          --build-arg "ruby_version=#{version}" \
          --build-arg "ruby_download_sha256=#{sha256}" \
          --build-arg "compiler=#{compiler}" \
          --build-arg "line_edit_lib=#{line_editor_package}" \
          --build-arg "line_edit_config=#{line_editor_configure_flag}" \
          --file "docker/Dockerfile" \
          .
      COMMAND

      print "Building image #{tag}: #{command.gsub(/[\n ]+/, ' ').strip}  "

      status = system(command, out: File::NULL)

      puts(status ? "✔" : "❌")
    end

    def test
      command = <<-COMMAND
        docker run --rm -v$(pwd):/byebug #{tag} bash -c 'bundle && bundle exec rake'
      COMMAND

      print "Testing image #{tag}: #{command.gsub(/[\n ]+/, ' ').strip}  "

      status = system(command, out: File::NULL, err: File::NULL)

      puts(status ? " ✔" : " ❌")
    end

{'fraction_non_alphanumeric': 0.14410024364775495, 'fraction_numerical': 0.010442046641141664, 'mean_word_length': 1.9844236760124612, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4964469', 'n_tokens_mistral': 993, 'n_tokens_neox': 956, 'n_words': 224}