Class: Packages::Nuget::MetadataExtractionService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/packages/nuget/metadata_extraction_service.rb

Constant Summary collapse

ExtractionError =
Class.new(StandardError)
XPATHS =
{
  package_name: '//xmlns:package/xmlns:metadata/xmlns:id',
  package_version: '//xmlns:package/xmlns:metadata/xmlns:version',
  license_url: '//xmlns:package/xmlns:metadata/xmlns:licenseUrl',
  project_url: '//xmlns:package/xmlns:metadata/xmlns:projectUrl',
  icon_url: '//xmlns:package/xmlns:metadata/xmlns:iconUrl'
}.freeze
XPATH_DEPENDENCIES =
'//xmlns:package/xmlns:metadata/xmlns:dependencies/xmlns:dependency'
XPATH_DEPENDENCY_GROUPS =
'//xmlns:package/xmlns:metadata/xmlns:dependencies/xmlns:group'
XPATH_TAGS =
'//xmlns:package/xmlns:metadata/xmlns:tags'
MAX_FILE_SIZE =
4.megabytes.freeze

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(package_file_id) ⇒ MetadataExtractionService

Returns a new instance of MetadataExtractionService.


24
25
26
# File 'app/services/packages/nuget/metadata_extraction_service.rb', line 24

def initialize(package_file_id)
  @package_file_id = package_file_id
end

Instance Method Details

#executeObject

Raises:


28
29
30
31
32
# File 'app/services/packages/nuget/metadata_extraction_service.rb', line 28

def execute
  raise ExtractionError.new('invalid package file') unless valid_package_file?

  (nuspec_file)
end