lib/getv/package.rb in getv-1.0.1 vs lib/getv/package.rb in getv-1.1.0
- old
+ new
@@ -3,11 +3,11 @@
module Getv
# package class
class Package # rubocop:disable Metrics/ClassLength
attr_accessor :name, :opts
- def initialize(name, opts = {}) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize
+ def initialize(name, opts = {}) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity
@name = name
case name
when /rubygem-.*/
opts = { 'type' => 'gem' }.merge(opts)
when /nodejs-.*/
@@ -30,9 +30,12 @@
semantic_only: true,
semantic_select: ['*'],
versions: nil,
latest_version: nil
}.merge(opts)
+ if (opts[:type] == 'docker' || opts[:type] =~ /github.*/) && (name.count('/') == 1)
+ opts = { owner: name.split('/')[0], repo: name.split('/')[1] }.merge(opts)
+ end
case opts[:type]
when 'docker'
opts = { owner: 'library', repo: name, url: 'https://registry.hub.docker.com' }.merge(opts)
when 'gem'
opts = { gem: name[/rubygem-(.*)/, 1] || name }.merge(opts)