<commit_before>module AnsibleCredentialHelper::TextualSummary
  include TextualMixins::TextualName

  def textual_group_properties
    TextualGroup.new(_("Properties"), %i[name type created updated])
  end

  def textual_group_relationships
    TextualGroup.new(_("Relationships"), %i[repositories])
  end

  def textual_group_options
    options = []

    @record.type.constantize::API_ATTRIBUTES.each do |key, value|
      options << key

      define_singleton_method "textual_#{key}" do
        h = {:label => _(value[:label]), :title => _(value[:help_text])}
        h[:value] = attribute_value(value[:type], key, @record)
        h
      end
    end

    TextualGroup.new(_("Credential Options"), options)
  end

  def attribute_value(attr_type, key, rec)
    if attr_type == :password && (rec.try(key).present? || rec.options[key].present?)
      '●●●●●●●●'
    else
      rec.try(key) || rec.options[key]
    end
  end
  private :attribute_value

  def textual_group_smart_management
    TextualTags.new(_("Smart Management"), %i[tags])
  end

  def textual_type
    {:label => _("Authentication Type"), :value => ui_lookup(:model => @record.type)}
  end

  def textual_created
    {:label => _("Created On"), :value => format_timezone(@record.created_on)}
  end

  def textual_updated
    {:label => _("Updated On"), :value => format_timezone(@record.updated_on)}
  end

  def textual_repositories
    num = @record.number_of(:configuration_script_sources)
    h = {:label => _("Repositories"), :value => num}
    if role_allows?(:feature => "embedded_configuration_script_source_view") && num > 0
      h.update(:link  => url_for_only_path(:action => 'show', :id => @record, :display => 'repositories'),
               :title => _('Show all Repositories'))
    end
    h
  end<commit_msg>Fix the spec failures in the simplest way possible<commit_after>module AnsibleCredentialHelper::TextualSummary
  include TextualMixins::TextualName

  def textual_group_properties
    TextualGroup.new(_("Properties"), %i[name type created updated])
  end

  def textual_group_relationships
    TextualGroup.new(_("Relationships"), %i[repositories])
  end

  def textual_group_options
    options = []

    @record.type.constantize::API_ATTRIBUTES.each do |key, value|
      options << key

      define_singleton_method "textual_#{key}" do
        h = {:label => _(value[:label]), :title => _(value[:help_text])}
        h[:value] = attribute_value(value[:type], key, @record)
        h
      end
    end

    TextualGroup.new(_("Credential Options"), options)
  end

  def attribute_value(attr_type, key, rec)
    if attr_type == :password && (rec.try(key).present? || rec.options.try(:[], key).present?)
      '●●●●●●●●'
    else
      rec.try(key) || rec.options.try(:[], key)
    end
  end
  private :attribute_value

  def textual_group_smart_management
    TextualTags.new(_("Smart Management"), %i[tags])
  end

  def textual_type
    {:label => _("Authentication Type"), :value => ui_lookup(:model => @record.type)}
  end

  def textual_created
    {:label => _("Created On"), :value => format_timezone(@record.created_on)}
  end

  def textual_updated
    {:label => _("Updated On"), :value => format_timezone(@record.updated_on)}
  end

  def textual_repositories
    num = @record.number_of(:configuration_script_sources)
    h = {:label => _("Repositories"), :value => num}
    if role_allows?(:feature => "embedded_configuration_script_source_view") && num > 0
      h.update(:link  => url_for_only_path(:action => 'show', :id => @record, :display => 'repositories'),
               :title => _('Show all Repositories'))
    end
    h
  end
{'fraction_non_alphanumeric': 0.1440701177759518, 'fraction_numerical': 0.0005477951246233908, 'mean_word_length': 3.8758344459279037, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, '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': '1458811', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1134, 'n_words': 251}