Class: Packages::Nuget::ExtractRemoteMetadataFileService

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

Constant Summary collapse

ExtractionError =
Class.new(StandardError)
MAX_FILE_SIZE =
4.megabytes.freeze
METADATA_FILE_EXTENSION =
'.nuspec'
MAX_FRAGMENTS =

nuspec file is usually in the first 2 fragments but we buffer 5 max

5

Instance Method Summary collapse

Constructor Details

#initialize(remote_url) ⇒ ExtractRemoteMetadataFileService

Returns a new instance of ExtractRemoteMetadataFileService.



14
15
16
# File 'app/services/packages/nuget/extract_remote_metadata_file_service.rb', line 14

def initialize(remote_url)
  @remote_url = remote_url
end

Instance Method Details

#executeObject

Raises:



18
19
20
21
22
23
24
25
26
# File 'app/services/packages/nuget/extract_remote_metadata_file_service.rb', line 18

def execute
  raise ExtractionError, 'invalid file url' if remote_url.blank?

  if nuspec_file_content.blank? || !nuspec_file_content.instance_of?(String)
    raise ExtractionError, 'nuspec file not found'
  end

  ServiceResponse.success(payload: nuspec_file_content)
end