<commit_before>module Mcir
  # Instance representing your server (or whatever resource).
  class Instance
    attr_reader :mcir, :name, :config

    # Initializes a new instance object.
    # @param [Mcir::Core] mcir MCIR instance
    # @param [String, Symbol] name Name of the instance (in config).
    def initialize mcir, name
      @mcir = mcir
      @name = name.to_s.dup
      @config = @mcir.config["instances"][@name]

      # autocomplete configuration name
      unless @config
        avail_keys = @mcir.config["instances"].keys
        @name.to_s.split(".").each do |qchunk|
          avail_keys = avail_keys.grep(/#{Regexp.escape(qchunk)}/)
        end
        case avail_keys.length
        when 1
          @name = avail_keys.first
          @config = @mcir.config["instances"][@name]
          @mcir.debug "autodiscovered instance `#{@name}' from input `#{name}'"
        when 0
          raise ArgumentError, "instance `#{@name}' can't be resolved, does not exist (#{@mcir.config["instances"].keys})"
        else
          raise ArgumentError, "ambiguous instance name `#{@name}' matching #{avail_keys}"
        end
      end
    end

    include Getters, Paths, Commands, IO, Rcon

    # --------------------------------

    # Helper to call the block in the instance's home directory.
    #
    # @param [Proc] block Block to execute with the instance's home directory as `pwd`.
    def in_home &block
      old_home = Dir.getwd
      Dir.chdir(@config["home"])
      block.call
    ensure
      Dir.chdir(old_home)
    end<commit_msg>Fix empty instance commands<commit_after>module Mcir
  # Instance representing your server (or whatever resource).
  class Instance
    attr_reader :mcir, :name, :config

    # Initializes a new instance object.
    # @param [Mcir::Core] mcir MCIR instance
    # @param [String, Symbol] name Name of the instance (in config).
    def initialize mcir, name
      @mcir = mcir
      @name = name.to_s.dup
      @config = @mcir.config["instances"][@name]

      # autocomplete configuration name
      if !@config && @name.present?
        avail_keys = @mcir.config["instances"].keys
        @name.to_s.split(".").each do |qchunk|
          avail_keys = avail_keys.grep(/#{Regexp.escape(qchunk)}/)
        end
        case avail_keys.length
        when 1
          @name = avail_keys.first
          @config = @mcir.config["instances"][@name]
          @mcir.debug "autodiscovered instance `#{@name}' from input `#{name}'"
        when 0
          raise ArgumentError, "instance `#{@name}' can't be resolved, does not exist (#{@mcir.config["instances"].keys})"
        else
          raise ArgumentError, "ambiguous instance name `#{@name}' matching #{avail_keys}"
        end
      end
    end

    include Getters, Paths, Commands, IO, Rcon

    # --------------------------------

    # Helper to call the block in the instance's home directory.
    #
    # @param [Proc] block Block to execute with the instance's home directory as `pwd`.
    def in_home &block
      old_home = Dir.getwd
      Dir.chdir(@config["home"])
      block.call
    ensure
      Dir.chdir(old_home)
    end
{'fraction_non_alphanumeric': 0.1343521171601401, 'fraction_numerical': 0.0012734797835084368, 'mean_word_length': 2.367631296891747, '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': '6396851', 'n_tokens_mistral': 953, 'n_tokens_neox': 936, 'n_words': 277}