2018-08-03 03:15:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-17 12:27:30 -04:00
|
|
|
module BlobViewer
|
|
|
|
class DependencyManager < Base
|
|
|
|
include Auxiliary
|
|
|
|
|
|
|
|
self.partial_name = 'dependency_manager'
|
|
|
|
self.binary = false
|
|
|
|
|
|
|
|
def manager_name
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def manager_url
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def package_type
|
|
|
|
'package'
|
|
|
|
end
|
|
|
|
|
|
|
|
def package_name
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def package_url
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-12-18 23:55:51 -05:00
|
|
|
def json_data
|
|
|
|
@json_data ||= begin
|
|
|
|
prepare!
|
2020-04-30 14:09:38 -04:00
|
|
|
Gitlab::Json.parse(blob.data)
|
2020-09-02 08:10:35 -04:00
|
|
|
rescue
|
|
|
|
{}
|
2017-12-18 23:55:51 -05:00
|
|
|
end
|
|
|
|
end
|
2017-05-17 12:27:30 -04:00
|
|
|
|
2017-12-18 23:55:51 -05:00
|
|
|
def package_name_from_json(key)
|
|
|
|
json_data[key]
|
2017-05-17 12:27:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def package_name_from_method_call(name)
|
|
|
|
prepare!
|
|
|
|
|
|
|
|
match = blob.data.match(/#{name}\s*=\s*["'](?<name>[^"']+)["']/)
|
|
|
|
match[:name] if match
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|