Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/license_finder/package_managers/conan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ def license_file_is_good?(license_file_path)
end

def license_file(project_path, name)
candidates = Dir.glob("#{project_path}/licenses/#{name}/**/LICENSE*")
lic_file = license_file_by_mask(project_path, name, 'LICENSE*')
lic_file = license_file_by_mask(project_path, name, 'copy*') if lic_file.nil?
lic_file
end

def license_file_by_mask(project_path, name, file_mask)
candidates = Dir.glob("#{project_path}/licenses/#{name}/**/#{file_mask}")
candidates.each do |candidate|
return candidate if license_file_is_good?(candidate)
end
Expand Down
19 changes: 15 additions & 4 deletions lib/license_finder/package_utils/conan_info_parser_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
module LicenseFinder
class ConanInfoParserV2
def parse(info)
@lines = info.lines.map(&:chomp)
@lines = get_dependencies_lines(info)
@state = :project_level # state of the state machine
@projects = [] # list of projects
@current_project = nil # current project being populated in the SM
@current_vals = [] # current val list being populate in the SM
@current_key = nil # current key to be associated with the current val

line = @lines.shift
line = @lines.shift while line != '======== Basic graph information ========'

while (line = @lines.shift)
next if line == ''

Expand All @@ -33,6 +30,20 @@ def parse(info)

private

def get_dependencies_lines(info)
lines = info.lines.map(&:chomp)
graph_info_start = 'basic graph information'
if info.downcase.include?(graph_info_start)
loop do
line = lines.shift
break if lines.empty?
next if line.nil?
break if line.downcase.include?(graph_info_start)
end
end
lines
end

def parse_key_val(line)
key, val = key_val(line)
if val
Expand Down