Class: LicenseFinder::Conan

Inherits:
PackageManager show all
Defined in:
lib/license_finder/package_managers/conan.rb

Instance Method Summary collapse

Methods inherited from PackageManager

#active?, #command_exists?, #current_packages_with_relations, #detected_package_path, id, #initialize, #installed?, #package_management_command, #prepare, #prepare_command, #project_root?, takes_priority_over

Constructor Details

This class inherits a constructor from LicenseFinder::PackageManager

Instance Method Details

#current_packagesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/license_finder/package_managers/conan.rb', line 11

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

#possible_package_pathsObject



7
8
9
# File 'lib/license_finder/package_managers/conan.rb', line 7

def possible_package_paths
  [project_path.join('conanfile.txt')]
end