Module: Wassup::Helpers::CircleCI::Formatter

Defined in:
lib/wassup/helpers/circleci.rb

Class Method Summary collapse

Class Method Details

.workflow(workflow) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/wassup/helpers/circleci.rb', line 49

def self.workflow(workflow)
  pipeline = workflow["pipeline"]
  number = pipeline["number"]
  message = (pipeline["vcs"]["commit"] || {})["subject"]
   = pipeline["trigger"]["actor"]["login"]

  status = workflow["status"]
  status_formatted = '%-8.8s' % status

  number_formatted = '%-7.7s' % "##{number}"

  if status == "failed"
    status_formatted = "[fg=red]#{status_formatted}[fg=white]"
  elsif status == "success"
    status_formatted = "[fg=green]#{status_formatted}[fg=white]"
  else
    status_formatted = "[fg=yellow]#{status_formatted}[fg=white]"
  end

  display = "[fg=yellow]#{number_formatted} [fg=while]#{status_formatted} [fg=white]#{} [fg=gray]#{message}"
  
  return display
end