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, auth_type: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bitbucket/representation/repo.rb', line 18

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

  if token.present?
    clone_url = URI.parse(url)

    clone_url.user = if auth_type == :basic
                       token
                     else
                       "x-token-auth:#{token}"
                     end

    clone_url.to_s
  else
    url
  end
end

#default_branchObject



68
69
70
# File 'lib/bitbucket/representation/repo.rb', line 68

def default_branch
  raw.dig('mainbranch', 'name')
end

#descriptionObject



36
37
38
# File 'lib/bitbucket/representation/repo.rb', line 36

def description
  raw['description']
end

#errorObject



76
77
78
# File 'lib/bitbucket/representation/repo.rb', line 76

def error
  raw['error']
end

#full_nameObject



40
41
42
# File 'lib/bitbucket/representation/repo.rb', line 40

def full_name
  raw['full_name']
end

#has_wiki?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/bitbucket/representation/repo.rb', line 56

def has_wiki?
  raw['has_wiki']
end

#issues_enabled?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/bitbucket/representation/repo.rb', line 44

def issues_enabled?
  raw['has_issues']
end

#nameObject



48
49
50
# File 'lib/bitbucket/representation/repo.rb', line 48

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



72
73
74
# File 'lib/bitbucket/representation/repo.rb', line 72

def to_s
  full_name
end

#valid?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/bitbucket/representation/repo.rb', line 52

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

#visibility_levelObject



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

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