<commit_before>module Pod
  class Source
    # Data provider for a `Pod::Source` backed by a repository hosted in the
    # file system.
    #
    class FileSystemDataProvider < AbstractDataProvider
      # @return [Pathname] The path where the source is stored.
      #
      attr_reader :repo

      # @param  [Pathname, String] repo @see #repo.
      #
      def initialize(repo)
        @repo = Pathname.new(repo)
      end

      public

      # @group Required methods
      #-----------------------------------------------------------------------#

      # @return [String] The name of the source.
      #
      def name
        repo.basename.to_s
      end

      # @return [String] The user friendly type of the source.
      #
      def type
        'file system'
      end

      # @return [Array<String>] The list of the name of all the Pods known to
      #         the Source.
      #
      # @note   Using Pathname#children is sensibly slower.
      #
      def pods
        return nil unless specs_dir
        specs_dir_as_string = specs_dir.to_s
        Dir.entries(specs_dir).select do |entry|
          valid_name = entry[0, 1] != '.'
          valid_name && File.directory?(File.join(specs_dir_as_string, entry))
        end.sort
      end

      # @return [Array<String>] All the available versions of a given Pod,
      #         sorted from highest to lowest.
      #
      # @param  [String] name
      #         The name of the Pod.
      #
      def versions(name)
        return nil unless specs_dir
        raise ArgumentError, 'No name' unless name
        pod_dir = specs_dir + name
        return unless pod_dir.exist?
        pod_dir.children.map do |v|
          basename = v.basename.to_s
          basename if v.directory? && basename[0, 1] != '.'
        end.compact.sort.reverse
      end

      # @return [Specification] The specification for a given version of a Pod.
      #
      # @param  [String] name
      #         The name of the Pod.
      #
      # @param  [String] version
      #         The version of the Pod.
      #
      def specification(name, version)
        path = specification_path(name, version)
        Pod::Specification.from_file(path) if path && path.exist?
      end

      # @return [Specification] The contents of the specification for a given
      #         version of a Pod.
      #
      # @param  [String] name
      #         the name of the Pod.
      #
      # @param  [String] version<commit_msg>Pass versions into through Version to sort<commit_after>module Pod
  class Source
    # Data provider for a `Pod::Source` backed by a repository hosted in the
    # file system.
    #
    class FileSystemDataProvider < AbstractDataProvider
      # @return [Pathname] The path where the source is stored.
      #
      attr_reader :repo

      # @param  [Pathname, String] repo @see #repo.
      #
      def initialize(repo)
        @repo = Pathname.new(repo)
      end

      public

      # @group Required methods
      #-----------------------------------------------------------------------#

      # @return [String] The name of the source.
      #
      def name
        repo.basename.to_s
      end

      # @return [String] The user friendly type of the source.
      #
      def type
        'file system'
      end

      # @return [Array<String>] The list of the name of all the Pods known to
      #         the Source.
      #
      # @note   Using Pathname#children is sensibly slower.
      #
      def pods
        return nil unless specs_dir
        specs_dir_as_string = specs_dir.to_s
        Dir.entries(specs_dir).select do |entry|
          valid_name = entry[0, 1] != '.'
          valid_name && File.directory?(File.join(specs_dir_as_string, entry))
        end.sort
      end

      # @return [Array<String>] All the available versions of a given Pod,
      #         sorted from highest to lowest.
      #
      # @param  [String] name
      #         The name of the Pod.
      #
      def versions(name)
        return nil unless specs_dir
        raise ArgumentError, 'No name' unless name
        pod_dir = specs_dir + name
        return unless pod_dir.exist?
        pod_dir.children.map do |v|
          basename = v.basename.to_s
          Version.new(basename) if v.directory? && basename[0, 1] != '.'
        end.compact.sort.reverse.map(&:to_s)
      end

      # @return [Specification] The specification for a given version of a Pod.
      #
      # @param  [String] name
      #         The name of the Pod.
      #
      # @param  [String] version
      #         The version of the Pod.
      #
      def specification(name, version)
        path = specification_path(name, version)
        Pod::Specification.from_file(path) if path && path.exist?
      end

      # @return [Specification] The contents of the specification for a given
      #         version of a Pod.
      #
      # @param  [String] name
      #         the name of the Pod.
      #
      # @param  [String] version
{'fraction_non_alphanumeric': 0.10951239008792965, 'fraction_numerical': 0.0015987210231814548, 'mean_word_length': 1.6523582405935346, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6884797', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1391, 'n_words': 461}