Sha256: 809dfe462fc25ff0849fa13075cc26cd6ae34cfecb28c6494ce861002e970173
Contents?: true
Size: 1.54 KB
Versions: 9
Compression:
Stored size: 1.54 KB
Contents
class CC::Service::Flowdock < CC::Service class Config < CC::Service::Config attribute :api_token, String, label: "API Token", description: "The API token of the Flow to send notifications to", link: "https://www.flowdock.com/account/tokens" validates :api_token, presence: true end BASE_URL = "https://api.flowdock.com/v1" INVALID_PROJECT_CHARACTERS = /[^0-9a-z\-_ ]+/i self.description = "Send messages to a Flowdock inbox" def receive_test notify("Test", repo_name, formatter.format_test).merge( message: "Test message sent" ) end def receive_coverage notify("Coverage", repo_name, formatter.format_coverage) end def receive_quality notify("Quality", repo_name, formatter.format_quality) end def receive_vulnerability notify("Vulnerability", repo_name, formatter.format_vulnerability) end private def formatter CC::Formatters::LinkedFormatter.new( self, prefix: "", prefix_with_repo: false, link_style: :html ) end 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 end
Version data entries
9 entries across 9 versions & 1 rubygems