Class: Hub::Context::GithubURL

Inherits:
URI::HTTP show all
Extended by:
Forwardable
Defined in:
lib/hub/context.rb

Instance Attribute Summary collapse

Attributes inherited from URI::HTTP

#fragment, #host, #password, #path, #port, #query, #scheme, #user

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from URI::HTTP

#find_proxy, #request_uri, #to_s, #userinfo, #userinfo=

Constructor Details

#initialize(uri, project) ⇒ GithubURL

Returns a new instance of GithubURL.



332
333
334
335
# File 'lib/hub/context.rb', line 332

def initialize(uri, project)
  @project = project
  super(uri)
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



319
320
321
# File 'lib/hub/context.rb', line 319

def project
  @project
end

Class Method Details

.resolve(url, local_repo) ⇒ Object



323
324
325
326
327
328
329
330
# File 'lib/hub/context.rb', line 323

def self.resolve(url, local_repo)
  u = URI(url)
  if %[http https].include? u.scheme and project = GithubProject.from_url(u, local_repo)
    self.new(u, project)
  end
rescue URI::InvalidURIError
  nil
end

Instance Method Details

#project_pathObject

segment of path after the project owner and name



338
339
340
# File 'lib/hub/context.rb', line 338

def project_path
  path.split('/', 4)[3]
end