<commit_before>require 'rake/tasklib'
require 'yaml'
require 'zip'
require 'zip/filesystem'

# Rake tasks to cross-compile Go project and ZIP the binaries:
# `rake build`, `rake zip`, `rake test` and `rake clean`.
#
# Usage: `require 'go4rake'` in `Rakefile`. Settings are specified in a YAML file: `go4rake.yml`.
#
# Example config: https://github.com/chillum/go4rake/blob/master/examples/go4rake.yml
#
# Docs: https://github.com/chillum/go4rake/blob/master/README.md
#
# Offline copies of README and example config are also included in this gem.
#
class Go4Rake < ::Rake::TaskLib
  # Load configuration file and initialize Rake tasks for cross-compiling Go programs.
  def initialize(yml = 'go4rake.yml')
    begin
      @config = YAML.load_file(yml)
      @config['out'] ||= '~/Downloads' # Default to ~/Downloads, if 'out' is not specified.
      tasks(@config, yml)
    rescue => e
      $stderr.puts("WARNING: Skipping `build` and `zip` tasks: #{e}")
    end
    # `build`, `zip` and `clean` depend on config, `test` doesn't.
    task_test
  end

  # Initialize `build`, `zip` and `clean` tasks.
  def tasks(cfg, yml)
    desc "Build this project for the platforms in #{yml}"
    task :build do
      cfg['platforms'].each { |os|
        if os['arch'].respond_to?('each')
          os['arch'].each { |arch|
            build(os['name'], arch)
          }
        else
          build(os['name'], os['arch'])
        end
      }
    end

    desc 'ZIP this project binaries'
    task zip: [:build, :test] do

      cfg['platforms'].each { |os|
        if os['arch'].respond_to?('each')
          os['arch'].each { |arch|
            zip(os['name'], arch, cfg['out'], cfg['files'],
                os['zip'] ? "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}")
          }
        else
          zip(os['name'], os['arch'], cfg['out'], cfg['files'],<commit_msg>formatting<commit_after>require 'rake/tasklib'
require 'yaml'
require 'zip'
require 'zip/filesystem'

# Rake tasks to cross-compile Go project and ZIP the binaries:
# `rake build`, `rake zip`, `rake test` and `rake clean`.
#
# Usage: `require 'go4rake'` in `Rakefile`. Settings are specified in a YAML file: `go4rake.yml`.
#
# Example config: https://github.com/chillum/go4rake/blob/master/examples/go4rake.yml
#
# Docs: https://github.com/chillum/go4rake/blob/master/README.md
#
# Offline copies of README and example config are also included in this gem.
#
class Go4Rake < ::Rake::TaskLib
  # Load configuration file and initialize Rake tasks for cross-compiling Go programs.
  def initialize(yml = 'go4rake.yml')
    begin
      @config = YAML.load_file(yml)
      @config['out'] ||= '~/Downloads' # Default to ~/Downloads, if 'out' is not specified.
      tasks(@config, yml)
    rescue => e
      $stderr.puts("WARNING: Skipping `build` and `zip` tasks: #{e}")
    end
    # `build`, `zip` and `clean` depend on config, `test` doesn't.
    task_test
  end

  # Initialize `build`, `zip` and `clean` tasks.
  def tasks(cfg, yml)
    desc "Build this project for the platforms in #{yml}"
    task :build do
      cfg['platforms'].each { |os|
        if os['arch'].respond_to?('each')
          os['arch'].each { |arch|
            build(os['name'], arch)
          }
        else
          build(os['name'], os['arch'])
        end
      }
    end

    desc 'ZIP this project binaries'
    task zip: [:build, :test] do
      cfg['platforms'].each { |os|
        if os['arch'].respond_to?('each')
          os['arch'].each { |arch|
            zip(os['name'], arch, cfg['out'], cfg['files'],
                os['zip'] ? "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}")
          }
        else
          zip(os['name'], os['arch'], cfg['out'], cfg['files'],
{'fraction_non_alphanumeric': 0.1686358754027927, 'fraction_numerical': 0.0037593984962406013, 'mean_word_length': 2.8802083333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2312289', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1223, 'n_words': 345}