2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
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
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def json_data
|
|
|
|
@json_data ||= begin
|
|
|
|
prepare!
|
|
|
|
JSON.parse(blob.data)
|
|
|
|
rescue
|
|
|
|
{}
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def package_name_from_json(key)
|
|
|
|
json_data[key]
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def package_name_from_method_call(name)
|
|
|
|
prepare!
|
|
|
|
|
|
|
|
match = blob.data.match(/#{name}\s*=\s*["'](?<name>[^"']+)["']/)
|
|
|
|
match[:name] if match
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|