class CC::Service::Flowdock

Constants

BASE_URL
INVALID_PROJECT_CHARACTERS

Public Instance Methods

receive_coverage() click to toggle source
# File lib/cc/services/flowdock.rb, line 21
def receive_coverage
  notify("Coverage", repo_name, formatter.format_coverage)
end
receive_quality() click to toggle source
# File lib/cc/services/flowdock.rb, line 25
def receive_quality
  notify("Quality", repo_name, formatter.format_quality)
end
receive_test() click to toggle source
# File lib/cc/services/flowdock.rb, line 15
def receive_test
  notify("Test", repo_name, formatter.format_test).merge(
    message: "Test message sent",
  )
end
receive_vulnerability() click to toggle source
# File lib/cc/services/flowdock.rb, line 29
def receive_vulnerability
  notify("Vulnerability", repo_name, formatter.format_vulnerability)
end

Private Instance Methods

formatter() click to toggle source
# File lib/cc/services/flowdock.rb, line 35
def formatter
  CC::Formatters::LinkedFormatter.new(
    self,
    prefix: "",
    prefix_with_repo: false,
    link_style: :html,
  )
end
notify(subject, project, content) click to toggle source
# File lib/cc/services/flowdock.rb, line 44
def notify(subject, project, content)
  params = {
    source:       "Code Climate",
    from_address: "hello@codeclimate.com",
    from_name:    "Code Climate",
    format:       "html",
    subject:      subject,
    project:      project.gsub(INVALID_PROJECT_CHARACTERS, ""),
    content:      content,
    link:         "https://codeclimate.com",
  }

  url = "#{BASE_URL}/messages/team_inbox/#{config.api_token}"
  http.headers["User-Agent"] = "Code Climate"

  service_post(url, params)
end