<commit_before># Methods needed to create a project.

require 'rubygems'
require File.expand_path(File.dirname(__FILE__) + "/errors")

module Suspenders
  class Create
    attr_accessor :project_path, :repo

    def self.run!(project_path, repo)
      creator = self.new(project_path, repo)
      creator.create_project!
    end

    def initialize(project_path, repo)
      self.project_path = project_path
      validate_project_path
      validate_project_name
      self.repo = repo if present?(repo)
    end

    def create_project!
      command = <<-COMMAND
        rails #{rails_version} new #{project_path} \
          --template=#{template} \
          --skip-test-unit \
          --skip-prototype
      COMMAND
      command_with_repo = if repo
                            "REPO='#{repo}' #{command}"
                          else
                            command
                          end
      exec(command_with_repo)
    end

    private

    def validate_project_name
      project_name = File.basename(project_path)
      unless project_name =~ /^[a-z0-9_]+$/
        raise InvalidInput.new("Project name must only contain [a-z0-9_]")
      end<commit_msg>Use Postgres by default.<commit_after># Methods needed to create a project.

require 'rubygems'
require File.expand_path(File.dirname(__FILE__) + "/errors")

module Suspenders
  class Create
    attr_accessor :project_path, :repo

    def self.run!(project_path, repo)
      creator = self.new(project_path, repo)
      creator.create_project!
    end

    def initialize(project_path, repo)
      self.project_path = project_path
      validate_project_path
      validate_project_name
      self.repo = repo if present?(repo)
    end

    def create_project!
      command = <<-COMMAND
        rails #{rails_version} new #{project_path} \
          --template=#{template} \
          --skip-test-unit \
          --skip-prototype \
          --database=postgresql
      COMMAND
      command_with_repo = if repo
                            "REPO='#{repo}' #{command}"
                          else
                            command
                          end
      exec(command_with_repo)
    end

    private

    def validate_project_name
      project_name = File.basename(project_path)
      unless project_name =~ /^[a-z0-9_]+$/
        raise InvalidInput.new("Project name must only contain [a-z0-9_]")
      end
{'fraction_non_alphanumeric': 0.09098462816784379, 'fraction_numerical': 0.0033236393851267137, 'mean_word_length': 1.9801980198019802, 'pattern_counts': {'":': 0, '<': 7, '<?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': '860474', 'n_tokens_mistral': 696, 'n_tokens_neox': 683, 'n_words': 157}