<commit_before># encoding: utf-8

module Backup
  module Storage
    module Cycler
      class Error < Backup::Error; end

      private

      # Adds the current package being stored to the YAML cycle data file
      # and will remove any old package file(s) when the storage limit
      # set by #keep is exceeded.
      def cycle!
        Logger.info 'Cycling Started...'

        packages = yaml_load.unshift(package)
        cycled_packages = []

        if keep.is_a?(Date) || keep.is_a?(Time)
          cycled_packages = packages.select do |p|
            p.time_as_object < keep.to_time
          end
        else
          excess = packages.count - keep.to_i
          cycled_packages = packages.last(excess)
        end

        saved_packages = packages - cycled_packages
        cycled_packages.each { |package| delete_package package }

        yaml_save(saved_packages)
      end

      def delete_package(package)
        begin<commit_msg>Fix for keep number failure<commit_after># encoding: utf-8

module Backup
  module Storage
    module Cycler
      class Error < Backup::Error; end

      private

      # Adds the current package being stored to the YAML cycle data file
      # and will remove any old package file(s) when the storage limit
      # set by #keep is exceeded.
      def cycle!
        Logger.info 'Cycling Started...'

        packages = yaml_load.unshift(package)
        cycled_packages = []

        if keep.is_a?(Date) || keep.is_a?(Time)
          cycled_packages = packages.select do |p|
            p.time_as_object < keep.to_time
          end
        else
          excess = packages.count - keep.to_i
          cycled_packages = packages.last(excess) if excess > 0
        end

        saved_packages = packages - cycled_packages
        cycled_packages.each { |package| delete_package package }

        yaml_save(saved_packages)
      end

      def delete_package(package)
        begin
{'fraction_non_alphanumeric': 0.06973140495867769, 'fraction_numerical': 0.0015495867768595042, 'mean_word_length': 2.1091492776886036, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '5368016', 'n_tokens_mistral': 558, 'n_tokens_neox': 538, 'n_words': 164}