gem-depclean 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/commands/world_command.rb +23 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -3,6 +3,15 @@ require 'rubygems/requirement'
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
class Gem::Commands::WorldCommand < Gem::Command
|
6
|
+
Gem.post_install do |installer|
|
7
|
+
command = Gem::CommandManager.instance['install']
|
8
|
+
name = installer.spec.name
|
9
|
+
|
10
|
+
if command.get_all_gem_names.include?(name)
|
11
|
+
new.add name, command.options[:version]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
6
15
|
def initialize
|
7
16
|
super 'world', 'Display gems that in your world'
|
8
17
|
|
@@ -19,6 +28,18 @@ class Gem::Commands::WorldCommand < Gem::Command
|
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
31
|
+
def add(name, version)
|
32
|
+
open(world_path, 'r+') do |f|
|
33
|
+
f << YAML.load(f).tap {|world|
|
34
|
+
(world[name] ||= []).tap {|vs|
|
35
|
+
vs << version.to_s
|
36
|
+
}.uniq!
|
37
|
+
|
38
|
+
f.rewind
|
39
|
+
}.to_yaml
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
22
43
|
def world_path
|
23
44
|
File.join(Gem.user_dir, 'world')
|
24
45
|
end
|
@@ -27,7 +48,7 @@ class Gem::Commands::WorldCommand < Gem::Command
|
|
27
48
|
YAML.load_file(world_path).inject([]) {|acc, (name, versions)|
|
28
49
|
acc + versions.map {|v|
|
29
50
|
Gem.source_index.find_name(name, v).sort_by(&:version).last
|
30
|
-
}
|
51
|
+
}.compact
|
31
52
|
}
|
32
53
|
end
|
33
54
|
|
@@ -41,7 +62,7 @@ class Gem::Commands::WorldCommand < Gem::Command
|
|
41
62
|
open(world_path, 'w') do |f|
|
42
63
|
f << Gem.source_index.map(&:last).select {|spec|
|
43
64
|
spec.dependent_gems.empty?
|
44
|
-
}.group_by(&:name).
|
65
|
+
}.group_by(&:name).inject({}) {|h, (name, specs)|
|
45
66
|
versions = specs.sort_by(&:version).map {|spec| spec.version }
|
46
67
|
versions[-1] = Gem::Requirement.default
|
47
68
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-depclean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keita Urashima
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-14 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|