Class: Gitlab::Ci::Badge::Release::LatestRelease

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/ci/badge/release/latest_release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#status

Constructor Details

#initialize(project, current_user, opts: {}) ⇒ LatestRelease

Returns a new instance of LatestRelease.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 9

def initialize(project, current_user, opts: {})
  @project = project
  @customization = {
    key_width: opts[:key_width] ? opts[:key_width].to_i : nil,
    key_text: opts[:key_text],
    value_width: opts[:value_width] ? opts[:value_width].to_i : nil
  }

  # In the future, we should support `order_by=semver` for showing the
  # latest release based on Semantic Versioning.
  @release = ::ReleasesFinder.new(
    project,
    current_user,
    order_by_for_latest: opts[:order_by],
    latest: true).execute.first
end

Instance Attribute Details

#customizationObject (readonly)

Returns the value of attribute customization.



7
8
9
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 7

def customization
  @customization
end

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 7

def project
  @project
end

#releaseObject (readonly)

Returns the value of attribute release.



7
8
9
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 7

def release
  @release
end

Instance Method Details

#entityObject



26
27
28
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 26

def entity
  'Latest Release'
end

#metadataObject



34
35
36
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 34

def 
  @metadata ||= Release::Metadata.new(self)
end

#tagObject



30
31
32
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 30

def tag
  @release&.tag
end

#templateObject



38
39
40
# File 'lib/gitlab/ci/badge/release/latest_release.rb', line 38

def template
  @template ||= Release::Template.new(self)
end