akam_roadmap/lib/tasks/slack.rake
Tyrel Souza 21e920079f slack:
2015-01-06 14:51:02 -05:00

69 lines
2.0 KiB
Ruby

require "uri"
require "net/http"
namespace :slack do
desc "TODO"
task webhook: :environment do
time = Time.new
out = {}
out[:text] = "Last updated at #{time.strftime("%Y-%m-%d %Hgg:%M:%S")}"
out[:color] = "#829495"
out[:pretext] = "Roadmap"
out[:fields] = []
column_1 = {}
column_1[:title] = "Active Project(s)"
column_1[:value] = "<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>"
column_1[:short] = true
column_2 = {}
column_2[:title] = "Furthest Status"
column_2[:value] = "Planning\nPlanning\nComplete\nOverdue :warning:"
column_2[:short] = true
out[:fields] << column_1
out[:fields] << column_2
column_1 = {}
column_1[:title] = "Upcoming Project(s)"
column_1[:value] = "<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>"
column_1[:short] = true
column_2 = {}
column_2[:title] = "Furthest Status"
column_2[:value] = "Planning\nPlanning\nComplete\nOverdue :warning:"
column_2[:short] = true
out[:fields] << column_1
out[:fields] << column_2
column_1 = {}
column_1[:title] = "Backlog Project(s)"
column_1[:value] = "<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>\n<http://www.foo.com|Project 1>"
column_1[:short] = true
column_2 = {}
column_2[:title] = "Furthest Status"
column_2[:value] = "Planning\nPlanning\nComplete\nOverdue :warning:"
column_2[:short] = true
out[:fields] << column_1
out[:fields] << column_2
uri = URI.parse('https://hooks.slack.com/services/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')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {'Content-Type' =>'application/json'})
request.body = out.to_json
response = http.request(request)
puts response.body
end
end