github-expirer 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/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +23 -0
- data/Rakefile +6 -0
- data/bin/github-expirer +5 -0
- data/github-expirer.gemspec +31 -0
- data/lib/expirer.rb +15 -0
- data/lib/expirer/checker.rb +17 -0
- data/lib/expirer/cli.rb +25 -0
- data/lib/expirer/config.rb +61 -0
- data/lib/expirer/core_ext/string/underscore_keys.rb +15 -0
- data/lib/expirer/list.rb +57 -0
- data/lib/expirer/reporter.rb +31 -0
- data/lib/expirer/repository.rb +31 -0
- data/lib/expirer/version.rb +3 -0
- data/spec/expirer/checker_spec.rb +29 -0
- data/spec/expirer/config_spec.rb +48 -0
- data/spec/expirer/list_spec.rb +50 -0
- data/spec/expirer/reporter_spec.rb +34 -0
- data/spec/expirer/repository_spec.rb +48 -0
- data/spec/expirer_spec.rb +41 -0
- data/spec/fixtures/config.yml +5 -0
- data/spec/spec_helper.rb +13 -0
- metadata +230 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Timur Vafin, Timur Batirshin
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Github Expirer
|
|
2
|
+
|
|
3
|
+
A quick hack to produce a list of not used repositories at Github.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
$ gem install github-expirer
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
$ github-expirer --username user \
|
|
12
|
+
--password password \
|
|
13
|
+
--organization github-org \
|
|
14
|
+
--private-only true \
|
|
15
|
+
--expire-date "6 months ago"
|
|
16
|
+
|
|
17
|
+
## Contributing
|
|
18
|
+
|
|
19
|
+
1. Fork it
|
|
20
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
21
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
22
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
23
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/github-expirer
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'expirer/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'github-expirer'
|
|
8
|
+
spec.version = Expirer::VERSION
|
|
9
|
+
spec.authors = ['Timur Vafin']
|
|
10
|
+
spec.email = ['timur.vafin@flatstack.com']
|
|
11
|
+
spec.description = %q{A quick hack to produce a list of not used repositories at Github.}
|
|
12
|
+
spec.summary = %q{A quick hack to produce a list of not used repositories at Github.}
|
|
13
|
+
spec.homepage = ''
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
|
19
|
+
spec.require_paths = ['lib']
|
|
20
|
+
|
|
21
|
+
spec.add_dependency 'activesupport'
|
|
22
|
+
spec.add_dependency 'github_api'
|
|
23
|
+
spec.add_dependency 'chronic'
|
|
24
|
+
spec.add_dependency 'ansi'
|
|
25
|
+
spec.add_dependency 'thor'
|
|
26
|
+
|
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
28
|
+
spec.add_development_dependency 'rake'
|
|
29
|
+
spec.add_development_dependency 'rspec'
|
|
30
|
+
spec.add_development_dependency 'timecop'
|
|
31
|
+
end
|
data/lib/expirer.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'expirer/version'
|
|
2
|
+
require 'expirer/config'
|
|
3
|
+
require 'expirer/repository'
|
|
4
|
+
require 'expirer/checker'
|
|
5
|
+
require 'expirer/reporter'
|
|
6
|
+
require 'expirer/list'
|
|
7
|
+
require 'expirer/cli'
|
|
8
|
+
|
|
9
|
+
module Expirer
|
|
10
|
+
extend self
|
|
11
|
+
|
|
12
|
+
def configuration
|
|
13
|
+
@configuration ||= Config.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'chronic'
|
|
2
|
+
|
|
3
|
+
module Expirer
|
|
4
|
+
class Checker
|
|
5
|
+
def self.expired?(repository)
|
|
6
|
+
new(repository).expired?
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def initialize(repository)
|
|
10
|
+
@repository = repository
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def expired?
|
|
14
|
+
@repository.last_updated_at < Expirer.configuration.expire_date
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/expirer/cli.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
|
|
3
|
+
module Expirer
|
|
4
|
+
class CLI < Thor
|
|
5
|
+
option 'username', required: true
|
|
6
|
+
option 'password', required: true
|
|
7
|
+
option 'organization', type: :string
|
|
8
|
+
option 'private-only', type: :boolean
|
|
9
|
+
option 'expire-date', type: :string
|
|
10
|
+
option 'config', type: :string
|
|
11
|
+
|
|
12
|
+
desc 'list', 'List expired repositories'
|
|
13
|
+
|
|
14
|
+
def list
|
|
15
|
+
Expirer.configuration.load_from_file!(options[:file])
|
|
16
|
+
Expirer.configuration.load_from_options!(options.to_hash)
|
|
17
|
+
|
|
18
|
+
Expirer::List.with_expired do |repository|
|
|
19
|
+
puts Expirer::Reporter.report(repository)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
default_task :list
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'active_support/core_ext/hash/keys'
|
|
3
|
+
require 'expirer/core_ext/string/underscore_keys'
|
|
4
|
+
|
|
5
|
+
module Expirer
|
|
6
|
+
class Config
|
|
7
|
+
DEFAULTS = {
|
|
8
|
+
private_only: true,
|
|
9
|
+
expire_date: '1 year ago'
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
OPTIONS = [:username, :password, :organization, :private_only, :expire_date]
|
|
13
|
+
attr_accessor *OPTIONS
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
reset!
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def load_from_file!(file)
|
|
20
|
+
set_options(config_from_file(file)) if file && File.exists?(file)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def reset!
|
|
24
|
+
set_options(DEFAULTS)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def load_from_options!(options)
|
|
28
|
+
set_options(options.underscore_keys.symbolize_keys)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def expire_date
|
|
32
|
+
@parsed_expire_date ||= Chronic.parse(@expire_date).to_datetime
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def private_only?
|
|
36
|
+
private_only
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def config_from_file(file)
|
|
42
|
+
@config_from_file ||= YAML.load(File.read(file)).symbolize_keys
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def set_option(key, value)
|
|
46
|
+
self.send("#{key}=", value)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def with_options
|
|
50
|
+
OPTIONS.each do |key|
|
|
51
|
+
yield(key)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def set_options(storage)
|
|
56
|
+
with_options do |key|
|
|
57
|
+
set_option(key, storage[key]) if storage.include?(key)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
data/lib/expirer/list.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'active_support/core_ext/module/delegation'
|
|
2
|
+
|
|
3
|
+
module Expirer
|
|
4
|
+
class List
|
|
5
|
+
delegate :private_only?, :username, :password, :organization,
|
|
6
|
+
to: :configuration
|
|
7
|
+
|
|
8
|
+
def self.with_expired(&block)
|
|
9
|
+
new.with_expired(&block)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def with_expired
|
|
13
|
+
expired(repositories).each do |repository|
|
|
14
|
+
yield(repository) if include?(repository)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def expired(repositories)
|
|
21
|
+
repositories.select do |repository|
|
|
22
|
+
repository.expired?
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def include?(repository)
|
|
27
|
+
return true unless private_only?
|
|
28
|
+
repository.private?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def repositories
|
|
32
|
+
@repositories ||= wrap(github_repositories)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def wrap(repositories)
|
|
36
|
+
repositories.map { |repository| Repository.new(repository) }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def github_repositories
|
|
40
|
+
@github_repositories ||= github.repos.all(
|
|
41
|
+
org: organization,
|
|
42
|
+
per_page: 10_000
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def github
|
|
47
|
+
@github ||= Github.new(
|
|
48
|
+
login: username,
|
|
49
|
+
password: password
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def configuration
|
|
54
|
+
Expirer.configuration
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'ansi/code'
|
|
2
|
+
|
|
3
|
+
module Expirer
|
|
4
|
+
class Reporter
|
|
5
|
+
def self.report(repository)
|
|
6
|
+
new(repository).report
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def initialize(repository)
|
|
10
|
+
@repository = repository
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def report
|
|
14
|
+
"#{datetime}: #{url}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def datetime
|
|
20
|
+
@repository.last_updated_at.strftime('%Y %b %e %a %T')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def url
|
|
24
|
+
if @repository.private?
|
|
25
|
+
ANSI.red { @repository.url }
|
|
26
|
+
else
|
|
27
|
+
ANSI.blue { @repository.url }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'github_api'
|
|
2
|
+
|
|
3
|
+
module Expirer
|
|
4
|
+
class Repository
|
|
5
|
+
def initialize(github_repository)
|
|
6
|
+
@github_repository = github_repository
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def private?
|
|
10
|
+
@github_repository.private
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def last_updated_at
|
|
14
|
+
DateTime.parse(last_updated_at_value)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def url
|
|
18
|
+
@github_repository.html_url
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def expired?
|
|
22
|
+
Checker.expired?(self)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def last_updated_at_value
|
|
28
|
+
@github_repository.pushed_at || @github_repository.updated_at
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Expirer::Checker do
|
|
4
|
+
describe '.expired?' do
|
|
5
|
+
before do
|
|
6
|
+
Expirer.configuration.expire_date = '6 month ago'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
subject { Expirer::Checker.expired?(repository) }
|
|
10
|
+
|
|
11
|
+
context 'with expired repo' do
|
|
12
|
+
let(:repository) do
|
|
13
|
+
double(Expirer::Repository,
|
|
14
|
+
last_updated_at: Chronic.parse('10 months ago').to_datetime)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it { should be true }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'with fresh repo' do
|
|
21
|
+
let(:repository) do
|
|
22
|
+
double(Expirer::Repository,
|
|
23
|
+
last_updated_at: Chronic.parse('1 month ago').to_datetime)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it { should be false }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Expirer::Config do
|
|
4
|
+
subject(:config) { Expirer::Config.new }
|
|
5
|
+
|
|
6
|
+
context 'without configuration file' do
|
|
7
|
+
let(:file) { nil }
|
|
8
|
+
|
|
9
|
+
it 'set default values' do
|
|
10
|
+
expect(config.private_only?).to eq(true)
|
|
11
|
+
expect(config.expire_date).to eq(DateTime.parse('2012-01-01 00:00:00'))
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'with configuration file' do
|
|
16
|
+
before do
|
|
17
|
+
config.load_from_file!('spec/fixtures/config.yml')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'set values from file' do
|
|
21
|
+
expect(config.username).to eq('user')
|
|
22
|
+
expect(config.password).to eq('password')
|
|
23
|
+
expect(config.organization).to eq('fs')
|
|
24
|
+
expect(config.private_only?).to eq(false)
|
|
25
|
+
expect(config.expire_date).to eq(DateTime.parse('2012-07-01 00:00:00'))
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context 'with command line options' do
|
|
30
|
+
before do
|
|
31
|
+
config.load_from_options!({
|
|
32
|
+
'username' => 'user',
|
|
33
|
+
'password' => 'password',
|
|
34
|
+
'organization' => 'fs',
|
|
35
|
+
'private-only' => false,
|
|
36
|
+
'expire-date' => '6 months ago'
|
|
37
|
+
})
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'set values from options' do
|
|
41
|
+
expect(config.username).to eq('user')
|
|
42
|
+
expect(config.password).to eq('password')
|
|
43
|
+
expect(config.organization).to eq('fs')
|
|
44
|
+
expect(config.private_only?).to eq(false)
|
|
45
|
+
expect(config.expire_date).to eq(DateTime.parse('2012-07-01 00:00:00'))
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Expirer::List do
|
|
4
|
+
let(:private_fresh) { double(Expirer::Repository, expired?: false, private?: true, url: 'private_fresh') }
|
|
5
|
+
let(:private_expired) { double(Expirer::Repository, expired?: true, private?: true, url: 'private_expired') }
|
|
6
|
+
let(:public_expired) { double(Expirer::Repository, expired?: true, private?: false, url: 'public_expired') }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
Expirer::List.any_instance.should_receive(:repositories) {[
|
|
10
|
+
private_fresh, private_expired, public_expired
|
|
11
|
+
]}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'when private only is set to true' do
|
|
15
|
+
before do
|
|
16
|
+
Expirer.configuration.private_only = true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'iterates on private only' do
|
|
20
|
+
private_fresh.should_not_receive(:url)
|
|
21
|
+
private_expired.should_receive(:url)
|
|
22
|
+
public_expired.should_not_receive(:url)
|
|
23
|
+
|
|
24
|
+
Expirer::List.with_expired do |repository|
|
|
25
|
+
expect(repository).to be_expired
|
|
26
|
+
expect(repository).to be_private
|
|
27
|
+
|
|
28
|
+
repository.url
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'when private only is set to false' do
|
|
34
|
+
before do
|
|
35
|
+
Expirer.configuration.private_only = false
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'iterates on all' do
|
|
39
|
+
private_fresh.should_not_receive(:url)
|
|
40
|
+
private_expired.should_receive(:url)
|
|
41
|
+
public_expired.should_receive(:url)
|
|
42
|
+
|
|
43
|
+
Expirer::List.with_expired do |repository|
|
|
44
|
+
expect(repository).to be_expired
|
|
45
|
+
|
|
46
|
+
repository.url
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Expirer::Reporter do
|
|
6
|
+
let(:repository) do
|
|
7
|
+
double(Expirer::Repository,
|
|
8
|
+
pushed_at: double(strftime: 'datetime'),
|
|
9
|
+
url: 'url'
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
subject(:report) { Expirer::Reporter.report(repository) }
|
|
14
|
+
|
|
15
|
+
context 'when private' do
|
|
16
|
+
before do
|
|
17
|
+
repository.stub(:private?) { true }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'report' do
|
|
21
|
+
expect(report).to eq("datetime: \e[31murl\e[0m")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'when public' do
|
|
26
|
+
before do
|
|
27
|
+
repository.stub(:private?) { false }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'report' do
|
|
31
|
+
expect(report).to eq("datetime: \e[34murl\e[0m")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Expirer::Repository do
|
|
4
|
+
let(:repository) do
|
|
5
|
+
Expirer::Repository.new(double(
|
|
6
|
+
pushed_at: '2011-01-26T19:06:43Z',
|
|
7
|
+
html_url: 'http://github.com/fs/test',
|
|
8
|
+
private: true
|
|
9
|
+
))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '#last_updated_at' do
|
|
13
|
+
it 'parse pushed_at' do
|
|
14
|
+
expect(repository.last_updated_at).to be_a_kind_of(DateTime)
|
|
15
|
+
expect(repository.last_updated_at).to eq(DateTime.parse('2011-01-26T19:06:43Z'))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context 'without pushed_at' do
|
|
19
|
+
let(:repository) do
|
|
20
|
+
Expirer::Repository.new(double(
|
|
21
|
+
pushed_at: nil,
|
|
22
|
+
updated_at: '2011-01-26T19:06:43Z',
|
|
23
|
+
html_url: 'http://github.com/fs/test',
|
|
24
|
+
private: true
|
|
25
|
+
))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'parse created_at' do
|
|
29
|
+
expect(repository.last_updated_at).to be_a_kind_of(DateTime)
|
|
30
|
+
expect(repository.last_updated_at).to eq(DateTime.parse('2011-01-26T19:06:43Z'))
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'url' do
|
|
36
|
+
expect(repository.url).to eq('http://github.com/fs/test')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'private?' do
|
|
40
|
+
expect(repository).to be_private
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'expired?' do
|
|
44
|
+
Expirer::Checker.should_receive(:expired?).with(repository) { true }
|
|
45
|
+
expect(repository).to be_expired
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Expirer do
|
|
4
|
+
describe '.configuration' do
|
|
5
|
+
subject(:config) { Expirer.configuration }
|
|
6
|
+
|
|
7
|
+
it 'instance of Config' do
|
|
8
|
+
expect(config).to be_an_instance_of(Expirer::Config)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'have options' do
|
|
12
|
+
expect(config.private_only).to eq(true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'with config file' do
|
|
16
|
+
before do
|
|
17
|
+
config.load_from_file!('spec/fixtures/config.yml')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'load config file' do
|
|
21
|
+
expect(config.private_only).to eq(false)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'reset defaults' do
|
|
25
|
+
expect { config.reset! }.to change { config.private_only }.from(false).to(true)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context 'with command line options' do
|
|
30
|
+
before do
|
|
31
|
+
config.load_from_options!({
|
|
32
|
+
'private-only' => false
|
|
33
|
+
})
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'load options' do
|
|
37
|
+
expect(config.private_only).to eq(false)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: github-expirer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease:
|
|
5
|
+
version: 0.0.1
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Timur Vafin
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: activesupport
|
|
16
|
+
type: :runtime
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
none: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ! '>='
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '0'
|
|
28
|
+
none: false
|
|
29
|
+
prerelease: false
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: github_api
|
|
32
|
+
type: :runtime
|
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
none: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ! '>='
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
none: false
|
|
45
|
+
prerelease: false
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: chronic
|
|
48
|
+
type: :runtime
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
none: false
|
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ! '>='
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
none: false
|
|
61
|
+
prerelease: false
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: ansi
|
|
64
|
+
type: :runtime
|
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
none: false
|
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ! '>='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
none: false
|
|
77
|
+
prerelease: false
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: thor
|
|
80
|
+
type: :runtime
|
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ! '>='
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
none: false
|
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ! '>='
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
none: false
|
|
93
|
+
prerelease: false
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: bundler
|
|
96
|
+
type: :development
|
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ~>
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '1.3'
|
|
102
|
+
none: false
|
|
103
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
104
|
+
requirements:
|
|
105
|
+
- - ~>
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '1.3'
|
|
108
|
+
none: false
|
|
109
|
+
prerelease: false
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: rake
|
|
112
|
+
type: :development
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ! '>='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
none: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ! '>='
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
none: false
|
|
125
|
+
prerelease: false
|
|
126
|
+
- !ruby/object:Gem::Dependency
|
|
127
|
+
name: rspec
|
|
128
|
+
type: :development
|
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
|
130
|
+
requirements:
|
|
131
|
+
- - ! '>='
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: '0'
|
|
134
|
+
none: false
|
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ! '>='
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '0'
|
|
140
|
+
none: false
|
|
141
|
+
prerelease: false
|
|
142
|
+
- !ruby/object:Gem::Dependency
|
|
143
|
+
name: timecop
|
|
144
|
+
type: :development
|
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
|
146
|
+
requirements:
|
|
147
|
+
- - ! '>='
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
version: '0'
|
|
150
|
+
none: false
|
|
151
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
152
|
+
requirements:
|
|
153
|
+
- - ! '>='
|
|
154
|
+
- !ruby/object:Gem::Version
|
|
155
|
+
version: '0'
|
|
156
|
+
none: false
|
|
157
|
+
prerelease: false
|
|
158
|
+
description: A quick hack to produce a list of not used repositories at Github.
|
|
159
|
+
email:
|
|
160
|
+
- timur.vafin@flatstack.com
|
|
161
|
+
executables:
|
|
162
|
+
- github-expirer
|
|
163
|
+
extensions: []
|
|
164
|
+
extra_rdoc_files: []
|
|
165
|
+
files:
|
|
166
|
+
- .gitignore
|
|
167
|
+
- .rspec
|
|
168
|
+
- Gemfile
|
|
169
|
+
- LICENSE.txt
|
|
170
|
+
- README.md
|
|
171
|
+
- Rakefile
|
|
172
|
+
- bin/github-expirer
|
|
173
|
+
- github-expirer.gemspec
|
|
174
|
+
- lib/expirer.rb
|
|
175
|
+
- lib/expirer/checker.rb
|
|
176
|
+
- lib/expirer/cli.rb
|
|
177
|
+
- lib/expirer/config.rb
|
|
178
|
+
- lib/expirer/core_ext/string/underscore_keys.rb
|
|
179
|
+
- lib/expirer/list.rb
|
|
180
|
+
- lib/expirer/reporter.rb
|
|
181
|
+
- lib/expirer/repository.rb
|
|
182
|
+
- lib/expirer/version.rb
|
|
183
|
+
- spec/expirer/checker_spec.rb
|
|
184
|
+
- spec/expirer/config_spec.rb
|
|
185
|
+
- spec/expirer/list_spec.rb
|
|
186
|
+
- spec/expirer/reporter_spec.rb
|
|
187
|
+
- spec/expirer/repository_spec.rb
|
|
188
|
+
- spec/expirer_spec.rb
|
|
189
|
+
- spec/fixtures/config.yml
|
|
190
|
+
- spec/spec_helper.rb
|
|
191
|
+
homepage: ''
|
|
192
|
+
licenses:
|
|
193
|
+
- MIT
|
|
194
|
+
post_install_message:
|
|
195
|
+
rdoc_options: []
|
|
196
|
+
require_paths:
|
|
197
|
+
- lib
|
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
|
+
requirements:
|
|
200
|
+
- - ! '>='
|
|
201
|
+
- !ruby/object:Gem::Version
|
|
202
|
+
segments:
|
|
203
|
+
- 0
|
|
204
|
+
hash: -51980655465764419
|
|
205
|
+
version: '0'
|
|
206
|
+
none: false
|
|
207
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
|
+
requirements:
|
|
209
|
+
- - ! '>='
|
|
210
|
+
- !ruby/object:Gem::Version
|
|
211
|
+
segments:
|
|
212
|
+
- 0
|
|
213
|
+
hash: -51980655465764419
|
|
214
|
+
version: '0'
|
|
215
|
+
none: false
|
|
216
|
+
requirements: []
|
|
217
|
+
rubyforge_project:
|
|
218
|
+
rubygems_version: 1.8.23
|
|
219
|
+
signing_key:
|
|
220
|
+
specification_version: 3
|
|
221
|
+
summary: A quick hack to produce a list of not used repositories at Github.
|
|
222
|
+
test_files:
|
|
223
|
+
- spec/expirer/checker_spec.rb
|
|
224
|
+
- spec/expirer/config_spec.rb
|
|
225
|
+
- spec/expirer/list_spec.rb
|
|
226
|
+
- spec/expirer/reporter_spec.rb
|
|
227
|
+
- spec/expirer/repository_spec.rb
|
|
228
|
+
- spec/expirer_spec.rb
|
|
229
|
+
- spec/fixtures/config.yml
|
|
230
|
+
- spec/spec_helper.rb
|