Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 35 lines (27 sloc) 0.84 kB
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
1 $:.unshift(File.dirname(__FILE__))
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
2 require 'repository'
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
3
4 class Enforcer
7356ea1 @coreyhaines Adding api key
coreyhaines authored
5 def initialize(account_name, api_key)
d3f87e9 @coreyhaines Added account name to enforcer
coreyhaines authored
6 @account_name = account_name
7356ea1 @coreyhaines Adding api key
coreyhaines authored
7 @api_key = api_key
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
8 end
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
9
10 def project(project_name, &block)
11 instance_eval(&block)
12 return if @collaborators.nil?
13
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
14 repo = Repository.new(@account_name, @api_key, project_name)
15
16 existing_collaborators = repo.list
0c80b05 @coreyhaines Removing people too that don't belong
coreyhaines authored
17
18 { :add => @collaborators - existing_collaborators,
19 :remove => existing_collaborators - @collaborators}.each_pair do |action, collaborators|
56ff3dc @qrush Cleaned up the github api immensely
qrush authored
20 collaborators.each do |collaborator|
21 repo.send(action, collaborator)
22 end
0c80b05 @coreyhaines Removing people too that don't belong
coreyhaines authored
23 end
24 end
25
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
26 def collaborators(*names)
27 @collaborators = names
28 end
29 end
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
30
7356ea1 @coreyhaines Adding api key
coreyhaines authored
31 def Enforcer(account_name, api_key, &block)
32 enforcer = Enforcer.new(account_name, api_key)
d3f87e9 @coreyhaines Added account name to enforcer
coreyhaines authored
33 enforcer.instance_eval(&block)
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
34 end
Something went wrong with that request. Please try again.