remove_stale_gems 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/LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +28 -0
- data/VERSION +1 -0
- data/lib/remove_stale_gems.rb +2 -0
- data/lib/rubygems/commands/remove_stale_command.rb +53 -0
- data/lib/rubygems_plugin.rb +3 -0
- data/remove_stale_gems.gemspec +42 -0
- metadata +75 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Boba Fat
|
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
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
|
4
|
+
name = 'remove_stale_gems'
|
5
|
+
summary = 'Remove unused gems'
|
6
|
+
description = 'Remove gems for which last use time is too old'
|
7
|
+
|
8
|
+
jewel = Jeweler::Tasks.new do |j|
|
9
|
+
j.name = name
|
10
|
+
j.summary = summary
|
11
|
+
j.description = description
|
12
|
+
j.authors = ["Boba Fat"]
|
13
|
+
end
|
14
|
+
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
|
17
|
+
require 'pathname'
|
18
|
+
desc "Replace system gem with symlink to this folder"
|
19
|
+
task 'ghost' do
|
20
|
+
gem_path = Pathname(Gem.searcher.find(name).full_gem_path)
|
21
|
+
current_path = Pathname('.').expand_path
|
22
|
+
system('rm', '-r', gem_path)
|
23
|
+
system('ln', '-s', current_path, gem_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
rescue LoadError
|
27
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
28
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems/uninstaller'
|
2
|
+
|
3
|
+
class Gem::Commands::RemoveStaleCommand < Gem::Command
|
4
|
+
def initialize
|
5
|
+
super 'remove_stale', 'Remove gems for which last use time is too old'
|
6
|
+
end
|
7
|
+
|
8
|
+
def abandoned?(spec, border_time)
|
9
|
+
atime = nil
|
10
|
+
Dir["#{spec.full_gem_path}/**/*.*"].each do |file|
|
11
|
+
next if File.directory?(file)
|
12
|
+
stat = File.stat(file)
|
13
|
+
atime = stat.atime if !atime || atime < stat.atime
|
14
|
+
end
|
15
|
+
atime && atime < border_time
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
border_time = Time.now - 40 * (24 * 60 * 60)
|
20
|
+
|
21
|
+
abandoned_gems = []
|
22
|
+
Gem.source_index.each do |name, spec|
|
23
|
+
if abandoned?(spec, border_time)
|
24
|
+
abandoned_gems << spec
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
to_uninstall = abandoned_gems.select do |spec|
|
29
|
+
spec.dependent_gems.all? do |dependent, depency, satlist|
|
30
|
+
abandoned_gems.include?(dependent) || (satlist - abandoned_gems).length > 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
to_uninstall.each do |spec|
|
35
|
+
say "Attempting to uninstall #{spec.full_name}"
|
36
|
+
|
37
|
+
uninstall_options = {
|
38
|
+
:executables => (Gem.source_index.find_name(spec.name) - to_uninstall).length == 0,
|
39
|
+
:version => "= #{spec.version}",
|
40
|
+
:ignore => true
|
41
|
+
}
|
42
|
+
uninstaller = Gem::Uninstaller.new spec.name, uninstall_options
|
43
|
+
|
44
|
+
begin
|
45
|
+
uninstaller.uninstall
|
46
|
+
rescue Gem::DependencyRemovalException, Gem::InstallError,
|
47
|
+
Gem::GemNotInHomeException => e
|
48
|
+
say "Unable to uninstall #{spec.full_name}:"
|
49
|
+
say "\t#{e.class}: #{e.message}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{remove_stale_gems}
|
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 = ["Boba Fat"]
|
12
|
+
s.date = %q{2010-12-04}
|
13
|
+
s.description = %q{Remove gems for which last use time is too old}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"lib/remove_stale_gems.rb",
|
24
|
+
"lib/rubygems/commands/remove_stale_command.rb",
|
25
|
+
"lib/rubygems_plugin.rb",
|
26
|
+
"remove_stale_gems.gemspec"
|
27
|
+
]
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
s.rubygems_version = %q{1.3.7}
|
30
|
+
s.summary = %q{Remove unused gems}
|
31
|
+
|
32
|
+
if s.respond_to? :specification_version then
|
33
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
34
|
+
s.specification_version = 3
|
35
|
+
|
36
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
37
|
+
else
|
38
|
+
end
|
39
|
+
else
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: remove_stale_gems
|
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
|
+
- Boba Fat
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-04 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Remove gems for which last use time is too old
|
23
|
+
email:
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- LICENSE
|
30
|
+
- README.rdoc
|
31
|
+
files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
- Rakefile
|
35
|
+
- VERSION
|
36
|
+
- lib/remove_stale_gems.rb
|
37
|
+
- lib/rubygems/commands/remove_stale_command.rb
|
38
|
+
- lib/rubygems_plugin.rb
|
39
|
+
- remove_stale_gems.gemspec
|
40
|
+
has_rdoc: true
|
41
|
+
homepage:
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.3.7
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Remove unused gems
|
74
|
+
test_files: []
|
75
|
+
|