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

Constructor Details

#initialize(raw) ⇒ Repo

Returns a new instance of Repo.


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

def initialize(raw)
  super(raw)
end

Instance Method Details

#clone_url(token = nil) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bitbucket/representation/repo.rb', line 22

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


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

def description
  raw['description']
end

#full_nameObject


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

def full_name
  raw['full_name']
end

#has_wiki?Boolean

Returns:

  • (Boolean)

54
55
56
# File 'lib/bitbucket/representation/repo.rb', line 54

def has_wiki?
  raw['has_wiki']
end

#issues_enabled?Boolean

Returns:

  • (Boolean)

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

def issues_enabled?
  raw['has_issues']
end

#nameObject


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

def name
  raw['name']
end

#ownerObject


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

def owner
  owner_and_slug.first
end

#owner_and_slugObject


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

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

#slugObject


18
19
20
# File 'lib/bitbucket/representation/repo.rb', line 18

def slug
  owner_and_slug.last
end

#to_sObject


66
67
68
# File 'lib/bitbucket/representation/repo.rb', line 66

def to_s
  full_name
end

#valid?Boolean

Returns:

  • (Boolean)

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

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

#visibility_levelObject


58
59
60
61
62
63
64
# File 'lib/bitbucket/representation/repo.rb', line 58

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