class BoGitcw::Chatwork
Constants
- CW_TOKEN
- CW_URI
- ROOM_ID
- USERS
Public Class Methods
new_comment(comment, pr)
click to toggle source
# File lib/bo_gitcw/chatwork.rb, line 57 def new_comment comment, pr pic = [] comment['body'].gsub(/@(\w+)/){|c| pic.push(c.gsub("@", ""))} if pic.empty? "[info][title][PR] #{pr['title']}[/title] #{picon(comment['user']['login'])}(commented)[code]#{comment['body']}[/code][hr]#{to(pr['user']['login'])} Link: #{comment['html_url']}[/info]" else "[info][title][PR] #{pr['title']}[/title] #{picon(comment['user']['login'])}(commented)[code]#{comment['body']}[/code][hr]#{to(pr['user']['login'])} Link: #{comment['html_url']}[hr] #{pic.map{|p| to(p)}.join()}[/info]" end end
new_pull(pr)
click to toggle source
# File lib/bo_gitcw/chatwork.rb, line 53 def new_pull pr "[info][title][NEW] Pull request created by #{picon(pr['user']['login'])}[/title] - Title: #{pr['title']} - Link: #{pr['html_url']}[/info]" end
picon(user)
click to toggle source
# File lib/bo_gitcw/chatwork.rb, line 35 def picon user usr = USERS.select{|u| u[:login] == user}.first if usr.blank? "" else "[picon:#{usr[:cw_id]}]" end end
post(path, data)
click to toggle source
# File lib/bo_gitcw/chatwork.rb, line 71 def post path, data url = "#{CW_URI[:host]}#{path}" res = RestClient.post url, {body: data}, {'X-ChatWorkToken' => CW_TOKEN} p res end
send_message(body)
click to toggle source
# File lib/bo_gitcw/chatwork.rb, line 67 def send_message body post("rooms/#{ROOM_ID}/messages", body) end
to(user)
click to toggle source
# File lib/bo_gitcw/chatwork.rb, line 44 def to user usr = USERS.select{|u| u[:login] == user}.first if usr.blank? "" else "[To:#{usr[:cw_id]}]" end end