<commit_before>require 'cabar/renderer'


module Cabar

  # Base class for rendering methods of Components and Facets.
  class Renderer

    # Abstract superclass for rendering environment variables.
    class EnvVar < self
      attr_accessor :env_var_prefix

      def initialize *args
        @env_var_prefix ||= ''
        super
      end


      # Calls Cabar.path_sep.
      def path_sep
        Cabar.path_sep
      end


      # Renders a Resolver object,
      # Using the Resolver's current required_components_dependencies.
      #
      def render_Resolver x
        comment "Cabar Resolver Environment"

        comps = x.required_component_dependencies
        
        self.env_var_prefix = "CABAR_"
        setenv "TOP_LEVEL_COMPONENTS", x.top_level_components.map{ | c | c.name }.join(" ")
        
        setenv "REQUIRED_COMPONENTS", comps.map{ | c | c.name }.join(" ")
        render comps

        render x.facets.values
        
        render_configuration_env_var x.resolver.configuration
      end
      

      def render_Selection x
        if _options[:selected]
          comment "Cabar Selection Environment"
          setenv "SELECTED_COMPONENTS", x.map{ | c | c.name }.join(" ")
          render x.to_a
          render_configuration_env_var x.resolver.configuration
        else
          render x.resolver
        end
      end

<commit_msg>Using x as a variable name is a cop-out... sometimes.<commit_after>require 'cabar/renderer'


module Cabar

  # Base class for rendering methods of Components and Facets.
  class Renderer

    # Abstract superclass for rendering environment variables.
    class EnvVar < self
      attr_accessor :env_var_prefix

      def initialize *args
        @env_var_prefix ||= ''
        super
      end


      # Calls Cabar.path_sep.
      def path_sep
        Cabar.path_sep
      end


      # Renders a Resolver object,
      # Using the Resolver's current required_components_dependencies.
      #
      def render_Resolver resolver
        comment "Cabar Resolver Environment"

        comps = resolver.required_component_dependencies
        
        self.env_var_prefix = "CABAR_"
        setenv "TOP_LEVEL_COMPONENTS", resolver.top_level_components.map{ | c | c.name }.join(" ")
        
        setenv "REQUIRED_COMPONENTS", comps.map{ | c | c.name }.join(" ")
        render comps

        render resolver.facets.values
        
        render_configuration_env_var resolver.configuration
      end
      

      def render_Selection selection
        if _options[:selected]
          comment "Cabar Selection Environment"
          setenv "SELECTED_COMPONENTS", selection.map{ | c | c.name }.join(" ")
          render selection.to_a

          render_configuration_env_var selection.resolver.configuration
        else
          render selection.resolver
        end
      end


{'fraction_non_alphanumeric': 0.0664568030779993, 'fraction_numerical': 0.0, 'mean_word_length': 2.1463146314631465, 'pattern_counts': {'":': 0, '<': 5, '<?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': '345786', 'n_tokens_mistral': 834, 'n_tokens_neox': 793, 'n_words': 211}