diff options
Diffstat (limited to 'app/models/blob_viewer')
-rw-r--r-- | app/models/blob_viewer/dependency_manager.rb | 13 | ||||
-rw-r--r-- | app/models/blob_viewer/package_json.rb | 12 |
2 files changed, 22 insertions, 3 deletions
diff --git a/app/models/blob_viewer/dependency_manager.rb b/app/models/blob_viewer/dependency_manager.rb index a8d9be945dc..cc4950240af 100644 --- a/app/models/blob_viewer/dependency_manager.rb +++ b/app/models/blob_viewer/dependency_manager.rb @@ -27,10 +27,17 @@ module BlobViewer private - def package_name_from_json(key) - prepare! + def json_data + @json_data ||= begin + prepare! + JSON.parse(blob.data) + rescue + {} + end + end - JSON.parse(blob.data)[key] rescue nil + def package_name_from_json(key) + json_data[key] end def package_name_from_method_call(name) diff --git a/app/models/blob_viewer/package_json.rb b/app/models/blob_viewer/package_json.rb index 09221efb56c..6ce61e30d3d 100644 --- a/app/models/blob_viewer/package_json.rb +++ b/app/models/blob_viewer/package_json.rb @@ -16,8 +16,20 @@ module BlobViewer @package_name ||= package_name_from_json('name') end + def package_type + private? ? 'private package' : super + end + def package_url + return nil if private? + "https://www.npmjs.com/package/#{package_name}" end + + private + + def private? + !!json_data['private'] + end end end |