Sha256: fabc146ed65d5ab289f1dc086ac80a51c5b68c5df1f17678332f1bff88c11361

Contents?: true

Size: 905 Bytes

Versions: 42

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true

require 'license_finder/package_utils/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

42 entries across 42 versions & 2 rubygems

Version Path
gitlab-license_finder-6.14.2.1 lib/license_finder/package_managers/conan.rb
license_finder-6.14.2 lib/license_finder/package_managers/conan.rb
license_finder-6.14.1 lib/license_finder/package_managers/conan.rb
license_finder-6.13.0 lib/license_finder/package_managers/conan.rb
license_finder-6.12.2 lib/license_finder/package_managers/conan.rb
license_finder-6.12.1 lib/license_finder/package_managers/conan.rb
license_finder-6.12.0 lib/license_finder/package_managers/conan.rb
license_finder-6.11.0 lib/license_finder/package_managers/conan.rb
license_finder-6.10.1 lib/license_finder/package_managers/conan.rb
license_finder-6.10.0 lib/license_finder/package_managers/conan.rb
license_finder-6.9.0 lib/license_finder/package_managers/conan.rb
license_finder-6.8.2 lib/license_finder/package_managers/conan.rb
license_finder-6.8.1 lib/license_finder/package_managers/conan.rb
license_finder-6.8.0 lib/license_finder/package_managers/conan.rb
license_finder-6.7.0 lib/license_finder/package_managers/conan.rb
license_finder-6.6.2 lib/license_finder/package_managers/conan.rb
license_finder-6.6.1 lib/license_finder/package_managers/conan.rb
license_finder-6.6.0 lib/license_finder/package_managers/conan.rb
license_finder-6.5.0 lib/license_finder/package_managers/conan.rb
license_finder-6.4.0 lib/license_finder/package_managers/conan.rb