<commit_before>require "digest/sha1"

module Bundler
  class Runtime < Environment
    include SharedHelpers

    def initialize(*)
      super
      lock
    end

    def setup(*groups)
      # Has to happen first
      clean_load_path

      specs = groups.any? ? @definition.specs_for(groups) : requested_specs

      cripple_rubygems(specs)

      # Activate the specs
      specs.each do |spec|
        unless spec.loaded_from
          raise GemNotFound, "#{spec.full_name} is cached, but not installed."
        end

        Gem.loaded_specs[spec.name] = spec
        spec.load_paths.each do |path|
          $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
        end
      end
      self
    end

    def require(*groups)
      groups.map! { |g| g.to_sym }
      groups = [:default] if groups.empty?

      @definition.dependencies.each do |dep|
        # Skip the dependency if it is not in any of the requested
        # groups
        next unless (dep.groups & groups).any?

        begin
          # Loop through all the specified autorequires for the
          # dependency. If there are none, use the dependency's name
          # as the autorequire.
          Array(dep.autorequire || dep.name).each do |file|
            Kernel.require file
          end
        rescue LoadError
          # Only let a LoadError through if the autorequire was explicitly
          # specified by the user.
          raise if dep.autorequire
        end
      end
    end

    def dependencies_for(*groups)
      if groups.empty?
        dependencies
      else
        dependencies.select { |d| (groups & d.groups).any? }
      end
    end

    alias gems specs

    def cache
      FileUtils.mkdir_p(cache_path)

      Bundler.ui.info "Copying .gem files into vendor/cache"
      specs.each do |spec|
        spec.source.cache(spec) if spec.source.respond_to?(:cache)
      end
    end

    def prune_cache
      FileUtils.mkdir_p(cache_path)

      Bundler.ui.info "Removing outdated .gem files from vendor/cache"
      Pathname.glob(cache_path.join("*.gem")).each do |gem_path|
        cached_spec = Gem::Format.from_file_by_path(gem_path).spec
        next unless Gem::Platform.match(cached_spec.platform)
        unless specs.any?{|s| s.full_name == cached_spec.full_name }
          Bundler.ui.info "  * #{File.basename(gem_path)}"
          gem_path.rmtree
        end
      end
    end

  private

    def cache_path
      root.join("vendor/cache")
    end

  end<commit_msg>Convert Pathname to String before passing it to Pathname.glob<commit_after>require "digest/sha1"

module Bundler
  class Runtime < Environment
    include SharedHelpers

    def initialize(*)
      super
      lock
    end

    def setup(*groups)
      # Has to happen first
      clean_load_path

      specs = groups.any? ? @definition.specs_for(groups) : requested_specs

      cripple_rubygems(specs)

      # Activate the specs
      specs.each do |spec|
        unless spec.loaded_from
          raise GemNotFound, "#{spec.full_name} is cached, but not installed."
        end

        Gem.loaded_specs[spec.name] = spec
        spec.load_paths.each do |path|
          $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
        end
      end
      self
    end

    def require(*groups)
      groups.map! { |g| g.to_sym }
      groups = [:default] if groups.empty?

      @definition.dependencies.each do |dep|
        # Skip the dependency if it is not in any of the requested
        # groups
        next unless (dep.groups & groups).any?

        begin
          # Loop through all the specified autorequires for the
          # dependency. If there are none, use the dependency's name
          # as the autorequire.
          Array(dep.autorequire || dep.name).each do |file|
            Kernel.require file
          end
        rescue LoadError
          # Only let a LoadError through if the autorequire was explicitly
          # specified by the user.
          raise if dep.autorequire
        end
      end
    end

    def dependencies_for(*groups)
      if groups.empty?
        dependencies
      else
        dependencies.select { |d| (groups & d.groups).any? }
      end
    end

    alias gems specs

    def cache
      FileUtils.mkdir_p(cache_path)

      Bundler.ui.info "Copying .gem files into vendor/cache"
      specs.each do |spec|
        spec.source.cache(spec) if spec.source.respond_to?(:cache)
      end
    end

    def prune_cache
      FileUtils.mkdir_p(cache_path)

      Bundler.ui.info "Removing outdated .gem files from vendor/cache"
      Pathname.glob(cache_path.join("*.gem").to_s).each do |gem_path|
        cached_spec = Gem::Format.from_file_by_path(gem_path).spec
        next unless Gem::Platform.match(cached_spec.platform)
        unless specs.any?{|s| s.full_name == cached_spec.full_name }
          Bundler.ui.info "  * #{File.basename(gem_path)}"
          gem_path.rmtree
        end
      end
    end

  private

    def cache_path
      root.join("vendor/cache")
    end

  end
{'fraction_non_alphanumeric': 0.08292005554453481, 'fraction_numerical': 0.00039674667724657806, 'mean_word_length': 2.0837920489296637, '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': '2093985', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1479, 'n_words': 407}