Class: Composer::Package::Loader::ProjectAttributesLoader
- Inherits:
-
Object
- Object
- Composer::Package::Loader::ProjectAttributesLoader
- Defined in:
- lib/composer/package/loader/project_attributes_loader.rb
Overview
Loads a package from project attributes
Instance Method Summary collapse
-
#initialize(loader) ⇒ ProjectAttributesLoader
constructor
A new instance of ProjectAttributesLoader.
-
#load(project, ref, type = 'library') ⇒ Object
Load a json string or file Param: string|JsonFile json A filename, json string or JsonFile instance to load the package from Returns: Composer::Package::Package.
Constructor Details
#initialize(loader) ⇒ ProjectAttributesLoader
Returns a new instance of ProjectAttributesLoader.
11 12 13 |
# File 'lib/composer/package/loader/project_attributes_loader.rb', line 11 def initialize(loader) @loader = loader end |
Instance Method Details
#load(project, ref, type = 'library') ⇒ Object
Load a json string or file Param: string|JsonFile json A filename, json string or JsonFile instance to load the package from Returns: Composer::Package::Package
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/composer/package/loader/project_attributes_loader.rb', line 18 def load(project, ref, type = 'library') version = (ref.instance_of?(Gitlab::Git::Branch)) ? "dev-#{ref.name}" : ref.name config = { 'name' => project.path_with_namespace.gsub(/\s/, '').downcase, 'description' => project.description, 'version' => version, 'uid' => Digest::CRC32.checksum(ref.name + ref.target), 'source' => { 'url' => project.url_to_repo, 'type' => 'git', 'reference' => ref.target }, 'dist' => { 'url' => [project.web_url, 'repository', 'archive.zip?ref=' + ref.name].join('/'), 'type' => 'zip' }, 'type' => type, 'homepage' => project.web_url } if time = get_time(project, ref) log("Ref: #{ref.to_json} Time: #{time}") config['time'] = time end if keywords = get_keywords(project) config['keywords'] = keywords end @loader.load(config) end |