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

Constructor Details

#initialize(raw) ⇒ Repo

Returns a new instance of Repo.


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

def initialize(raw)
  super(raw)
end

Instance Method Details

#browse_urlObject


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

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


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

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

#descriptionObject


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

def description
  project['description']
end

#full_nameObject


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

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

#issues_enabled?Boolean

Returns:

  • (Boolean)

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

def issues_enabled?
  true
end

#nameObject


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

def name
  raw['name']
end

#projectObject


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

def project
  raw['project']
end

#project_keyObject


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

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

#project_nameObject


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

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

#slugObject


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

def slug
  raw['slug']
end

#to_sObject


64
65
66
# File 'lib/bitbucket_server/representation/repo.rb', line 64

def to_s
  full_name
end

#valid?Boolean

Returns:

  • (Boolean)

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

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

#visibility_levelObject


52
53
54
55
56
57
58
# File 'lib/bitbucket_server/representation/repo.rb', line 52

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