Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 37 lines (29 sloc) 0.992 kB
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
1 $:.unshift(File.dirname(__FILE__))
2861d65 @coreyhaines Fleshing out some features and starting on the tests
coreyhaines authored
2 require 'github_api'
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
0c80b05 @coreyhaines Removing people too that don't belong
coreyhaines authored
14 existing_collaborators = GitHubApi.list_collaborators(@account_name, project_name)
15
16 { :add => @collaborators - existing_collaborators,
17 :remove => existing_collaborators - @collaborators}.each_pair do |action, collaborators|
18 modify_collaborators action, project_name, collaborators
19 end
20 end
21
22 def modify_collaborators(action, project_name, these)
23 these.each do |collaborator|
24 GitHubApi.send("#{action}_collaborator", @account_name, @api_key, project_name, collaborator)
493248e @coreyhaines Making binding work and figuring out more of the DSL
coreyhaines authored
25 end
26 end
27
28 def collaborators(*names)
29 @collaborators = names
30 end
31 end
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
32
7356ea1 @coreyhaines Adding api key
coreyhaines authored
33 def Enforcer(account_name, api_key, &block)
34 enforcer = Enforcer.new(account_name, api_key)
d3f87e9 @coreyhaines Added account name to enforcer
coreyhaines authored
35 enforcer.instance_eval(&block)
4aeb4b3 @coreyhaines Plenty of confusion since either fakeweb or github is being a pain
coreyhaines authored
36 end
Something went wrong with that request. Please try again.