gem-maintenance 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gem-maintenance.gemspec
4
+ gemspec
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
@@ -0,0 +1,4 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :cleanstale
4
+ Gem::CommandManager.instance.register_command :fix
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
+