Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 47 lines (35 sloc) 1.095 kb
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
1 $:.unshift(File.dirname(__FILE__))
a6ca254 @qrush Shuffling some requires around
qrush authored
2
3 require 'rubygems'
4 require 'httparty'
5 require 'json'
6
4c63ec5 @qrush Act like a grownup gem
qrush authored
7 require 'enforcer/repository'
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
8
9 class Enforcer
534142b @jyurek Version 0.1.1
jyurek authored
10 VERSION = "0.1.1"
4c63ec5 @qrush Act like a grownup gem
qrush authored
11
7356ea1 @coreyhaines Adding api key
coreyhaines authored
12 def initialize(account_name, api_key)
d3f87e9 @coreyhaines Added account name to enforcer
coreyhaines authored
13 @account_name = account_name
7356ea1 @coreyhaines Adding api key
coreyhaines authored
14 @api_key = api_key
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
15 end
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
16
22d72fd @qrush Making the DSL a bit more compact
qrush authored
17 def project(project_name, *collaborators)
18 return if collaborators.nil?
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
19
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
20 repo = Repository.new(@account_name, @api_key, project_name)
21
22 existing_collaborators = repo.list
0c80b05 @coreyhaines Removing people too that don't belong
coreyhaines authored
23
251de9b @qrush Adding some better error checking in
qrush authored
24 if existing_collaborators.nil?
25 STDOUT.puts ">> Can't find existing collaborators for this project"
26 return
27 end
28
22d72fd @qrush Making the DSL a bit more compact
qrush authored
29 { :add => collaborators - existing_collaborators,
30 :remove => existing_collaborators - collaborators}.each_pair do |action, group|
31 group.each do |collaborator|
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
32 repo.send(action, collaborator)
33 end
0c80b05 @coreyhaines Removing people too that don't belong
coreyhaines authored
34 end
35 end
18d8237 @qrush Adding postreceive hooks, thanks to tekkub's gist
qrush authored
36
498f783 @qrush Setting multiple hook urls
qrush authored
37 def postreceive(project_name, *urls)
18d8237 @qrush Adding postreceive hooks, thanks to tekkub's gist
qrush authored
38 repo = Repository.new(@account_name, @api_key, project_name)
498f783 @qrush Setting multiple hook urls
qrush authored
39 repo.postreceive(urls)
18d8237 @qrush Adding postreceive hooks, thanks to tekkub's gist
qrush authored
40 end
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
41 end
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
42
7356ea1 @coreyhaines Adding api key
coreyhaines authored
43 def Enforcer(account_name, api_key, &block)
44 enforcer = Enforcer.new(account_name, api_key)
d3f87e9 @coreyhaines Added account name to enforcer
coreyhaines authored
45 enforcer.instance_eval(&block)
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
46 end
Something went wrong with that request. Please try again.