<commit_before>require 'spreadsheet'

module Spreadsheet
  module Rails
    module SpreadsheetHelper

      def excel_document(opts={})
        download = opts.delete(:force_download)
        filename = opts.delete(:filename)
        template_path = opts.delete(:template_path)
        workbook = template_path ? Spreadsheet.open(template_path) : Spreadsheet::Workbook.new
        yield(workbook)
        disposition(download, filename) if (download || filename)
        workbook
      end

      def disposition(download, filename)
        download = true if (filename && download == nil)
        disposition = download ? "attachment;" : "inline;"
        disposition += " filename=#{filename}" if filename
        headers["Content-Disposition"] = disposition
      end
    end

    class TemplateHandler
      class_attribute :default_format<commit_msg>Add an option for a own renderer of the workbook.<commit_after>require 'spreadsheet'

module Spreadsheet
  module Rails
    module SpreadsheetHelper

      def excel_document(opts={})
        download = opts.delete(:force_download)
        filename = opts.delete(:filename)
        template_path = opts.delete(:template_path)
        workbook = template_path ? Spreadsheet.open(template_path) : (opts.delete(:renderer) || Spreadsheet::Workbook).new
        yield(workbook)
        disposition(download, filename) if (download || filename)
        workbook
      end

      def disposition(download, filename)
        download = true if (filename && download == nil)
        disposition = download ? "attachment;" : "inline;"
        disposition += " filename=#{filename}" if filename
        headers["Content-Disposition"] = disposition
      end
    end

    class TemplateHandler
      class_attribute :default_format
{'fraction_non_alphanumeric': 0.09188275084554678, 'fraction_numerical': 0.0, 'mean_word_length': 3.089861751152074, '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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1156841', 'n_tokens_mistral': 462, 'n_tokens_neox': 438, 'n_words': 115}