Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 36 lines (27 sloc) 0.853 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
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
7 require 'repository'
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
8
9 class Enforcer
7356ea1 @coreyhaines Adding api key
coreyhaines authored
10 def initialize(account_name, api_key)
d3f87e9 @coreyhaines Added account name to enforcer
coreyhaines authored
11 @account_name = account_name
7356ea1 @coreyhaines Adding api key
coreyhaines authored
12 @api_key = api_key
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
13 end
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
14
22d72fd @qrush Making the DSL a bit more compact
qrush authored
15 def project(project_name, *collaborators)
16 return if collaborators.nil?
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
17
acd1e51 @qrush Adding some debug info so it's easy to figure out what's happening
qrush authored
18 STDOUT.puts "Enforcing settings for #{project_name}"
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
19 repo = Repository.new(@account_name, @api_key, project_name)
20
21 existing_collaborators = repo.list
0c80b05 @coreyhaines Removing people too that don't belong
coreyhaines authored
22
22d72fd @qrush Making the DSL a bit more compact
qrush authored
23 { :add => collaborators - existing_collaborators,
24 :remove => existing_collaborators - collaborators}.each_pair do |action, group|
25 group.each do |collaborator|
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
26 repo.send(action, collaborator)
27 end
0c80b05 @coreyhaines Removing people too that don't belong
coreyhaines authored
28 end
29 end
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
30 end
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
31
7356ea1 @coreyhaines Adding api key
coreyhaines authored
32 def Enforcer(account_name, api_key, &block)
33 enforcer = Enforcer.new(account_name, api_key)
d3f87e9 @coreyhaines Added account name to enforcer
coreyhaines authored
34 enforcer.instance_eval(&block)
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
35 end
Something went wrong with that request. Please try again.