<commit_before>require "multi_json"

require "rack/info/version"
require "rack/info/config"
require "rack/info/html_formatter"
require "rack/info/html_comment"
require "rack/info/html_meta_tag"

module Rack
  class Info
    CONTENT_TYPE_HEADER = 'Content-Type'
    HTML_CONTENT_TYPE = 'text/html'

    def self.header_name(str)
      "X-" + str.to_s.split(/[-_ ]/).map(&:capitalize).join("-")
    end

    def self.header_value(obj)
      obj.to_s
    end

    attr_reader :app, :config, :metadata

    def initialize(app, hsh_or_config = {})
      @app = app
      @config = Config.from(hsh_or_config)
      @data_headers = to_headers(@config.data)
    end

    def call(env)
      return app.call(env) unless config.enabled?(env)
      return json_rsp if config.path == env["PATH_INFO"]

      status, headers, body = @app.call(env)
      headers.merge!(@data_headers) if config.add_headers?(env, [status, headers, body])
      if html?(headers) && config.add_html?(env, [status, headers, body])
        body = add_html(body)
      end

      [status, headers, body]<commit_msg>Remove unused accessor<commit_after>require "multi_json"

require "rack/info/version"
require "rack/info/config"
require "rack/info/html_formatter"
require "rack/info/html_comment"
require "rack/info/html_meta_tag"

module Rack
  class Info
    CONTENT_TYPE_HEADER = 'Content-Type'
    HTML_CONTENT_TYPE = 'text/html'

    def self.header_name(str)
      "X-" + str.to_s.split(/[-_ ]/).map(&:capitalize).join("-")
    end

    def self.header_value(obj)
      obj.to_s
    end

    attr_reader :app, :config

    def initialize(app, hsh_or_config = {})
      @app = app
      @config = Config.from(hsh_or_config)
      @data_headers = to_headers(@config.data)
    end

    def call(env)
      return app.call(env) unless config.enabled?(env)
      return json_rsp if config.path == env["PATH_INFO"]

      status, headers, body = @app.call(env)
      headers.merge!(@data_headers) if config.add_headers?(env, [status, headers, body])
      if html?(headers) && config.add_html?(env, [status, headers, body])
        body = add_html(body)
      end

      [status, headers, body]
{'fraction_non_alphanumeric': 0.13438368860055608, 'fraction_numerical': 0.0, 'mean_word_length': 3.266798418972332, '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': '2831986', 'n_tokens_mistral': 758, 'n_tokens_neox': 739, 'n_words': 154}