<commit_before>module Ariane
  # Adds the ariane helper to controllers.
  module ControllerHelper

    # Internal: Sets a hash of cumb levels
    #
    # levels - Hash of crumb levels for actions
    #
    # Sets a hash of crumb levels for actions that require custom levels
    #
    # Returns nothing.
    def set_crumb_levels(levels)
      @crumb_levels = levels
    end

    # Internal: Sets the Ariane environment
    #
    # Sets the Ariane per request environment as well assigns the session hash.
    #
    # Returns Ariane.breadcrumb
    def ariane
      if !Ariane.request_env || Ariane.request != request.object_id
        Ariane.request     = request.object_id
        Ariane.request_env = request.env
        Ariane.session     = session if Ariane.dynamic_breadcrumb
      end

      Ariane.breadcrumb
    end

    # Public: Controller helper method for auto creation of breadcrums.
    #
    # Automatically sets the breadcrumb based on controller and action names.
    #
    # Returns nothing
    def auto_set_breadcrumb
      ariane.add("Home", root_path, 1) if ariane.crumbs.empty? 
      
      if self.action_name == "index"
        name = self.controller_name.gsub(/_/, " ").capitalize
        level = get_level(2)
      else
        name = self.action_name.capitalize + " " + self.controller_name.singularize.gsub(/_/, " ").capitalize
        level = get_level(3)
      end

      ariane.add(name, request.fullpath, level)
    end



    # Private: Helper method to retrieve a crumb level from the @crumb_levels hash 
    # if it exists.
    #
    # Returns level
    def get_level(default)
      return default unless @crumb_levels
      action = self.action_name.to_sym
      @crumb_levels[action] || default
    end

    private :get_level

  end
end

ActionController::Base.send :include, Ariane::ControllerHelper<commit_msg>More refactoring and code clean-up.<commit_after>module Ariane
  # Adds the ariane helper to controllers.
  module ControllerHelper

    # Internal: Sets a hash of cumb levels
    #
    # levels - Hash of crumb levels for actions
    #
    # Sets a hash of crumb levels for actions that require custom levels
    #
    # Returns nothing.
    def set_crumb_levels(levels)
      @crumb_levels = levels
    end

    # Internal: Sets the Ariane environment
    #
    # Sets the Ariane per request environment as well assigns the session hash.
    #
    # Returns Ariane.breadcrumb
    def ariane
      if !Ariane.request_env || Ariane.request != request.object_id
        Ariane.request     = request.object_id
        Ariane.request_env = request.env
        Ariane.session     = session if Ariane.dynamic_breadcrumb
      end

      Ariane.breadcrumb
    end

    # Public: Controller helper method for auto creation of breadcrums.
    #
    # Automatically sets the breadcrumb based on controller and action names.
    #
    # Returns nothing
    def auto_set_breadcrumb
      ariane.add("Home", root_path, 1) if ariane.crumbs.empty? 
      
      if self.action_name == "index"
        name = controller_name.titleize
        level = get_level || 2
      else
        name = "#{action_name.titleize} #{controller_name.singularize.titleize}"
        level = get_level || 3
      end

      ariane.add(name, request.fullpath, level)
    end



    # Private: Helper method to retrieve a crumb level from the @crumb_levels hash 
    # if it exists.
    #
    # Returns level
    def get_level
      @crumb_levels[self.action_name.to_sym] if @crumb_levels
    end

    private :get_level

  end
end

ActionController::Base.send :include, Ariane::ControllerHelper
{'fraction_non_alphanumeric': 0.06984478935698447, 'fraction_numerical': 0.0016629711751662971, 'mean_word_length': 2.5209756097560976, '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': '1065959', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1053, 'n_words': 322}