<commit_before>require 'stacks/namespace'
require 'stacks/machine_def_container'

class Stacks::Environment
  attr_reader :domain_suffix
  attr_reader :environments
  attr_reader :parent
  attr_reader :name
  attr_reader :options

  include Stacks::MachineDefContainer

  def initialize(name, options, parent, environments, stack_procs)
    @name = name
    @options = options
    @environments = environments
    @stack_procs = stack_procs
    @definitions = {}
    @persistent_storage_supported =
      options[:persistent_storage_supported].nil? ? true : options[:persistent_storage_supported]
    @every_machine_destroyable =
      options[:every_machine_destroyable].nil? ? false : options[:every_machine_destroyable]
    @primary_site = options[:primary_site]
    @secondary_site = options[:secondary_site]
    @domain_suffix = option[:domain_suffix] rescue 'net.local'
    @parent = parent
    @children = []
  end

  def child?(environment)
    children.include?(environment)
  end

  def child_or_self?(environment)
    children.include?(environment) || environment == self
  end

  def sub_environments
    children.select { |node| node.is_a?(Stacks::Environment) }
  end

  def sub_environment_names
    names = []
    sub_environments.each do |sub_environment|
      names << sub_environment.name
    end
    names
  end

  def domain(fabric, network = nil)
    case network
    when nil, :prod
      "#{fabric}.#{@domain_suffix}"
    else
      "#{network}.#{fabric}.#{@domain_suffix}"
    end
  end

  def environment
    self
  end

  def parent?
    !@parent.nil?
  end<commit_msg>rpearce: Fix domain suffix when fabric is local  * We don't want local.dev.mgmt.net.local we just want  * dev.mgmt.net.local<commit_after>require 'stacks/namespace'
require 'stacks/machine_def_container'

class Stacks::Environment
  attr_reader :domain_suffix
  attr_reader :environments
  attr_reader :parent
  attr_reader :name
  attr_reader :options

  include Stacks::MachineDefContainer

  def initialize(name, options, parent, environments, stack_procs)
    @name = name
    @options = options
    @environments = environments
    @stack_procs = stack_procs
    @definitions = {}
    @persistent_storage_supported =
      options[:persistent_storage_supported].nil? ? true : options[:persistent_storage_supported]
    @every_machine_destroyable =
      options[:every_machine_destroyable].nil? ? false : options[:every_machine_destroyable]
    @primary_site = options[:primary_site]
    @secondary_site = options[:secondary_site]
    @domain_suffix = options[:domain_suffix] || 'net.local'
    @parent = parent
    @children = []
  end

  def child?(environment)
    children.include?(environment)
  end

  def child_or_self?(environment)
    children.include?(environment) || environment == self
  end

  def sub_environments
    children.select { |node| node.is_a?(Stacks::Environment) }
  end

  def sub_environment_names
    names = []
    sub_environments.each do |sub_environment|
      names << sub_environment.name
    end
    names
  end

  def domain(fabric, network = nil)
    case fabric
    when 'local'
      case network
      when nil, :prod
        "#{@domain_suffix}"
      else
        "#{network}.#{@domain_suffix}"
      end
    else
      case network
      when nil, :prod
        "#{fabric}.#{@domain_suffix}"
      else
        "#{network}.#{fabric}.#{@domain_suffix}"
      end
    end
  end

  def environment
    self
  end

  def parent?
    !@parent.nil?
  end
{'fraction_non_alphanumeric': 0.09934154022330376, 'fraction_numerical': 0.0, 'mean_word_length': 3.5792922673656618, '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': '4593690', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1059, 'n_words': 232}