<commit_before>require "open-uri"
require "fileutils"
require "zip/zip"

module RailsInstaller::Utilities
#
# unzip:
# Requires: rubyzip2 (gem install rubyzip2) # require "zip/zip"
#
  def unzip(filename, regex = nil)

    Zip::ZipFile.open(File.basename(RailsInstaller::BSDTar.url)) do |zipfile|

      zipfile.entries.select do |entry|

        entry.name.match(/.*\.exe$/)

      end.each do |entry|

        zipfile.extract(entry, entry.name)

      end

    end

  end

#
# bsdtar_install
# Requires: open-uri
#
  def bsdtar_install(path = File.join(RailsInstaller::Stage, "bin"))

    FileUtils.mkdir_p(File.dirname(path))

    # BSDTar is small so using open-uri to download this is fine.
    open(RailsInstaller::BSDTar.url) do |temporary_file|

      File.open(File.basename(RailsInstaller::BSDTar.url), "wb") do |file|

        file.write(temporary_file.read)

      end

    end

    unzip(File.basename(RailsInstaller::BSDTar.url), /.*\.exe$/)

    FileUtils.mv("basic-bsdtar.exe", path)

  end

#
# sh
#
# Runs Shell commands, single point of shell contact.
#
  def sh(command, *options)

    stage_bin_path = File.join(RailsInstaller::Stage, "bin")<commit_msg>Move basic-bsdtar.exe into place.<commit_after>require "open-uri"
require "fileutils"
require "zip/zip"

module RailsInstaller::Utilities
#
# unzip:
# Requires: rubyzip2 (gem install rubyzip2) # require "zip/zip"
#
  def unzip(filename, regex = nil)

    printf "Extracting #{filename} contents\n"

    Zip::ZipFile.open(filename)) do |zipfile|

      zipfile.entries.select do |entry|

        entry.name.match(/.*\.exe$/)

      end.each do |entry|

        zipfile.extract(entry, entry.name)

      end

    end

  end

#
# bsdtar_install
# Requires: open-uri
#
  def bsdtar_install(path = File.join(RailsInstaller::Stage, "bin"))

    printf "Downloading and extracting basic-bsdtar.exe\n"
    FileUtils.mkdir_p(File.dirname(path))

    # BSDTar is small so using open-uri to download this is fine.
    open(RailsInstaller::BSDTar.url) do |temporary_file|

      File.open(File.basename(RailsInstaller::BSDTar.url), "wb") do |file|

        file.write(temporary_file.read)

      end

    end
    unzip(File.basename(RailsInstaller::BSDTar.url), /.*\.exe$/)

    printf "Instaling basic-bsdtar.exe into #{path}\n"
    File.mv(
        File.join(Dir.pwd,"basic-bsdtar.exe"),
        File.join(path,"basic-bsdtar.exe"),
        :force => true
    )

  end

#
# sh
#
# Runs Shell commands, single point of shell contact.
#
  def sh(command, *options)

    stage_bin_path = File.join(RailsInstaller::Stage, "bin")
{'fraction_non_alphanumeric': 0.13683803633552377, 'fraction_numerical': 0.0015461925009663702, 'mean_word_length': 3.2847682119205297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3604969', 'n_tokens_mistral': 979, 'n_tokens_neox': 910, 'n_words': 187}