Sha256: eea5765796750e13dbc304fdf7c67477a3e0755f7e2ccb077497f59dcc6b9624
Contents?: true
Size: 744 Bytes
Versions: 14
Compression:
Stored size: 744 Bytes
Contents
require 'addressable/uri' module Octokit class Repository attr_accessor :username, :name def self.from_url(url) Repository.new(Addressable::URI.parse(url).path[1..-1]) end def initialize(repo) case repo when String @username, @name = repo.split('/') when Repository @username = repo.username @name = repo.name when Hash @name = repo[:repo] ||= repo[:name] @username = repo[:username] ||= repo[:user] ||= repo[:owner] end end def slug [@username, @name].compact.join('/') end def to_s self.slug end def url "https://github.com/#{slug}" end alias :user :username alias :repo :name end end
Version data entries
14 entries across 14 versions & 3 rubygems