Module: Tping

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

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.request_build(opts) ⇒ Object



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

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

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