<commit_before>require 'yaml'

REDIRECTS_FILE = '.redirects.gollum'

module Gollum
  
  module Redirects
        
    def stale?
      @current_head != get_head_sha
    end

    def init(wiki)
      @wiki = wiki
      @current_head = get_head_sha
    end

    def load
      file = @wiki.file(REDIRECTS_FILE)
      redirects = {}
      if file
        begin
          redirects = YAML.load(file.raw_data)
        rescue YAML::Error
          # TODO handle error
        end
      end
      self.clear
      self.merge!(redirects)
    end
    
    def dump
      @wiki.overwrite_file(REDIRECTS_FILE, self.to_yaml, {})
    end
    
    def get_head_sha
      @wiki.repo.head.nil? ? nil : @wiki.repo.head.commit.sha
    end<commit_msg>Refactor<commit_after>require 'yaml'

REDIRECTS_FILE = '.redirects.gollum'

module Gollum
  
  module Redirects
        
    def stale?
      @current_head != get_head_sha
    end

    def init(wiki)
      @wiki = wiki
      @current_head = get_head_sha
    end

    def load
      file = @wiki.file(REDIRECTS_FILE)
      redirects = {}
      if file
        begin
          redirects = YAML.load(file.raw_data)
        rescue YAML::Error
          # TODO handle error
        end
      end
      self.clear
      self.merge!(redirects)
    end
    
    def dump
      @wiki.overwrite_file(REDIRECTS_FILE, self.to_yaml, {})
    end
    
    def get_head_sha
      @wiki.repo.head ? @wiki.repo.head.commit.sha : nil
    end
{'fraction_non_alphanumeric': 0.08390646492434663, 'fraction_numerical': 0.0, 'mean_word_length': 1.841796875, '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': '7630255', 'n_tokens_mistral': 501, 'n_tokens_neox': 498, 'n_words': 101}