<commit_before>require "fileutils"
require "uri"
module TiyoHw
  class Setup
    attr_accessor :url
    def initialize(url)
      @url = url
    end

    def sha
      matches = /\b[0-9a-f]{5,40}\b/.match(url)
      matches.to_s if matches && !gist?
    end

    def git_url
      final_url = url.split("/tree/").first
      "#{final_url}#{'.git' unless final_url.end_with?('.git')}"
    end

    def gist?
      /gist\.github\.com/.match(url)
    end

    def dir_name
      git_url.split(%r{[\/\.]})[-3..-2].join("-")
    end

    def clean_dir
      FileUtils.rm_rf(File.join(File.expand_path(HOMEWORK_DIR), dir_name))
    end

    def setup
      FileUtils.mkdir_p HOMEWORK_DIR
    end

    def cmd
      setup
      clean_dir
      cmds = []
      cmds << "cd #{File.expand_path( )}"
      cmds << "git clone #{git_url} #{dir_name}"
      cmds << "cd #{dir_name}"
      cmds << "git checkout #{sha} -b submitted_assignment" if sha
      cmds << "#{EDITOR} ."
      cmds.join(" && ")
    end
  end
end<commit_msg>Fix typo in clone directory path<commit_after>require "fileutils"
require "uri"
module TiyoHw
  class Setup
    attr_accessor :url
    def initialize(url)
      @url = url
    end

    def sha
      matches = /\b[0-9a-f]{5,40}\b/.match(url)
      matches.to_s if matches && !gist?
    end

    def git_url
      final_url = url.split("/tree/").first
      "#{final_url}#{'.git' unless final_url.end_with?('.git')}"
    end

    def gist?
      /gist\.github\.com/.match(url)
    end

    def dir_name
      git_url.split(%r{[\/\.]})[-3..-2].join("-")
    end

    def clean_dir
      FileUtils.rm_rf(File.join(File.expand_path(HOMEWORK_DIR), dir_name))
    end

    def setup
      FileUtils.mkdir_p HOMEWORK_DIR
    end

    def cmd
      setup
      clean_dir
      cmds = []
      cmds << "cd #{File.expand_path( HOMEWORK_DIR )}"
      cmds << "git clone #{git_url} #{dir_name}"
      cmds << "cd #{dir_name}"
      cmds << "git checkout #{sha} -b submitted_assignment" if sha
      cmds << "#{EDITOR} ."
      cmds.join(" && ")
    end
  end
end
{'fraction_non_alphanumeric': 0.15198451113262343, 'fraction_numerical': 0.006776379477250726, 'mean_word_length': 2.175115207373272, 'pattern_counts': {'":': 0, '<': 23, '<?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': '2444543', 'n_tokens_mistral': 778, 'n_tokens_neox': 754, 'n_words': 165}