gem-maintenance 0.1.0
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 +17 -0
- data/Gemfile +4 -0
- data/Rakefile +21 -0
- data/gem-maintenance.gemspec +13 -0
- data/lib/rubygems/commands/cleanstale_command.rb +36 -0
- data/lib/rubygems_plugin.rb +4 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems' unless defined?(Gem)
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
%w(install release).each do |task|
|
6
|
+
Rake::Task[task].enhance do
|
7
|
+
sh "rm -rf pkg"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Bump version on github'
|
12
|
+
task :bump do
|
13
|
+
if `git status -s`.strip == ''
|
14
|
+
puts "\e[31mNothing to commit (working directory clean)\e[0m"
|
15
|
+
else
|
16
|
+
version = Bundler.load_gemspec(Dir[File.expand_path('../*.gemspec', __FILE__)].first).version
|
17
|
+
sh "git add .; git commit -a -m \"Bump to version #{version}\""
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
task :release => :bump
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.authors = ["Davide D'Agostino"]
|
4
|
+
gem.email = ["d.dagostino@lipsiasoft.com"]
|
5
|
+
gem.description = "Maintenance tasks for your rubygems"
|
6
|
+
gem.summary = "Maintenance tasks for your rubygems"
|
7
|
+
gem.homepage = ""
|
8
|
+
|
9
|
+
gem.files = `git ls-files`.split("\n")
|
10
|
+
gem.name = "gem-maintenance"
|
11
|
+
gem.require_paths = ["lib"]
|
12
|
+
gem.version = '0.1.0'
|
13
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
|
3
|
+
class Gem::Commands::CleanstaleCommand < Gem::Command
|
4
|
+
def initialize
|
5
|
+
super('cleanstale', 'Remove gems without a given access time')
|
6
|
+
end
|
7
|
+
|
8
|
+
def arguments
|
9
|
+
"DAYS number of days to check, default 30"
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage # :nodoc:
|
13
|
+
"#{program_name} [DAYS]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
days = get_one_optional_argument || '30'
|
18
|
+
say "Querying for gems without access from #{days} days..."
|
19
|
+
gem_to_atime = {}
|
20
|
+
Gem::Specification.each do |spec|
|
21
|
+
key = { :name => spec.name, :version => spec.version }
|
22
|
+
Dir["#{spec.full_gem_path}/**/*.*"].each do |file|
|
23
|
+
next if File.directory?(file)
|
24
|
+
stat = File.stat(file)
|
25
|
+
gem_to_atime[key] ||= stat.atime
|
26
|
+
gem_to_atime[key] = stat.atime if gem_to_atime[key] < stat.atime
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
gem_to_atime.sort_by { |_, atime| atime }.each do |spec, atime|
|
31
|
+
break unless (Time.now.to_i-atime.to_i) > 3600 * 24 * days.to_i
|
32
|
+
say "#{spec[:name]} #{spec[:version]} last access was on #{atime.strftime '%d/%m/%Y at %H:%M'}"
|
33
|
+
system "gem uninstall #{spec[:name]} #{spec[:version]}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gem-maintenance
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Davide D'Agostino
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-01-23 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Maintenance tasks for your rubygems
|
22
|
+
email:
|
23
|
+
- d.dagostino@lipsiasoft.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- Rakefile
|
34
|
+
- gem-maintenance.gemspec
|
35
|
+
- lib/rubygems/commands/cleanstale_command.rb
|
36
|
+
- lib/rubygems_plugin.rb
|
37
|
+
homepage: ""
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.15
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Maintenance tasks for your rubygems
|
70
|
+
test_files: []
|
71
|
+
|