<commit_before>module BuildKit
  
  module Tasks

    def self.xcode_build runner, task_opts
      task = XcodeBuildTask.new({ runner: runner, opts: task_opts })
      task.run!
    end

    private

    class XcodeBuildTask < BuildKitTask

      attr_reader :output

      def run!
        run_command!
        complete_task!
      end

      private

      def assert_requirements
        BuildKit::Utilities::Assertions.assert_required_config [:app_name, :workspace, :sdk, :build_configuration, :build_dir, :scheme], @runner
        BuildKit::Utilities::Assertions.assert_files_exist [@config.workspace, @config.absolute_build_dir]
      end

      def build_command
        workspace_arg = "-workspace \"#{@config.workspace}\""
        sdk_arg = "-sdk \"#{@config.sdk}\""
        scheme_arg = "-scheme \"#{@config.scheme}\""   
        configuration_arg = "-configuration \"#{@config.build_configuration}\""
        build_dir_arg = "CONFIGURATION_BUILD_DIR=\"#{@config.absolute_build_dir}\""
        "xcodebuild #{workspace_arg} #{sdk_arg} #{scheme_arg} #{configuration_arg} #{build_dir_arg} build | xcpretty -c"
      end

      def run_command!
        command = build_command
        @output = %x[#{command}]
        puts @output if @task_options[:log]
      end<commit_msg>Create :build_dir if needed<commit_after>module BuildKit
  
  module Tasks

    require "fileutils"
    
    def self.xcode_build runner, task_opts
      task = XcodeBuildTask.new({ runner: runner, opts: task_opts })
      task.run!
    end

    private

    class XcodeBuildTask < BuildKitTask

      attr_reader :output

      def run!
        create_build_directory
        run_command!
        complete_task!
      end

      private

      def assert_requirements
        BuildKit::Utilities::Assertions.assert_required_config [:app_name, :workspace, :sdk, :build_configuration, :build_dir, :scheme], @runner
      end

      def create_build_directory
        FileUtils.mkdir_p(@config.absolute_build_dir) unless File.exists?(@config.absolute_build_dir)
      end

      def build_command
        workspace_arg = "-workspace \"#{@config.workspace}\""
        sdk_arg = "-sdk \"#{@config.sdk}\""
        scheme_arg = "-scheme \"#{@config.scheme}\""   
        configuration_arg = "-configuration \"#{@config.build_configuration}\""
        build_dir_arg = "CONFIGURATION_BUILD_DIR=\"#{@config.absolute_build_dir}\""
        "xcodebuild #{workspace_arg} #{sdk_arg} #{scheme_arg} #{configuration_arg} #{build_dir_arg} build | xcpretty -c"
      end

      def run_command!
        command = build_command
        @output = %x[#{command}]
        puts @output if @task_options[:log]
      end
{'fraction_non_alphanumeric': 0.11439252336448598, 'fraction_numerical': 0.0, 'mean_word_length': 2.8726483357452968, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5548916', 'n_tokens_mistral': 816, 'n_tokens_neox': 809, 'n_words': 166}