class Danger::DangerChatwork
Attributes
api_token[W]
API token to authenticate with ChatWork API
@return [String]
Public Class Methods
new(dangerfile)
click to toggle source
Calls superclass method
# File lib/chatwork/plugin.rb, line 11 def initialize(dangerfile) super(dangerfile) self.api_token = ENV['CHATWORK_API_TOKEN'] end
Public Instance Methods
notify(room_id:, text: '')
click to toggle source
# File lib/chatwork/plugin.rb, line 16 def notify(room_id:, text: '') return ChatWork::Message.create(room_id: room_id, body: text) unless text.empty? return if reports.empty? report = "[info][title]Danger Report[/title]#{pr_info}\n#{reports.join("\n")}[/info]" ChatWork::Message.create(room_id: room_id, body: report) end
Private Instance Methods
pr_info()
click to toggle source
# File lib/chatwork/plugin.rb, line 39 def pr_info # TODO: GitHub(Enterprise)以外のPR情報取得 github = @dangerfile.github <<-INFO #{github.pr_title} ##{github.pr_json['number']} #{github.pr_json['html_url']} INFO end
reports()
click to toggle source
# File lib/chatwork/plugin.rb, line 29 def reports status_report.reject { |_, v| v.empty? }.map do |status, messages| messages = messages.map(&:message) if status == :markdowns <<-REPORT #{status.to_s} - #{messages.join("\n - ")} REPORT end end