Class: Bitbucket::Representation::Repo

Inherits:
Base
  • Object
show all
Defined in:
lib/bitbucket/representation/repo.rb

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from Base

decorate, #initialize

Constructor Details

This class inherits a constructor from Bitbucket::Representation::Base

Instance Method Details

#clone_url(token = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bitbucket/representation/repo.rb', line 18

def clone_url(token = nil)
  url = raw['links']['clone'].find { |link| link['name'] == 'https' }.fetch('href')

  if token.present?
    clone_url = URI.parse(url)
    clone_url.user = "x-token-auth:#{token}"
    clone_url.to_s
  else
    url
  end
end

#descriptionObject



30
31
32
# File 'lib/bitbucket/representation/repo.rb', line 30

def description
  raw['description']
end

#full_nameObject



34
35
36
# File 'lib/bitbucket/representation/repo.rb', line 34

def full_name
  raw['full_name']
end

#has_wiki?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/bitbucket/representation/repo.rb', line 50

def has_wiki?
  raw['has_wiki']
end

#issues_enabled?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/bitbucket/representation/repo.rb', line 38

def issues_enabled?
  raw['has_issues']
end

#nameObject



42
43
44
# File 'lib/bitbucket/representation/repo.rb', line 42

def name
  raw['name']
end

#ownerObject



10
11
12
# File 'lib/bitbucket/representation/repo.rb', line 10

def owner
  owner_and_slug.first
end

#owner_and_slugObject



6
7
8
# File 'lib/bitbucket/representation/repo.rb', line 6

def owner_and_slug
  @owner_and_slug ||= full_name.split('/', 2)
end

#slugObject



14
15
16
# File 'lib/bitbucket/representation/repo.rb', line 14

def slug
  owner_and_slug.last
end

#to_sObject



62
63
64
# File 'lib/bitbucket/representation/repo.rb', line 62

def to_s
  full_name
end

#valid?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/bitbucket/representation/repo.rb', line 46

def valid?
  raw['scm'] == 'git'
end

#visibility_levelObject



54
55
56
57
58
59
60
# File 'lib/bitbucket/representation/repo.rb', line 54

def visibility_level
  if raw['is_private']
    Gitlab::VisibilityLevel::PRIVATE
  else
    Gitlab::VisibilityLevel::PUBLIC
  end
end