Class: BitbucketServer::Representation::Repo

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

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from Base

convert_timestamp, decorate, #initialize

Constructor Details

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

Instance Method Details

#browse_urlObject



18
19
20
21
22
# File 'lib/bitbucket_server/representation/repo.rb', line 18

def browse_url
  # The JSON response contains an array of 1 element. Not sure if there
  # are cases where multiple links would be provided.
  raw.dig('links', 'self').first.fetch('href')
end

#clone_urlObject



24
25
26
# File 'lib/bitbucket_server/representation/repo.rb', line 24

def clone_url
  raw['links']['clone'].find { |link| link['name'].starts_with?('http') }.fetch('href')
end

#descriptionObject



28
29
30
# File 'lib/bitbucket_server/representation/repo.rb', line 28

def description
  raw['description']
end

#full_nameObject



32
33
34
# File 'lib/bitbucket_server/representation/repo.rb', line 32

def full_name
  "#{project_name}/#{name}"
end

#issues_enabled?Boolean

Returns:

  • (Boolean)


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

def issues_enabled?
  true
end

#nameObject



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

def name
  raw['name']
end

#projectObject



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

def project
  raw['project']
end

#project_keyObject



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

def project_key
  raw.dig('project', 'key')
end

#project_nameObject



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

def project_name
  raw.dig('project', 'name')
end

#slugObject



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

def slug
  raw['slug']
end

#to_sObject



60
61
62
# File 'lib/bitbucket_server/representation/repo.rb', line 60

def to_s
  full_name
end

#valid?Boolean

Returns:

  • (Boolean)


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

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

#visibility_levelObject



48
49
50
51
52
53
54
# File 'lib/bitbucket_server/representation/repo.rb', line 48

def visibility_level
  if project['public']
    Gitlab::VisibilityLevel::PUBLIC
  else
    Gitlab::VisibilityLevel::PRIVATE
  end
end