Sha256: d5cdefebfde093951a7c0e3b1d2b34635ff4da5dbfd7fd4e565fd5c9b09253ab

Contents?: true

Size: 850 Bytes

Versions: 3

Compression:

Stored size: 850 Bytes

Contents

require_relative 'conan_info_parser'

module LicenseFinder
  class Conan < PackageManager
    def possible_package_paths
      [project_path.join('conanfile.txt')]
    end

    def current_packages
      install_command = 'conan install'
      info_command = 'conan info'
      Dir.chdir(project_path) { Cmd.run(install_command) }
      info_output, _stderr, _status = Dir.chdir(project_path) { Cmd.run(info_command) }

      info_parser = ConanInfoParser.new

      deps = info_parser.parse(info_output)
      deps.map do |dep|
        name, version = dep['name'].split('@').first.split('/')
        url = dep['URL']
        license_file_path = Dir.glob("#{project_path}/licenses/#{name}/**/LICENSE*").first
        ConanPackage.new(name, version, File.open(license_file_path).read, url) unless name == 'PROJECT'
      end.compact
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
license_finder-4.0.2 lib/license_finder/package_managers/conan.rb
license_finder-4.0.1 lib/license_finder/package_managers/conan.rb
license_finder-3.1.1 lib/license_finder/package_managers/conan.rb