Sha256: 625120b464bf1252c87d652ab0d4f2c69075f007709f1da1b5c13c9da55c6c92

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

#!/usr/bin/env ruby
require 'optparse'
require 'octokit'

options = {}

OptionParser.new do |opts|
  opts.banner = "Usage: tutter --project [project] [options]"
  opts.on("-p", "--project [PROJECT]", "Github project name (jhaals/tutter)") do |p|
    options[:project] = p
  end
  opts.on("-e", "--events [EVENTS]", "Github events that will trigger tutter") do |e|
    options[:events] = e
  end
  opts.on("-u", "--url [URL]", "URL to the tutter service") do |u|
    options[:url] = u
  end
  opts.on("-t", "--access-token [TOKEN]", "Github access token") do |t|
    options[:access_token] = t
  end
  opts.on("--github-api-endpoint [api-endpoint]", "Github API endpoint") do |t|
    options[:api_endpoint] = t
  end
  opts.on("--github-web-url [GITHUBWEBSITE]", "Github website url") do |t|
    options[:base_url] = t
  end
end.parse!

if options[:project].nil?
  puts '--project required'
  exit 1
end

if options[:url].nil?
  puts '--url required'
  exit 1
end

if options[:access_token].nil?
  puts '--access-token required'
  exit 1
end

if options[:base_url].nil?
  puts '--github-web-url required'
  exit 1
end

if options[:api_endpoint].nil?
  puts '--github-api-endpoint required'
  exit 1
end

Octokit.configure do |c|
  c.api_endpoint = options[:api_endpoint]
  c.web_endpoint = options[:base_url]
end

client = Octokit::Client.new :access_token => options[:access_token]
client.login

p client.create_hook(
  options[:project],
  'web',
  {
    :url => options[:url],
    :content_type => 'json'
  },
  {
    :events => options[:events].split(','),
    :active => true
  }
)


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tutter-0.0.1 bin/tutter