<commit_before>require "thor"
require "fileutils"
require File.dirname(__FILE__) + '/util'

module Gator
  class Project < Thor
    include Thor::Actions

    def self.source_root
      Gator::Util.project_template_root
    end

    desc "project install DIRECTORY TEMPLATE_NAME", "Install a project template."
    def install( dir, template )
      empty_directory template_dir(template)
      FileUtils.cp_r File.expand_path( dir ), template_dir(template)
    end

    desc "project uninstall TEMPLATE_NAME", "Uninstall a project template."
    def uninstall( template )
      FileUtils.rm_r template_dir(template)
    end

    desc "project new DIRECTORY TEMPLATE_NAME", "Create a new project by template."
    def new( dir, template )
      directory template_dir(template), File.expand_path( dir )
    end

    private

    def template_dir( template )
      File.join( Gator::Util.project_template_root, template )
    end

  end
end<commit_msg>Implemented project template directory and project tasks with commands: install, uninstall, new, wipe & list.<commit_after>require "thor"
require "fileutils"
require File.dirname(__FILE__) + '/util'

module Gator
  class Project < Thor
    include Thor::Actions

    def self.source_root
      Gator::Util.project_template_root
    end

    desc "project install DIRECTORY TEMPLATE_NAME", "Install a project template."
    def install( dir, template=nil )
      entries = directory_entries dir
      template ||= File.expand_path( File.dirname(entries.first) ).split(File::SEPARATOR).last
      empty_directory template_dir(template)
      FileUtils.cp_r entries, template_dir(template)
    end

    desc "project uninstall TEMPLATE_NAME", "Uninstall a project template."
    def uninstall( template )
      FileUtils.rm_r template_dir(template)
    end

    desc "project new DIRECTORY TEMPLATE_NAME", "Create a new project by template."
    def new( dir, template )
      directory template_dir(template), File.expand_path( dir )
    end

    desc "project wipe", "Delete all project templates."
    def wipe
      template_root_entries.each { |e| FileUtils.rm_r e }
    end

    desc "project list [SEARCH]", "Lists project templates."
    def list(search=nil)
      entries = template_root_entries
      entries = entries.select { |e| e.include?(search) } unless search.nil?
      entries.each {|e| say "  #{e}" }
      say "No templates found.", :blue if entries.empty?
    end

    private

    def template_dir( template )
      File.join( Gator::Util.project_template_root, template )
    end

    def directory_entries( dir, join_with_dir=true )
      entries = Dir.entries(dir)
      entries.delete(".")
      entries.delete("..")
      entries.collect! { |e| File.join(dir, e) } if join_with_dir
      entries
    end

    def template_root_entries
      directory_entries Gator::Util.project_template_root, false
    end

  end
end
{'fraction_non_alphanumeric': 0.08880442294402212, 'fraction_numerical': 0.0, 'mean_word_length': 3.3338323353293413, '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': '5284212', 'n_tokens_mistral': 860, 'n_tokens_neox': 826, 'n_words': 247}