Sha256: bde29ec951b295daa2494956662f1eeffde2dca3a954e439c487fb8f45989e12

Contents?: true

Size: 1.06 KB

Versions: 7

Compression:

Stored size: 1.06 KB

Contents

module Bibliothecary
  class RelatedFilesInfo
    attr_reader :path
    attr_reader :platform
    attr_reader :manifests
    attr_reader :lockfiles

    def self.create_from_file_infos(file_infos)
      returns = []
      paths = file_infos.group_by { |info| File.dirname(info.relative_path) }
      paths.values.each do |path|
        same_pm = path.group_by { |info| info.package_manager}
        same_pm.values.each do |value|
          returns.append(RelatedFilesInfo.new(value))
        end
      end
      returns
    end

    def initialize(file_infos)
      package_manager = file_infos.first.package_manager
      @platform = package_manager.platform_name
      @path = Pathname.new(File.dirname(file_infos.first.relative_path)).cleanpath.to_path
      @manifests = file_infos.select { |info| package_manager.determine_kind_from_info(info) == "manifest" }.map { |info| File.basename(info.relative_path) }
      @lockfiles = file_infos.select { |info| package_manager.determine_kind_from_info(info) == "lockfile" }.map { |info| File.basename(info.relative_path) }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bibliothecary-6.8.1 lib/bibliothecary/related_files_info.rb
bibliothecary-6.8.0 lib/bibliothecary/related_files_info.rb
bibliothecary-6.7.4 lib/bibliothecary/related_files_info.rb
bibliothecary-6.7.3 lib/bibliothecary/related_files_info.rb
bibliothecary-6.7.2 lib/bibliothecary/related_files_info.rb
bibliothecary-6.7.1 lib/bibliothecary/related_files_info.rb
bibliothecary-6.6.0 lib/bibliothecary/related_files_info.rb