class Hub::Context::GithubProject
Attributes
repo_data[RW]
Public Class Methods
from_url(url, local_repo)
click to toggle source
# File lib/hub/context.rb, line 252 def self.from_url(url, local_repo) if local_repo.known_host?(url.host) _, owner, name = url.path.split('/', 4) GithubProject.new(local_repo, owner, name.sub(/\.git$/, ''), url.host) end end
new(*args)
click to toggle source
Calls superclass method
# File lib/hub/context.rb, line 261 def initialize(*args) super self.name = self.name.tr(' ', '-') self.host ||= (local_repo || LocalRepo).default_host self.host = host.sub(/^ssh\./i, '') if 'ssh.github.com' == host.downcase end
Public Instance Methods
==(other)
click to toggle source
# File lib/hub/context.rb, line 283 def ==(other) name_with_owner == other.name_with_owner end
git_url(options = {})
click to toggle source
# File lib/hub/context.rb, line 308 def git_url(options = {}) if options[:https] then "https://#{host}/" elsif options[:private] or private? then "git@#{host}:" else "git://#{host}/" end + name_with_owner + '.git' end
name_with_owner()
click to toggle source
# File lib/hub/context.rb, line 279 def name_with_owner "#{owner}/#{name}" end
owned_by(new_owner)
click to toggle source
# File lib/hub/context.rb, line 273 def owned_by(new_owner) new_project = dup new_project.owner = new_owner new_project end
private?()
click to toggle source
# File lib/hub/context.rb, line 268 def private? repo_data ? repo_data.fetch('private') : host != (local_repo || LocalRepo).main_host end
remote()
click to toggle source
# File lib/hub/context.rb, line 287 def remote local_repo.remotes.find { |r| r.project == self } end
web_url(path = nil, protocol_config = nil)
click to toggle source
# File lib/hub/context.rb, line 291 def web_url(path = nil, protocol_config = nil) project_name = name_with_owner if project_name.sub!(/\.wiki$/, '') unless '/wiki' == path path = if path =~ %r{^/commits/} then '/_history' else path.to_s.sub(/\w+/, '_\0') end path = '/wiki' + path end end '%s://%s/%s' % [ protocol_config ? protocol_config.call(host) : 'https', host, project_name + path.to_s ] end