bouncer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +22 -0
- data/Rakefile +56 -0
- data/bin/bouncer +29 -0
- data/bouncer.gemspec +57 -0
- data/lib/bouncer.rb +41 -0
- data/lib/bouncer/version.rb +3 -0
- data/test/helper.rb +10 -0
- data/test/test_bouncer.rb +7 -0
- metadata +92 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Andrew Nesbitt
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
= Bouncer
|
2
|
+
|
3
|
+
Bouncer makes it easy to remove a collabroator's access to all of your github projects, perfect for when someone leaves your company or team and you don't want them to have access to your projects anymore.
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
sudo gem install bouncer
|
8
|
+
bouncer -c dhh -a rails -t 0335sdfsdb171145fgd4ec04f
|
9
|
+
|
10
|
+
== Note on Patches/Pull Requests
|
11
|
+
|
12
|
+
* Fork the project.
|
13
|
+
* Make your feature addition or bug fix.
|
14
|
+
* Add tests for it. This is important so I don't break it in a
|
15
|
+
future version unintentionally.
|
16
|
+
* Commit, do not mess with rakefile, version, or history.
|
17
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
18
|
+
* Send me a pull request. Bonus points for topic branches.
|
19
|
+
|
20
|
+
== Copyright
|
21
|
+
|
22
|
+
Copyright (c) 2010 Andrew Nesbitt. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'lib/bouncer/version.rb'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "bouncer"
|
10
|
+
gem.version = Bouncer::VERSION
|
11
|
+
gem.summary = "Kick people out of your github projects"
|
12
|
+
gem.description = "Bouncer makes it easy to remove a collabroator's access to all of your github projects, perfect for when someone leaves your company or team and you don't want them to have access to your projects anymore."
|
13
|
+
gem.email = "andrewnez@gmail.com"
|
14
|
+
gem.homepage = "http://github.com/andrew/bouncer"
|
15
|
+
gem.authors = ["Andrew Nesbitt"]
|
16
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
Rake::TestTask.new(:test) do |test|
|
26
|
+
test.libs << 'lib' << 'test'
|
27
|
+
test.pattern = 'test/**/test_*.rb'
|
28
|
+
test.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'rcov/rcovtask'
|
33
|
+
Rcov::RcovTask.new do |test|
|
34
|
+
test.libs << 'test'
|
35
|
+
test.pattern = 'test/**/test_*.rb'
|
36
|
+
test.verbose = true
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
task :rcov do
|
40
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
task :test => :check_dependencies
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
require 'rake/rdoctask'
|
49
|
+
Rake::RDocTask.new do |rdoc|
|
50
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
51
|
+
|
52
|
+
rdoc.rdoc_dir = 'rdoc'
|
53
|
+
rdoc.title = "bouncer #{version}"
|
54
|
+
rdoc.rdoc_files.include('README*')
|
55
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
+
end
|
data/bin/bouncer
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'bouncer'
|
5
|
+
require 'lib/bouncer/version.rb'
|
6
|
+
|
7
|
+
options = Hash.new
|
8
|
+
|
9
|
+
help = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: bouncer [options]"
|
11
|
+
opts.on('-v', '--version') { puts "Bouncer v#{Bouncer::VERSION}"; exit(0) }
|
12
|
+
opts.on('-c', '--collaborator [github user name]', 'Example: dhh') do |collaborator|
|
13
|
+
options[:collaborator] = collaborator if collaborator
|
14
|
+
end
|
15
|
+
opts.on('-a', '--account [github account]', 'Example: rails') do |account|
|
16
|
+
options[:account] = account if account
|
17
|
+
end
|
18
|
+
opts.on('-t', '--token [github api token]', 'Example: 0335sdfsdb171145fgd4ec04f') do |token|
|
19
|
+
options[:token] = token if token
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
help.parse!
|
24
|
+
|
25
|
+
if options.empty?
|
26
|
+
puts help.to_s
|
27
|
+
else
|
28
|
+
Bouncer.remove_collaborator(options)
|
29
|
+
end
|
data/bouncer.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{bouncer}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Andrew Nesbitt"]
|
12
|
+
s.date = %q{2010-06-04}
|
13
|
+
s.default_executable = %q{bouncer}
|
14
|
+
s.description = %q{Bouncer makes it easy to remove a collabroator's access to all of your github projects, perfect for when someone leaves your company or team and you don't want them to have access to your projects anymore.}
|
15
|
+
s.email = %q{andrewnez@gmail.com}
|
16
|
+
s.executables = ["bouncer"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"bin/bouncer",
|
28
|
+
"bouncer.gemspec",
|
29
|
+
"lib/bouncer.rb",
|
30
|
+
"lib/bouncer/version.rb",
|
31
|
+
"test/helper.rb",
|
32
|
+
"test/test_bouncer.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/andrew/bouncer}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.7}
|
38
|
+
s.summary = %q{Kick people out of your github projects}
|
39
|
+
s.test_files = [
|
40
|
+
"test/helper.rb",
|
41
|
+
"test/test_bouncer.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/lib/bouncer.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'curb'
|
3
|
+
|
4
|
+
module Bouncer
|
5
|
+
def self.remove_collaborator(options)
|
6
|
+
collaborator, account, token = options[:collaborator], options[:account], options[:token]
|
7
|
+
|
8
|
+
return puts "Must provide a account" if account.nil?
|
9
|
+
return puts "Must provide a github token" if token.nil?
|
10
|
+
return puts "Must provide a collaborator to remove" if collaborator.nil?
|
11
|
+
|
12
|
+
return puts "You can't remove yourself from your projects" if !collaborator.nil? && collaborator == account
|
13
|
+
|
14
|
+
repos = repositiories(account, token)
|
15
|
+
repos.each do |repo|
|
16
|
+
remove_from_project(collaborator, repo['name'], account, token)
|
17
|
+
sleep 1 # to avoid hitting the github rate limit
|
18
|
+
end
|
19
|
+
|
20
|
+
puts "#{collaborator} was removed from #{repos.size} repositiories"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.repositiories(account, token)
|
24
|
+
JSON.parse(Curl::Easy.http_post("https://github.com/api/v2/json/repos/show/#{account}",
|
25
|
+
Curl::PostField.content('login', account),
|
26
|
+
Curl::PostField.content('token', token)).body_str)['repositories']
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.remove_from_project(collaborator, repo_name, account, token)
|
30
|
+
result = Curl::Easy.http_post("https://github.com/api/v2/json/repos/collaborators/#{repo_name}/remove/#{collaborator}",
|
31
|
+
Curl::PostField.content('login', account),
|
32
|
+
Curl::PostField.content('token', token))
|
33
|
+
remaining_collaborators = JSON.parse(result.body_str)['collaborators']
|
34
|
+
|
35
|
+
if remaining_collaborators.include?(collaborator)
|
36
|
+
puts "Failed to remove #{collaborator} from #{repo_name}"
|
37
|
+
else
|
38
|
+
puts "Removed #{collaborator} from #{repo_name}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bouncer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andrew Nesbitt
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-04 00:00:00 +01:00
|
19
|
+
default_executable: bouncer
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thoughtbot-shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Bouncer makes it easy to remove a collabroator's access to all of your github projects, perfect for when someone leaves your company or team and you don't want them to have access to your projects anymore.
|
36
|
+
email: andrewnez@gmail.com
|
37
|
+
executables:
|
38
|
+
- bouncer
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- bin/bouncer
|
51
|
+
- bouncer.gemspec
|
52
|
+
- lib/bouncer.rb
|
53
|
+
- lib/bouncer/version.rb
|
54
|
+
- test/helper.rb
|
55
|
+
- test/test_bouncer.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/andrew/bouncer
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --charset=UTF-8
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 3
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.3.7
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Kick people out of your github projects
|
90
|
+
test_files:
|
91
|
+
- test/helper.rb
|
92
|
+
- test/test_bouncer.rb
|