<commit_before>module Views
  class Base < Fortitude::Widget
    doctype :html5

    private

    def row(args = {}, &block)
      classes = [:row]
      classes += Array(args.fetch(:class, []))
      div(args.merge(class: classes), &block)
    end

    def column(size = :'small-12', args = {}, &block)
      classes = [:columns, size]
      classes += Array(args.fetch(:class, []))
      div(args.merge(class: classes), &block)
    end

    def full_row
      row { column { yield } }
    end

    def buttonish(size = :small, *extras)
      result = %i[button radius]
      result << size
      result.concat extras
    end

    def with_errors(object, field)
      errors = object.errors[field]
      if errors.any?
        div(class: :error) {
          yield
          small(class: :error) { text errors.to_sentence }
        }
      else
        yield
      end
    end

    def to_json(*args)
      as_json(*args).to_json
    end
  end
end<commit_msg>Clean up base view class<commit_after>module Views
  class Base < Fortitude::Widget
    doctype :html5

    private

    def row(args = {}, &block)
      div(add_classes(args, [:row]), &block)
    end

    def column(size = :'small-12', args = {}, &block)
      div(add_classes(args, [:columns, size]), &block)
    end

    def full_row
      row { column { yield } }
    end

    def buttonish(size = :small, *extras)
      result = %i[button radius]
      result << size
      result.concat extras
    end

    def with_errors(object, field)
      errors = object.errors[field]
      if errors.any?
        div(class: :error) {
          yield
          small(errors.to_sentence, class: :error)
        }
      else
        yield
      end
    end

    def to_json(*args)
      as_json(*args).to_json
    end

    def add_classes(args, classes)
      classes += Array(args.fetch(:class, []))
      args.merge(class: classes)
    end
  end
end
{'fraction_non_alphanumeric': 0.12138728323699421, 'fraction_numerical': 0.0031529164477141357, 'mean_word_length': 2.11620294599018, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2176587', 'n_tokens_mistral': 624, 'n_tokens_neox': 598, 'n_words': 152}