Class: Hub::Context::GithubProject

Inherits:
Struct
  • Object
show all
Defined in:
lib/hub/context.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



172
173
174
# File 'lib/hub/context.rb', line 172

def ==(other)
  name_with_owner == other.name_with_owner
end

#git_url(options = {}) ⇒ Object



193
194
195
196
197
198
# File 'lib/hub/context.rb', line 193

def git_url(options = {})
  if options[:https] then 'https://github.com/'
  elsif options[:private] then '[email protected]:'
  else 'git://github.com/'
  end + name_with_owner + '.git'
end

#name_with_ownerObject



168
169
170
# File 'lib/hub/context.rb', line 168

def name_with_owner
  "#{owner}/#{name}"
end

#remoteObject



176
177
178
# File 'lib/hub/context.rb', line 176

def remote
  local_repo.remotes.find { |r| r.project == self }
end

#web_url(path = nil) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/hub/context.rb', line 180

def web_url(path = 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
  'https://github.com/' + project_name + path.to_s
end