<commit_before>require 'tempfile'
require "fileutils"

module Qor
  module Test
    class CLI
      attr_accessor :options, :scripts

      def initialize(options={})
        self.options = options
        self.scripts = []
      end

      def gemfile
        @gemfile ||= Qor::Test::Gemfile.new(options)
      end

      def gemfiles
        @gemfiles ||= gemfile.generate_gemfiles.reverse
      end

      def rubies
        gemfile.ruby_versions
      end

      def write_scripts
        puts ENV['QOR_TEST_SCRIPT_FILE']
        File.open(ENV['QOR_TEST_SCRIPT_FILE'], 'w+') do |f|
          f << scripts.compact.join("\n")
        end
      end

      def run
        scripts << "echo 'Generated #{gemfiles.count} Gemfile, Running with ruby #{rubies}'"

        case_num = 0
        rubies.map do |version|
          scripts << Qor::Test::Rubies.switch_ruby_version(version)
          gemfiles.map do |gemfile|
            case_num += 1
            scripts << "echo '\n\nRunning case #{case_num} with ruby #{version}, '$[$total_cases_num-#{case_num}]' cases left\n'"
            run_with_gemfile(gemfile)<commit_msg>colorful hint<commit_after>require 'tempfile'
require "fileutils"

module Qor
  module Test
    class CLI
      attr_accessor :options, :scripts

      def initialize(options={})
        self.options = options
        self.scripts = []
      end

      def gemfile
        @gemfile ||= Qor::Test::Gemfile.new(options)
      end

      def gemfiles
        @gemfiles ||= gemfile.generate_gemfiles.reverse
      end

      def rubies
        gemfile.ruby_versions
      end

      def write_scripts
        File.open(ENV['QOR_TEST_SCRIPT_FILE'], 'w+') do |f|
          f << scripts.compact.join("\n")
        end
      end

      def run
        scripts << "echo 'Generated #{gemfiles.count} Gemfile, Running with ruby #{rubies}'"

        case_num = 0
        rubies.map do |version|
          scripts << Qor::Test::Rubies.switch_ruby_version(version)
          gemfiles.map do |gemfile|
            case_num += 1
            scripts << "echo '\n\n\e[01;31mRunning case #{case_num} with ruby #{version}, '$[$total_cases_num-#{case_num}]' cases left\n\e[0m'"
            run_with_gemfile(gemfile)
{'fraction_non_alphanumeric': 0.11331828442437923, 'fraction_numerical': 0.004063205417607223, 'mean_word_length': 2.2115942028985507, 'pattern_counts': {'":': 0, '<': 19, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '614871', 'n_tokens_mistral': 714, 'n_tokens_neox': 678, 'n_words': 158}