<commit_before># frozen_string_literal: true

module BootstrapHelper
  def menu_item(name = nil, path = '#', *args, &block)
    path = name || path if block_given?
    options = args.extract_options!
    options[:class] = [options[:class], 'nav-link'].join(' ')
    content_tag :li, class: "nav-item #{is_active?(path, options)}" do
      if block_given?
        name = path
        path = options
      end
      link_to name, path, options, &block
    end
  end

  def model_menu_item(model:, route:, icon: nil, number: nil, pluralize: nil)
    title = model.is_a?(Class) ? (pluralize || model.model_name.human.pluralize(:ru)) : model
    if icon
      menu_item route do
        concat icon_element icon
        concat ' '
        concat title
        if number && number != 0
          concat ' '
          concat(content_tag(:span, number.to_s, class: 'badge danger'))
        end
      end
    else
      menu_item title, route
    end
  end

  private<commit_msg>Added dropdown method<commit_after># frozen_string_literal: true

module BootstrapHelper
  def menu_item(name = nil, path = '#', *args, &block)
    path = name || path if block_given?
    options = args.extract_options!
    options[:class] = [options[:class], 'nav-link'].join(' ')
    content_tag :li, class: "nav-item #{is_active?(path, options)}" do
      if block_given?
        name = path
        path = options
      end
      link_to name, path, options, &block
    end
  end

  def model_menu_item(model:, route:, icon: nil, number: nil, pluralize: nil)
    title = model.is_a?(Class) ? (pluralize || model.model_name.human.pluralize(:ru)) : model
    if icon
      menu_item route do
        concat icon_element icon
        concat ' '
        concat title
        if number && number != 0
          concat ' '
          concat(content_tag(:span, number.to_s, class: 'badge danger'))
        end
      end
    else
      menu_item title, route
    end
  end

  def dropdown(text, icon = nil, &block)
    content_tag :li, class: :drowdown do
      concat(link_to('#', class: 'dropdown-toggle', data: { toggle: :dropdown }) do
        if icon
          concat content_tag :span, '', class: "glyphicon glyphicon-#{icon}"
          concat ' '
        end
        concat text
        unless icon
          concat ' '
          concat content_tag :span, '', class: :caret
        end
      end)
      concat(content_tag(:ul, class: 'dropdown-menu') do
        yield block
      end)
    end
  end


  private
{'fraction_non_alphanumeric': 0.11321514907332796, 'fraction_numerical': 0.0008058017727639, 'mean_word_length': 2.3599458728010827, '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': '231857', 'n_tokens_mistral': 790, 'n_tokens_neox': 759, 'n_words': 221}