class Nearmiss::Project

Class to parse GitHub repository owner and name from URLs and to generate URLs

Attributes

id[RW]
name[RW]
owner[RW]

Public Class Methods

from_url(url) click to toggle source

Instantiate from a GitHub repository URL

@return [Repository]

# File lib/nearmiss-ruby/project.rb, line 11
def self.from_url(url)
  Project.new(URI.parse(url).path[1..-1])
end
new(project) click to toggle source
# File lib/nearmiss-ruby/project.rb, line 16
def initialize(project)
  case project
  # when Integer
  #   @id = project
  when String
    @id = project
    # @owner, @name = repo.split('/')
    # unless @owner && @name
    #   raise ArgumentError, "Invalid Repository. Use user/repo format."
    # end
  when Project
    @id   = project.id
    # @name = repo.name
  when Hash
    @id = project[:project] ||= project[:id]
    # @owner = repo[:owner] ||= repo[:user] ||= repo[:username]
  end
end
path(project) click to toggle source

Get the api path for a repo @param project [Integer, String, Hash, Project] A project. @return [String] Api path.

# File lib/nearmiss-ruby/project.rb, line 51
def self.path(project)
  new(project).path
end

Public Instance Methods

id_api_path() click to toggle source

@return [String] Api path for id identified repos

# File lib/nearmiss-ruby/project.rb, line 61
def id_api_path
  "projects/#{@id}"
end
path() click to toggle source

@return [String] Project API path

# File lib/nearmiss-ruby/project.rb, line 43
def path
  # return named_api_path if @owner && @name
  return id_api_path if @id
end
slug() click to toggle source

Project owner/name @return [String]

# File lib/nearmiss-ruby/project.rb, line 37
def slug
  # "#{@owner}/#{@name}"
end
Also aliased as: to_s
to_s()
Alias for: slug
url() click to toggle source

Project URL based on {Nearmiss::Client#web_endpoint} @return [String]

# File lib/nearmiss-ruby/project.rb, line 67
def url
  # "#{Octokit.web_endpoint}#{slug}"
end