<commit_before>class Date
  def format_nicely
    "#{Date::MONTHNAMES[mon]} #{mday}, #{year}"
  end
end

class File
  def self.read_file(a_filename)
    content = ''
    File.open(a_filename) do |io|
      io.each_line do |line|
        content += line
      end
    end
    content
  end
  
  def self.read_yaml(a_filename)
    YAML::load(self.read_file(a_filename))
  end
end

class Hash
  def clean
    hash = {}
    self.each_pair do |key, value|
      # Convert all keys to symbols
      hash[key.to_sym] = value
    end
    hash
  end
  
  def clean!
    self.replace(self.clean)
  end
end

class NilClass
  def true?
    false
  end
  
  def false?
    true
  end
end

class String
  def filter!(a_filters, a_context)
    a_filters.each do |filter|
      case filter
      when 'markdown'
        self.markdown!
      when 'eruby'
        self.eruby!(a_context)
      end
    end
  end
  
  def markdown
    BlueCloth::new(self).to_html
  end
  
  def markdown!
    self.replace(self.markdown)
  end
  
  def eruby(a_context)
    Erubis::Eruby.new(self).evaluate(a_context)
  end
  
  def eruby!(a_context)
    self.replace(self.eruby(a_context))
  end
end

class Time
  def format_nicely
    "#{Date::MONTHNAMES[mon]} #{mday}, #{year}"
  end
end

def html_escape(a_string)
  a_string.gsub('&', '&amp;').gsub('<', '&lt;')
end
alias h html_escape

def to_atom_date(a_string)
  Time.parse(a_string).strftime("%Y-%m-%d")
end

def to_atom_time(a_string)
  Time.parse(a_string).strftime("%Y-%m-%dT%H:%M:%SZ")
end<commit_msg>*_on and *_at metadata fields are now automatically converted to Dates and Times, respectively<commit_after>class Date
  def format_nicely
    "#{Date::MONTHNAMES[mon]} #{mday}, #{year}"
  end
end

class File
  def self.read_file(a_filename)
    content = ''
    File.open(a_filename) do |io|
      io.each_line do |line|
        content += line
      end
    end
    content
  end
  
  def self.read_yaml(a_filename)
    YAML::load(self.read_file(a_filename))
  end
end

class Hash
  def clean
    hash = {}
    
    self.each_pair do |key, value|
      # Convert all keys to symbols
      hash[key.to_sym] = value
      
      # Convert *_on and *_at to Dates and Times
      if key =~ /_on$/
        hash[key.to_sym] = Date.parse(value)
      elsif key =~ /_at$/
        hash[key.to_sym] = Time.parse(value)
      end
    end
    
    hash
  end
end

class NilClass
  def true?
    false
  end
  
  def false?
    true
  end
end

class String
  def filter!(a_filters, a_context)
    a_filters.each do |filter|
      case filter
      when 'markdown'
        self.markdown!
      when 'eruby'
        self.eruby!(a_context)
      end
    end
  end
  
  def markdown
    BlueCloth::new(self).to_html
  end
  
  def markdown!
    self.replace(self.markdown)
  end
  
  def eruby(a_context)
    Erubis::Eruby.new(self).evaluate(a_context)
  end
  
  def eruby!(a_context)
    self.replace(self.eruby(a_context))
  end
end

class Time
  def format_nicely
    "#{Date::MONTHNAMES[mon]} #{mday}, #{year}"
  end
end

def html_escape(a_string)
  a_string.gsub('&', '&amp;').gsub('<', '&lt;')
end
alias h html_escape

def to_atom_date(a_date)
  a_date.strftime("%Y-%m-%d")
end

def to_atom_time(a_time)
  a_time.strftime("%Y-%m-%dT%H:%M:%SZ")
end
{'fraction_non_alphanumeric': 0.11914241960183768, 'fraction_numerical': 0.0, 'mean_word_length': 2.6779279279279278, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4076831', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1256, 'n_words': 283}