Class: BlobViewer::PackageJson

Inherits:
DependencyManager show all
Includes:
ServerSide
Defined in:
app/models/blob_viewer/package_json.rb

Constant Summary

Constants inherited from Base

Base::PARTIAL_PATH_PREFIX

Instance Attribute Summary

Attributes inherited from Base

#blob

Instance Method Summary collapse

Methods included from ServerSide

#prepare!, #render_error

Methods included from Auxiliary

#visible_to?

Methods included from Gitlab::Allowable

#can?

Methods inherited from Base

auxiliary?, binary?, #binary_detected_after_load?, can_render?, #collapsed?, #initialize, load_async?, loading_partial_path, partial_path, #prepare!, #render_error, rich?, simple?, text?, #too_large?

Constructor Details

This class inherits a constructor from BlobViewer::Base

Instance Method Details

#manager_nameObject


9
10
11
# File 'app/models/blob_viewer/package_json.rb', line 9

def manager_name
  yarn? ? 'yarn' : 'npm'
end

#manager_urlObject


17
18
19
# File 'app/models/blob_viewer/package_json.rb', line 17

def manager_url
  yarn? ? 'https://yarnpkg.com/' : 'https://www.npmjs.com/'
end

#package_nameObject


21
22
23
# File 'app/models/blob_viewer/package_json.rb', line 21

def package_name
  @package_name ||= package_name_from_json('name')
end

#package_typeObject


25
26
27
# File 'app/models/blob_viewer/package_json.rb', line 25

def package_type
  private? ? 'private package' : super
end

#package_urlObject


29
30
31
# File 'app/models/blob_viewer/package_json.rb', line 29

def package_url
  private? ? homepage : npm_url
end

#yarn?Boolean

Returns:

  • (Boolean)

13
14
15
# File 'app/models/blob_viewer/package_json.rb', line 13

def yarn?
  json_data['engines'].present? && json_data['engines']['yarn'].present?
end