<commit_before># frozen_string_literal: true

class Shrine
  module Plugins
    # Documentation lives in [doc/plugins/restore_cached_data.md] on GitHub.
    #
    # [doc/plugins/restore_cached_data.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/restore_cached_data.md
    module RestoreCachedData
      def self.load_dependencies(uploader, *)
        uploader.plugin :refresh_metadata
      end

      module AttacherMethods
        private

        def cached(value, **options)
          cached_file = super
          options     = context.merge(options)

          # TODO: Remove this conditional when we remove the versions plugin
          if cached_file.is_a?(Hash) || cached_file.is_a?(Array)
            uploaded_file(cached_file) { |file| file.refresh_metadata!(options) }
          else
            cached_file.refresh_metadata!(options)
          end

          cached_file
        end
      end
    end

    register_plugin(:restore_cached_data, RestoreCachedData)
  end
end
<commit_msg>Remove extra line in restore_cached_data plugin<commit_after># frozen_string_literal: true

class Shrine
  module Plugins
    # Documentation lives in [doc/plugins/restore_cached_data.md] on GitHub.
    #
    # [doc/plugins/restore_cached_data.md]: https://github.com/shrinerb/shrine/blob/master/doc/plugins/restore_cached_data.md
    module RestoreCachedData
      def self.load_dependencies(uploader, *)
        uploader.plugin :refresh_metadata
      end

      module AttacherMethods
        private

        def cached(value, **options)
          cached_file = super

          # TODO: Remove this conditional when we remove the versions plugin
          if cached_file.is_a?(Hash) || cached_file.is_a?(Array)
            uploaded_file(cached_file) { |file| file.refresh_metadata!(**context, **options) }
          else
            cached_file.refresh_metadata!(**context, **options)
          end

          cached_file
        end
      end
    end

    register_plugin(:restore_cached_data, RestoreCachedData)
  end
end

{'fraction_non_alphanumeric': 0.08027410670582477, 'fraction_numerical': 0.0, 'mean_word_length': 2.6895306859205776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5155356', 'n_tokens_mistral': 599, 'n_tokens_neox': 580, 'n_words': 123}