<commit_before>require 'erb'
require 'fileutils'
require 'securerandom'

module Pakyow
  module Generators
    class AppGenerator
      class << self
        def start(destination)
          generator = self.new(destination)
          generator.build
        end
      end

      FILENAME_TRANSLATIONS = {
        'rspec' => '.rspec',
        'gitignore' => '.gitignore',
        'env' => '.env',
        'env.example' => '.env.example'
      }

      def initialize(dest)
        @src = "#{File.expand_path('../', __FILE__)}/templates/."
        @dest = dest
      end

      def build
        puts "Generating project: #{@dest}"

        if !File.directory?(@dest) || (Dir.entries(@dest) - ['.', '..']).empty?
          copy
        else
          print "The folder '#{@dest}' is in use. Would you like to populate it anyway? [Yn] "

          if gets.chomp! == 'Y'
            copy
          else
            puts "Aborted!"
            exit
          end
        end

        exec
        puts "Done! Run `cd #{@dest}; pakyow server` to get started!"
      end

      protected

      def copy
        FileUtils.mkdir(@dest) unless File.exists?(@dest)

        Dir.glob(File.join(@src, '**', '*')).each do |path|
          relative_path = path[@src.length..-1]
          generated_path = File.join(@dest, File.dirname(relative_path), translated_filename(File.basename(relative_path)))

          if File.directory?(path)
            FileUtils.mkdir(generated_path)
            next<commit_msg>Put ARGV clear back in before call to gets<commit_after>require 'erb'
require 'fileutils'
require 'securerandom'

module Pakyow
  module Generators
    class AppGenerator
      class << self
        def start(destination)
          generator = self.new(destination)
          generator.build
        end
      end

      FILENAME_TRANSLATIONS = {
        'rspec' => '.rspec',
        'gitignore' => '.gitignore',
        'env' => '.env',
        'env.example' => '.env.example'
      }

      def initialize(dest)
        @src = "#{File.expand_path('../', __FILE__)}/templates/."
        @dest = dest
      end

      def build
        puts "Generating project: #{@dest}"

        if !File.directory?(@dest) || (Dir.entries(@dest) - ['.', '..']).empty?
          copy
        else
          ARGV.clear
          print "The folder '#{@dest}' is in use. Would you like to populate it anyway? [Yn] "

          if gets.chomp! == 'Y'
            copy
          else
            puts "Aborted!"
            exit
          end
        end

        exec
        puts "Done! Run `cd #{@dest}; pakyow server` to get started!"
      end

      protected

      def copy
        FileUtils.mkdir(@dest) unless File.exists?(@dest)

        Dir.glob(File.join(@src, '**', '*')).each do |path|
          relative_path = path[@src.length..-1]
          generated_path = File.join(@dest, File.dirname(relative_path), translated_filename(File.basename(relative_path)))

          if File.directory?(path)
            FileUtils.mkdir(generated_path)
            next
{'fraction_non_alphanumeric': 0.1323915900131406, 'fraction_numerical': 0.000657030223390276, 'mean_word_length': 1.8272980501392757, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5703014', 'n_tokens_mistral': 912, 'n_tokens_neox': 883, 'n_words': 222}