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] = "\n\n\n" 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] = "\n\n\n" 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] = "\n\n\n" 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