<commit_before>require 'ztk'

require 'lxc/version'

# Top-Level LXC Class
#
# @author <NAME> <<EMAIL>ary AT jovelabs DOT com>
class LXC

  # Top-Level Error Class
  class LXCError < StandardError; end

  autoload :Config, 'lxc/config'
  autoload :Container, 'lxc/container'

  # Controls if sudo is prefixed on all executed commands.
  #
  # @overload use_sudo=(value)
  #   Sets if all executed commands should be prefixed with sudo.
  #   @param [Boolean] value
  #
  # @overload use_sudo
  #   Gets if we are prefixing all executed commands with sudo.
  #
  # @return [Boolean] Returns true if we are prefixing commands with "sudo";
  #   otherwise false.
  attr_accessor :use_sudo

  # Controls if executed commands run locally or remotely via a Net::SSH
  # Session.
  #
  # @overload use_ssh=(value)
  #   Sets if all executed commands should be run locally or remotely.
  #   To force commands to run locally, assign a value of nil (default).
  #   To force commands to run remotely, assign a valid, active, Net::SSH
  #   Session.
  #
  # @overload use_ssh
  #   Gets if we are executing commands locally or remotely.
  #
  # @return [Net::SSH::Connection::Session] Returns nil if disabled; otherwise
  #   returns the assigned Net::SSH Session object.
  attr_accessor :use_ssh

  # RegEx pattern for extracting the LXC Version from the "lxc-version" command
  # output.
  REGEX_VERSION = /^lxc version:\s+([\w\W]+)$/

  # SED command for removing ANSI colors
  #
  # @see http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed CommandLineFu - Remove Color Codes (Special Characters) with SED
  SED_REMOVE_ANSI = %q(sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")

  # @param [Hash] options Options hash.
  # @option options [Boolean] :use_sudo (false) Whether or not to prefix all
  #   commands with 'sudo'.
  # @option options [Net::SSH,ZTK::SSH,nil] :use_ssh (nil) Whether or not to
  #   execute all commands remotely via an SSH connection.
  def initialize(options={})
    @ui       = (options[:ui] || ZTK::UI.new)
    @use_sudo = (options[:use_sudo] || false)
    @use_ssh  = (options[:use_ssh] || nil)
  end

  # LXC configuration class
  #
  # Gets the LXC configuration class object
  #
  # @return [LXC::Config] Returns the LXC configuration object.
  def config
    @config ||= LXC::Config.new(self, "/etc/lxc/lxc.conf")
  end

  # Initialize container object
  #
  # Initalizes an LXC::Container class for the supplied container name.
  #
  # @param [String] name The container name to initalize.
  # @return [LXC::Container] Returns the container object.
  def container(name)
    LXC::Container.new(:lxc => self, :name => name)
  end
<commit_msg>removed sed command to strip ANSI since we now rely on ZTK::ANSI to do this for us<commit_after>require 'ztk'

require 'lxc/version'

# Top-Level LXC Class
#
# @author <NAME> <<EMAIL> jo<EMAIL>>
class LXC

  # Top-Level Error Class
  class LXCError < StandardError; end

  autoload :Config, 'lxc/config'
  autoload :Container, 'lxc/container'

  # Controls if sudo is prefixed on all executed commands.
  #
  # @overload use_sudo=(value)
  #   Sets if all executed commands should be prefixed with sudo.
  #   @param [Boolean] value
  #
  # @overload use_sudo
  #   Gets if we are prefixing all executed commands with sudo.
  #
  # @return [Boolean] Returns true if we are prefixing commands with "sudo";
  #   otherwise false.
  attr_accessor :use_sudo

  # Controls if executed commands run locally or remotely via a Net::SSH
  # Session.
  #
  # @overload use_ssh=(value)
  #   Sets if all executed commands should be run locally or remotely.
  #   To force commands to run locally, assign a value of nil (default).
  #   To force commands to run remotely, assign a valid, active, Net::SSH
  #   Session.
  #
  # @overload use_ssh
  #   Gets if we are executing commands locally or remotely.
  #
  # @return [Net::SSH::Connection::Session] Returns nil if disabled; otherwise
  #   returns the assigned Net::SSH Session object.
  attr_accessor :use_ssh

  # RegEx pattern for extracting the LXC Version from the "lxc-version" command
  # output.
  REGEX_VERSION = /^lxc version:\s+([\w\W]+)$/

  # @param [Hash] options Options hash.
  # @option options [Boolean] :use_sudo (false) Whether or not to prefix all
  #   commands with 'sudo'.
  # @option options [Net::SSH,ZTK::SSH,nil] :use_ssh (nil) Whether or not to
  #   execute all commands remotely via an SSH connection.
  def initialize(options={})
    @ui       = (options[:ui] || ZTK::UI.new)
    @use_sudo = (options[:use_sudo] || false)
    @use_ssh  = (options[:use_ssh] || nil)
  end

  # LXC configuration class
  #
  # Gets the LXC configuration class object
  #
  # @return [LXC::Config] Returns the LXC configuration object.
  def config
    @config ||= LXC::Config.new(self, "/etc/lxc/lxc.conf")
  end

  # Initialize container object
  #
  # Initalizes an LXC::Container class for the supplied container name.
  #
  # @param [String] name The container name to initalize.
  # @return [LXC::Container] Returns the container object.
  def container(name)
    LXC::Container.new(:lxc => self, :name => name)
  end

{'fraction_non_alphanumeric': 0.11104695919938413, 'fraction_numerical': 0.0025019245573518092, 'mean_word_length': 3.515204170286707, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '6143288', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1696, 'n_words': 579}