Module: Tping

Defined in:
lib/tping.rb,
lib/tping/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.request_build(token, user, repo, pro = false) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tping.rb', line 4

def self.request_build(token, user, repo, pro = false)
  headers = ["Content-Type: application/json",
             "Accept: application/json",
             "Travis-API-Version: 3",
             "Authorization: token #{token}"].flat_map do |header|
    ["-H", header]
  end

  command = %w(curl -s -X POST)
  command += headers
  command += ["-d", '{ "request": { "branch": "master" }}']
  command <<  "https://api.travis-ci.#{pro ? "com" : "org"}/repo/#{user}%2F#{repo}/requests"
  system(*command)
end