<commit_before>module Refinery
  module Helpers
    module MenuHelper

      # Adds conditional caching
      def cache_if(condition, name = {}, &block)
        if condition
          cache(name, &block)
        else
          yield
        end

        # for <%= style helpers vs <% style
        nil
      end

      # This was extracted from app/views/shared/_menu_branch.html.erb
      # to remove the complexity of that template by reducing logic in the view.
      def css_for_menu_branch(item, counter, sibling_count = nil, collection = nil, selected_item = nil, warning = true)

        Refinery.deprecate({
          :what => 'css_for_menu_branch',
          :when => '1.1',
          :replacement => 'menu_branch_css(local_assigns)',
          :caller => caller
        }) if warning

        Refinery.deprecate(:what => 'collection', :when => '1.1', :caller => caller) if collection
        Refinery.deprecate(:what => 'selected_item', :when => '1.1', :caller => caller) if selected_item

        css = []
        css << "selected" if selected_page_or_descendant_page_selected?(item, collection, selected_item)
        css << "first" if counter == 0
        if (sibling_count ? (counter == sibling_count) : (item.rgt == item.parent.rgt - 1))
          $stdout.puts "sibling_count: #{sibling_count}"
          $stdout.puts "counter: #{counter}"
          $stdout.puts "item: #{item.inspect}"
          $stdout.puts "parent: #{item.parent.inspect}"
          css << "last"
        end
        css
      end

      # New method which accepts the local_assigns hash.
      # This maps to the older css_for_menu_branch method.
      def menu_branch_css(local_assigns)<commit_msg>Well, I *was* debugging.<commit_after>module Refinery
  module Helpers
    module MenuHelper

      # Adds conditional caching
      def cache_if(condition, name = {}, &block)
        if condition
          cache(name, &block)
        else
          yield
        end

        # for <%= style helpers vs <% style
        nil
      end

      # This was extracted from app/views/shared/_menu_branch.html.erb
      # to remove the complexity of that template by reducing logic in the view.
      def css_for_menu_branch(item, counter, sibling_count = nil, collection = nil, selected_item = nil, warning = true)

        Refinery.deprecate({
          :what => 'css_for_menu_branch',
          :when => '1.1',
          :replacement => 'menu_branch_css(local_assigns)',
          :caller => caller
        }) if warning

        Refinery.deprecate(:what => 'collection', :when => '1.1', :caller => caller) if collection
        Refinery.deprecate(:what => 'selected_item', :when => '1.1', :caller => caller) if selected_item

        css = []
        css << "selected" if selected_page_or_descendant_page_selected?(item, collection, selected_item)
        css << "first" if counter == 0
        css << "last" if (sibling_count ? (counter == sibling_count) : (item.rgt == item.parent.rgt - 1))
        css
      end

      # New method which accepts the local_assigns hash.
      # This maps to the older css_for_menu_branch method.
      def menu_branch_css(local_assigns)
{'fraction_non_alphanumeric': 0.10875079264426125, 'fraction_numerical': 0.0050729232720355105, 'mean_word_length': 2.418201516793066, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '2259170', 'n_tokens_mistral': 941, 'n_tokens_neox': 914, 'n_words': 259}