<commit_before>require 'json'
require 'grit_wrapper'

module Barkeep

  def barkeep
    @@barkeep ||= Barkeeper.new
  end

end

class Barkeeper

  def config
    @config ||= JSON.parse(File.read("config/barkeep.json"))
  end

  def load?
    if defined?(Rails)
      this_env = Rails.env
    elsif defined?(Sinatra)
      this_env = Sinatra::Application.settings.environment
    end
    config['environments'].include?(this_env.to_s)
  end

  def styles
    return unless load?
    %(<style>#{File.read(File.expand_path(File.dirname(__FILE__) + "/default.css"))}</style>)
  end

  def render
    return unless load? && grit_info.repository?

    %(
      <dl id="barkeep">
      #{
        config['panes'].map do |name|
          if name =~ /^(p|partial) (.*)/
            render :partial => $2
          else
            send(name)
          end
        end.join('')
      }
      <dd class="close">
        <a href="#" onclick="c = document.getElementById('barkeep'); c.parentNode.removeChild(c); return false" title="Close me!">&times;</a>
      </dd>
      </dl>
    ).html_safe
  end<commit_msg>Fixed escaping regression on barkeep.styles<commit_after>require 'json'
require 'grit_wrapper'

module Barkeep

  def barkeep
    @@barkeep ||= Barkeeper.new
  end

end

class Barkeeper

  def config
    @config ||= JSON.parse(File.read("config/barkeep.json"))
  end

  def load?
    if defined?(Rails)
      this_env = Rails.env
    elsif defined?(Sinatra)
      this_env = Sinatra::Application.settings.environment
    end
    config['environments'].include?(this_env.to_s)
  end

  def styles
    return unless load?
    %(<style>#{File.read(File.expand_path(File.dirname(__FILE__) + "/default.css"))}</style>).html_safe
  end

  def render
    return unless load? && grit_info.repository?

    %(
      <dl id="barkeep">
      #{
        config['panes'].map do |name|
          if name =~ /^(p|partial) (.*)/
            render :partial => $2
          else
            send(name)
          end
        end.join('')
      }
      <dd class="close">
        <a href="#" onclick="c = document.getElementById('barkeep'); c.parentNode.removeChild(c); return false" title="Close me!">&times;</a>
      </dd>
      </dl>
    ).html_safe
  end
{'fraction_non_alphanumeric': 0.14732142857142858, 'fraction_numerical': 0.0008928571428571428, 'mean_word_length': 2.507042253521127, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '1594457', 'n_tokens_mistral': 740, 'n_tokens_neox': 722, 'n_words': 155}