<commit_before>module ActiveAdmin
  module Views

    class AttributesTable < ActiveAdmin::Component
      builder_method :attributes_table_for

      attr_reader :resource

      def build(record, *attrs)
        @record = record
        super(:for => @record)
        @table = table
        rows(*attrs)
      end

      def rows(*attrs)
        attrs.each {|attr| row(attr) }
      end

      def row(attr, &block)
        @table << tr do
          th do
            header_content_for(attr)
          end
          td do
            content_for(block || attr)
          end
        end
      end

      protected

      def default_id_for_prefix
        'attributes_table'
      end

      def header_content_for(attr)
        attr.to_s.titleize
      end

      def empty_value
        span I18n.t('active_admin.empty'), :class => "empty"
      end

      def content_for(attr_or_proc)
        value = case attr_or_proc
                when Proc
                  attr_or_proc.call
                else
                  content_for_attribute(attr_or_proc)
                end
        value = pretty_format(value)
        value == "" || value == nil ? empty_value : value
      end

      def content_for_attribute(attr)
        if attr.to_s =~ /^([\w]+)_id$/ && @record.respond_to?($1.to_sym)
          content_for_attribute($1)
        else
          @record.send(attr.to_sym)
        end
      end
    end

  end
end
<commit_msg>I18n for the show page<commit_after>module ActiveAdmin
  module Views

    class AttributesTable < ActiveAdmin::Component
      builder_method :attributes_table_for

      attr_reader :resource

      def build(record, *attrs)
        @record = record
        super(:for => @record)
        @table = table
        rows(*attrs)
      end

      def rows(*attrs)
        attrs.each {|attr| row(attr) }
      end

      def row(attr, &block)
        @table << tr do
          th do
            header_content_for(attr)
          end
          td do
            content_for(block || attr)
          end
        end
      end

      protected

      def default_id_for_prefix
        'attributes_table'
      end

      def header_content_for(attr)
        @record.class.respond_to?(:human_attribute_name) ? @record.class.human_attribute_name(attr).titleize : attr.to_s.titleize
      end

      def empty_value
        span I18n.t('active_admin.empty'), :class => "empty"
      end

      def content_for(attr_or_proc)
        value = case attr_or_proc
                when Proc
                  attr_or_proc.call
                else
                  content_for_attribute(attr_or_proc)
                end
        value = pretty_format(value)
        value == "" || value == nil ? empty_value : value
      end

      def content_for_attribute(attr)
        if attr.to_s =~ /^([\w]+)_id$/ && @record.respond_to?($1.to_sym)
          content_for_attribute($1)
        else
          @record.send(attr.to_sym)
        end
      end
    end

  end
end

{'fraction_non_alphanumeric': 0.08338914936369725, 'fraction_numerical': 0.003348961821835231, 'mean_word_length': 1.6340388007054674, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6642437', 'n_tokens_mistral': 907, 'n_tokens_neox': 861, 'n_words': 194}