Class: Action::Project::Badge

Inherits:
Object
  • Object
show all
Includes:
SetProjectAndBranch, InchCI::Action
Defined in:
app/services/action/project/badge.rb

Instance Method Summary collapse

Methods included from SetProjectAndBranch

#set_project_and_branch

Methods included from InchCI::Action

#exposures, included

Constructor Details

#initialize(params) ⇒ Badge

Returns a new instance of Badge.


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/services/action/project/badge.rb', line 11

def initialize(params)
  set_project_and_branch(params)
  if !@project
    create_project_and_branch(params)
    if @project && @branch
      create_empty_badge
      enqueue_build
    end
  end
  if @project && @branch
    @badge = InchCI::BadgeRequest.new(@project.service_name, @project.user_name, @project.repo_name, @branch.name)
    format = 'svg' # we only serve SVG badges
    style = params[:style]
    @badge_filename = @badge.local_filename(format, style)
    @content_type = content_types[format]
    if !File.exist?(@badge_filename)
      @badge_filename = Rails.root.join('app/assets/images/transparent.png')
      @content_type = content_types['png']
    end
  end
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)

33
34
35
# File 'app/services/action/project/badge.rb', line 33

def success?
  !@badge.nil?
end