debian-mirror-gitlab/app/services/packages/composer/composer_json_service.rb

32 lines
684 B
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module Packages
module Composer
class ComposerJsonService
def initialize(project, target)
@project, @target = project, target
end
def execute
composer_json
end
private
def composer_json
composer_file = @project.repository.blob_at(@target, 'composer.json')
composer_file_not_found! unless composer_file
Gitlab::Json.parse(composer_file.data)
rescue JSON::ParserError
raise 'Could not parse composer.json file. Invalid JSON.'
end
def composer_file_not_found!
raise 'The file composer.json was not found.'
end
end
end
end