Class: Danger::DangerChatwork

Inherits:
Plugin
  • Object
show all
Defined in:
lib/chatwork/plugin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dangerfile) ⇒ DangerChatwork

Returns a new instance of DangerChatwork.



11
12
13
14
# File 'lib/chatwork/plugin.rb', line 11

def initialize(dangerfile)
  super(dangerfile)
  self.api_token = ENV['CHATWORK_API_TOKEN']
end

Instance Attribute Details

#api_token=(value) ⇒ String (writeonly)

API token to authenticate with ChatWork API

Returns:

  • (String)


9
10
11
# File 'lib/chatwork/plugin.rb', line 9

def api_token=(value)
  @api_token = value
end

Instance Method Details

#notify(room_id:, text: '') ⇒ Object



16
17
18
19
20
21
# 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