Sha256: 849569dfd9f808da92de8f88d9a80d008923448915934b54177eeafe297f7a27
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
# Nugem::Repository contains informations about the git repository and the git user module Nugem class Repository attr_reader :gem_server_url, :global_config, :host, :name, :private, :user, :user_name, :user_email Host = Struct.new(:domain, :camel_case, :id, keyword_init: true) HOSTS = [ Host.new(domain: 'github.com', camel_case: 'GitHub', id: :github), Host.new(domain: 'bitbucket.org', camel_case: 'BitBucket', id: :bitbucket), ].freeze def initialize(options) @host = HOSTS.find { |host| host.id == options[:host] } @private = options[:private] @name = options[:name] @user = options[:user] @global_config = Rugged::Config.global abort 'Git global config not found' if @global_config.nil? @user_name = @global_config['user.name'] @user_email = @global_config['user.email'] @gem_server_url = options[:gem_server_url] @private = options[:private] end def bitbucket? @host.id == :bitbucket end def github? @host.id == :github end def origin "git@#{@host.domain}:#{@user}/#{@name}.git" end # TODO: Currently all private repositories are on BitBucket and all public repos are on GitHub # TODO: Drop BitBucket? # TODO: Support private repos on GitHub def private? @private end def public? !@private end def url "https://#{@host.domain}/#{@user}/#{@name}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nugem-0.8.3 | lib/nugem/repository.rb |
nugem-0.8.1 | lib/nugem/repository.rb |
nugem-0.8.0 | lib/nugem/repository.rb |