github-team-remover 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: db6db43efd35e1f9f89ac38e21f655745c92b5ae
4
+ data.tar.gz: 28d90718cac16af8748859c5e040850e1b47c136
5
+ SHA512:
6
+ metadata.gz: 81317ad7b63c321f7e48d1b11e1947752b3b70f9fd9cf04ec9189d4098538706f6778f65ac286f552402e6a01d910cee191a1c78093e4d5587449b46d0021ad2
7
+ data.tar.gz: 5941f5c328c84dfb02403d196e48b86c48cf0558af03e5ffa1b9e4692879d9109809ad866afdcdca30566780397b868e250294bb06a83410de677584c92da0ae
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,19 @@
1
+ AllCops:
2
+ RunRailsCops: true
3
+ Excludes:
4
+ - bin/**
5
+
6
+ Documentation:
7
+ Description: 'Document classes and non-namespace modules.'
8
+ Enabled: false
9
+
10
+ SymbolArray:
11
+ Description: 'Use %i or %I for arrays of symbols.'
12
+ Enabled: true
13
+
14
+ AlignParameters:
15
+ Enabled: false
16
+
17
+ LineLength:
18
+ Description: 'Limit lines to 120 characters.'
19
+ Max: 120
@@ -0,0 +1 @@
1
+ 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in github-team-remover.gemspec
4
+ gemspec
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ github-team-remover (0.0.2)
5
+ octokit (~> 3.0)
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.6)
12
+ ast (1.1.0)
13
+ diff-lcs (1.2.5)
14
+ faraday (0.9.0)
15
+ multipart-post (>= 1.2, < 3)
16
+ json (1.8.1)
17
+ multipart-post (2.0.0)
18
+ octokit (3.0.0)
19
+ sawyer (~> 0.5.3)
20
+ parser (2.1.7)
21
+ ast (~> 1.1)
22
+ slop (~> 3.4, >= 3.4.5)
23
+ powerpack (0.0.9)
24
+ rainbow (2.0.0)
25
+ rspec (3.0.0.beta2)
26
+ rspec-core (= 3.0.0.beta2)
27
+ rspec-expectations (= 3.0.0.beta2)
28
+ rspec-mocks (= 3.0.0.beta2)
29
+ rspec-core (3.0.0.beta2)
30
+ rspec-support (= 3.0.0.beta2)
31
+ rspec-expectations (3.0.0.beta2)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (= 3.0.0.beta2)
34
+ rspec-mocks (3.0.0.beta2)
35
+ rspec-support (= 3.0.0.beta2)
36
+ rspec-support (3.0.0.beta2)
37
+ rubocop (0.19.1)
38
+ json (>= 1.7.7, < 2)
39
+ parser (~> 2.1.7)
40
+ powerpack (~> 0.0.6)
41
+ rainbow (>= 1.99.1, < 3.0)
42
+ ruby-progressbar (~> 1.4)
43
+ ruby-progressbar (1.4.2)
44
+ sawyer (0.5.4)
45
+ addressable (~> 2.3.5)
46
+ faraday (~> 0.8, < 0.10)
47
+ slop (3.5.0)
48
+ thor (0.19.1)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ github-team-remover!
55
+ rspec (~> 3.0.0.beta2)
56
+ rubocop
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Flatstack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # Github Team Remover
2
+
3
+ ## Usage
4
+
5
+ ```ruby
6
+ github-team-remover \
7
+ --organization FlatstackSchool \
8
+ --login github-login \
9
+ --password github-password
10
+ ```
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ bin/bootstrap
16
+ ```
17
+
18
+ ## Quality tools
19
+
20
+ * `bin/quality` based on [RuboCop](https://github.com/bbatsov/rubocop)
21
+ * `.rubocop.yml` describes active checks
22
+
23
+ ## Develop
24
+
25
+ `bin/build` checks your specs and runs quality tools
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'autospec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'autospec')
@@ -0,0 +1,9 @@
1
+ #!/bin/sh
2
+ # Make sure local dependencies are met.
3
+
4
+ cd "$(dirname $0)"/..
5
+
6
+ rm -f .bundle/config
7
+
8
+ bundle check --path .bundle > /dev/null 2>&1 ||
9
+ bundle install --path=.bundle
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -e
4
+
5
+ bin/rspec
6
+ bin/quality
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'remover'
5
+
6
+ Remover::CLI.start(ARGV)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -e
4
+
5
+ bin/rubocop
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rubocop' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rubocop', 'rubocop')
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'remover/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "github-team-remover"
9
+ spec.version = Remover::VERSION
10
+ spec.authors = ["Flatstack School"]
11
+ spec.email = ["fs-admin+school@flatstack.com"]
12
+ spec.summary = %q{Show empty teams on github}
13
+ spec.description = %q{Show empty teams on github. Teams without members or tems without repositories.}
14
+ spec.homepage = "http://github.com/FlatstackSchool/github-team-remover"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = ['github-team-remover']
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'octokit', '~> 3.0'
23
+ spec.add_dependency 'thor'
24
+
25
+ spec.add_development_dependency 'rubocop'
26
+ spec.add_development_dependency 'rspec', '~> 3.0.0.beta2'
27
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'remover/github'
4
+ require 'remover/team'
5
+ require 'remover/list'
6
+ require 'remover/cli'
7
+ require 'remover/configuration'
8
+
9
+ module Remover
10
+ def self.configuration
11
+ @configuration ||= Configuration.new
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ require 'thor'
2
+
3
+ module Remover
4
+ class CLI < Thor
5
+ method_option :organization, required: true
6
+ method_option :login, required: true
7
+ method_option :password, required: true
8
+
9
+ desc('list', 'List unused teams')
10
+
11
+ def list
12
+ Remover.configuration.load_from_options!(options)
13
+
14
+ Remover::List.new(github).unused_teams.each do |team|
15
+ puts team.name
16
+ end
17
+ end
18
+
19
+ default_task :list
20
+
21
+ private
22
+
23
+ def github
24
+ Remover::Github.new(octokit)
25
+ end
26
+
27
+ def octokit
28
+ Octokit::Client.new(
29
+ login: Remover.configuration.login,
30
+ password: Remover.configuration.password
31
+ )
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,13 @@
1
+ module Remover
2
+ class Configuration
3
+ OPTIONS = %i(organization login password)
4
+
5
+ attr_accessor(*OPTIONS)
6
+
7
+ def load_from_options!(options)
8
+ OPTIONS.each do |option|
9
+ send("#{option}=", options[option.to_s])
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ require 'octokit'
2
+
3
+ module Remover
4
+ class Github
5
+ attr_accessor :octokit
6
+
7
+ def initialize(octokit)
8
+ @octokit = octokit
9
+ end
10
+
11
+ def teams
12
+ github_teams.map do |github_team|
13
+ Remover::Team.new(octokit, github_team)
14
+ end
15
+ end
16
+
17
+ def team_members(github_team_id)
18
+ octokit.team_members(github_team_id)
19
+ end
20
+
21
+ def team_repositories(github_team_id)
22
+ octokit.team_repositories(github_team_id)
23
+ end
24
+
25
+ private
26
+
27
+ def github_teams
28
+ octokit.organization_teams(Remover.configuration.organization)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,19 @@
1
+ module Remover
2
+ class List
3
+ attr_accessor :github_client
4
+
5
+ def initialize(github_client)
6
+ @github_client = github_client
7
+ end
8
+
9
+ def unused_teams
10
+ teams.delete_if(&:used?)
11
+ end
12
+
13
+ private
14
+
15
+ def teams
16
+ github_client.teams
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ module Remover
2
+ class Team
3
+ attr_accessor :github_client, :github_team
4
+
5
+ def initialize(github_client, github_team)
6
+ @github_client, @github_team = github_client, github_team
7
+ end
8
+
9
+ def used?
10
+ with_members? && with_repositories?
11
+ end
12
+
13
+ def name
14
+ github_team.name
15
+ end
16
+
17
+ private
18
+
19
+ def with_members?
20
+ github_client.team_members(github_team.id).size > 0
21
+ end
22
+
23
+ def with_repositories?
24
+ github_client.team_repositories(github_team.id).size > 0
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Remover
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,23 @@
1
+ describe Remover::Configuration do
2
+ let(:options) do
3
+ {
4
+ 'organization' => 'FlatSchool',
5
+ 'login' => 'fs-school',
6
+ 'password' => '123456'
7
+ }
8
+ end
9
+
10
+ let(:configuration) { Remover::Configuration.new }
11
+
12
+ describe '#load_from_options!(options)' do
13
+ before do
14
+ configuration.load_from_options!(options)
15
+ end
16
+
17
+ it 'sets options' do
18
+ expect(configuration.organization).to eq('FlatSchool')
19
+ expect(configuration.login).to eq('fs-school')
20
+ expect(configuration.password).to eq('123456')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ describe Remover::Github do
2
+ let(:octokit) { double(Octokit::Client) }
3
+ let(:github) { Remover::Github.new(octokit) }
4
+ let(:github_team_id) { 1 }
5
+
6
+ describe '#teams' do
7
+ before do
8
+ allow(octokit).to receive(:organization_teams) do
9
+ [double('Github Team')]
10
+ end
11
+ end
12
+
13
+ it 'returns array' do
14
+ expect(github.teams).to be_an(Array)
15
+ end
16
+
17
+ it 'returns array of Remover::Team' do
18
+ expect(github.teams.first).to be_an(Remover::Team)
19
+ end
20
+ end
21
+
22
+ describe '#team_members(github_team_id)' do
23
+ before do
24
+ allow(octokit).to receive(:team_members) { [] }
25
+ end
26
+
27
+ it 'returns array' do
28
+ expect(github.team_members(github_team_id)).to be_an(Array)
29
+ end
30
+ end
31
+
32
+ describe '#team_repositories(github_team_id)' do
33
+ before do
34
+ allow(octokit).to receive(:team_repositories) { [] }
35
+ end
36
+
37
+ it 'returns array' do
38
+ expect(github.team_repositories(github_team_id)).to be_an(Array)
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,23 @@
1
+ describe Remover::List do
2
+ let(:github_client) { double('Github Client') }
3
+ let(:list) { Remover::List.new(github_client) }
4
+
5
+ let(:used_team) { double('Used Team', used?: true) }
6
+ let(:unused_team) { double('Unused Team', used?: false) }
7
+ let(:teams) { [used_team, unused_team] }
8
+
9
+ before do
10
+ allow(github_client).to receive(:teams) { teams }
11
+ end
12
+
13
+ describe '#unused_teams' do
14
+ it 'returns array' do
15
+ expect(list.unused_teams).to be_an(Array)
16
+ end
17
+
18
+ it 'returns array of unused teams' do
19
+ expect(list.unused_teams).to include(unused_team)
20
+ expect(list.unused_teams).not_to include(used_team)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ describe Remover::Team do
2
+ let(:github_client) { double('Github Client') }
3
+ let(:github_team) { double('Github Team', id: 1, name: 'Owners') }
4
+ let(:team) { Remover::Team.new(github_client, github_team) }
5
+
6
+ describe '#name' do
7
+ it 'returns Github team name' do
8
+ expect(team.name).to eq(github_team.name)
9
+ end
10
+ end
11
+
12
+ describe '#used' do
13
+ let(:members) { [double('Github Member')] }
14
+ let(:repositories) { [double('Github Repository')] }
15
+
16
+ before do
17
+ allow(github_client).to receive(:team_members) { members }
18
+ allow(github_client).to receive(:team_repositories) { repositories }
19
+ end
20
+
21
+ context 'with full of members and repositories' do
22
+ it 'not used' do
23
+ expect(team).to be_used
24
+ end
25
+ end
26
+
27
+ context 'without members' do
28
+ let(:members) { [] }
29
+
30
+ it 'used' do
31
+ expect(team).not_to be_used
32
+ end
33
+ end
34
+
35
+ context 'without repositories' do
36
+ let(:repositories) { [] }
37
+
38
+ it 'used' do
39
+ expect(team).not_to be_used
40
+ end
41
+ end
42
+
43
+ context 'without members and repositories' do
44
+ let(:members) { [] }
45
+ let(:repositories) { [] }
46
+
47
+ it 'used' do
48
+ expect(team).not_to be_used
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,12 @@
1
+ require 'remover'
2
+
3
+ RSpec.configure do |config|
4
+ config.expect_with :rspec do |expectations|
5
+ expectations.syntax = :expect
6
+ end
7
+
8
+ config.mock_with :rspec do |mocks|
9
+ mocks.syntax = :expect
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github-team-remover
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Flatstack School
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0.beta2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0.beta2
69
+ description: Show empty teams on github. Teams without members or tems without repositories.
70
+ email:
71
+ - fs-admin+school@flatstack.com
72
+ executables:
73
+ - github-team-remover
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".rubocop.yml"
80
+ - ".ruby-version"
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE
84
+ - README.md
85
+ - Rakefile
86
+ - bin/autospec
87
+ - bin/bootstrap
88
+ - bin/build
89
+ - bin/github-team-remover
90
+ - bin/quality
91
+ - bin/rspec
92
+ - bin/rubocop
93
+ - github-team-remover.gemspec
94
+ - lib/.keep
95
+ - lib/remover.rb
96
+ - lib/remover/cli.rb
97
+ - lib/remover/configuration.rb
98
+ - lib/remover/github.rb
99
+ - lib/remover/list.rb
100
+ - lib/remover/team.rb
101
+ - lib/remover/version.rb
102
+ - spec/remover/configuration_spec.rb
103
+ - spec/remover/github_spec.rb
104
+ - spec/remover/list_spec.rb
105
+ - spec/remover/team_spec.rb
106
+ - spec/spec_helper.rb
107
+ homepage: http://github.com/FlatstackSchool/github-team-remover
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.2.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Show empty teams on github
131
+ test_files:
132
+ - spec/remover/configuration_spec.rb
133
+ - spec/remover/github_spec.rb
134
+ - spec/remover/list_spec.rb
135
+ - spec/remover/team_spec.rb
136
+ - spec/spec_helper.rb