<commit_before>module ExecJS::Xtrn::Rack
  Formats=YAML.load <<-EOY
    -:
      mime: text/x-yaml
      dump: YAML
    json:
      mime: appication/json
      dump: JSON
  EOY

  def self.stats
    ExecJS::Xtrn.stats.as_json
  end

  def self.call req
    f=Formats[req['action_dispatch.request.path_parameters'][:format]] ||
      Formats['-']
    [
      200,
      {"Content-Type"=> f['mime']},
      [f['dump'].constantize.dump(stats)],
    ]
  end
end

class Rails::Application
  initializer :execjs_xtrn_stats do
    Rails.application.routes_reloader.paths <<
      File.expand_path('../routes.rb', __FILE__)
  end
end<commit_msg>Start HTML format<commit_after>module ExecJS::Xtrn::Rack
  Formats=YAML.load <<-EOY
    -:
      mime: text/x-yaml
      dump: YAML
    json:
      mime: appication/json
      dump: JSON
    html:
      mime: text/html
      dump: self
  EOY

  Formats.each {|k, v| v['dump']=instance_eval v['dump']}

  def self.stats
    ExecJS::Xtrn.stats.as_json
  end

  def self.call req
    f=Formats[req['action_dispatch.request.path_parameters'][:format]] ||
      Formats['-']
    [
      200,
      {"Content-Type"=> f['mime']},
      [f['dump'].dump(stats)],
    ]
  end

  # Dump as HTML
  def self.dump s
    'Hi there!'
  end
end

class Rails::Application
  initializer :execjs_xtrn_stats do
    Rails.application.routes_reloader.paths <<
      File.expand_path('../routes.rb', __FILE__)
  end
end
{'fraction_non_alphanumeric': 0.14315642458100558, 'fraction_numerical': 0.004189944134078212, 'mean_word_length': 2.6649616368286444, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '4196754', 'n_tokens_mistral': 551, 'n_tokens_neox': 521, 'n_words': 98}