<commit_before>require 'generamba/template/installer/rambaspec_validator.rb'

module Generamba
  class Installer
    def install_local_template(template_name, local_path)
      rambaspec_exist = Generamba::RambaspecValidator.validate_spec_existance(template_name, local_path)

      if rambaspec_exist == false
        error_description = "Cannot find #{template_name + '.rambaspec'} in the specified directory. Try another path or name."
        raise StandardError.new(error_description)
      end

      rambaspec_valid = Generamba::RambaspecValidator.validate_spec(template_name, local_path)
      if rambaspec_valid == false
        error_description = "#{template_name + '.rambaspec'} is not valid."
        raise StandardError.new(error_description)
      end

      puts('The local path is right! Installing template to the current project directory...')
      FileUtils.mkdir_p template_name
      FileUtils.copy_entry(local_path, Pathname.new(template_name))

      rambafile = YAML.load_file('Rambafile')

      templates = rambafile['project_templates'] ? SortedSet.new(rambafile['project_templates']) : SortedSet.new
      templates.add(template_name)

      rambafile['project_templates'] = templates.to_a
      File.open('Rambafile', 'w') {|f| f.write rambafile.to_yaml }

      puts("Installing is finished! Now you can call: generamba gen #{template_name}")
    end
  end<commit_msg>Added install_templates method, that queries the given Rambafile<commit_after>require 'generamba/template/installer/rambaspec_validator.rb'

module Generamba
  class Installer
    def install_templates
      rambafile = YAML.load_file('Rambafile')

      templates = rambafile['project_templates']
      if !templates || templates.count == 0
        error_description = 'You must specify at least one template in Rambafile under the key *project_templates*'
        raise StandardError.new(error_description)
      end

      local_templates = []
      remote_templates = []
      templates.each do |template|
        if template['local']
          local_templates.push(template)
        end

        if template['git']
          remote_templates.push(template)
        end

      end


    end

    def install_local_template(template_name, local_path)
      rambaspec_exist = Generamba::RambaspecValidator.validate_spec_existance(template_name, local_path)

      if rambaspec_exist == false
        error_description = "Cannot find #{template_name + '.rambaspec'} in the specified directory. Try another path or name."
        raise StandardError.new(error_description)
      end

      rambaspec_valid = Generamba::RambaspecValidator.validate_spec(template_name, local_path)
      if rambaspec_valid == false
        error_description = "#{template_name + '.rambaspec'} is not valid."
        raise StandardError.new(error_description)
      end

      puts('The local path is right! Installing template to the current project directory...')
      FileUtils.mkdir_p template_name
      FileUtils.copy_entry(local_path, Pathname.new(template_name))

      rambafile = YAML.load_file('Rambafile')

      templates = rambafile['project_templates'] ? SortedSet.new(rambafile['project_templates']) : SortedSet.new
      templates.add(template_name)

      rambafile['project_templates'] = templates.to_a
      File.open('Rambafile', 'w') {|f| f.write rambafile.to_yaml }

      puts("Installing is finished! Now you can call: generamba gen #{template_name}")
    end
  end
{'fraction_non_alphanumeric': 0.08787093056755978, 'fraction_numerical': 0.0002881014116969173, 'mean_word_length': 3.7046070460704605, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3951763', 'n_tokens_mistral': 1011, 'n_tokens_neox': 1010, 'n_words': 228}