Class: Octokit::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/octokit/repository.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Repository

Returns a new instance of Repository.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/octokit/repository.rb', line 11

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

Instance Attribute Details

#nameObject Also known as: repo

Returns the value of attribute name.



5
6
7
# File 'lib/octokit/repository.rb', line 5

def name
  @name
end

#usernameObject Also known as: user

Returns the value of attribute username.



5
6
7
# File 'lib/octokit/repository.rb', line 5

def username
  @username
end

Class Method Details

.from_url(url) ⇒ Object



7
8
9
# File 'lib/octokit/repository.rb', line 7

def self.from_url(url)
  Repository.new(Addressable::URI.parse(url).path[1..-1])
end

Instance Method Details

#slugObject



24
25
26
# File 'lib/octokit/repository.rb', line 24

def slug
  [@username, @name].compact.join('/')
end

#to_sObject



28
29
30
# File 'lib/octokit/repository.rb', line 28

def to_s
  self.slug
end

#urlObject



32
33
34
# File 'lib/octokit/repository.rb', line 32

def url
  "https://github.com/#{slug}"
end