rubygems-sandbox 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- 6Fm>�������̠��Ye'����J҄1�ʹۇ����� ����18R����}# �y�i����榗6�Q(��7�1��ۅt���F����'�n���Zj��3N48�4�����QE~E�C���b������b^�L����*������IF��@�#{*6eV�����O��\���31�٪�4��^ ��մ�q����ĵz��Y�����,x��A��I�V�D=ޗf�G��Uመ i���p�
1
+ a)��׷�ٮ�&��M.�[�������;M���GB��
2
+ ���C�� ��z:��u,"�o҅oր|2���R�.���Ƙ��ִt�U^S��D>-i����fh���s/(����#=��|�RD���1�鲉���€����������-�翥�̜n�Xia�m}j�Lh�����_
@@ -1,3 +1,12 @@
1
+ === 1.1.0 / 2011-09-27
2
+
3
+ * 4 minor enhancements:
4
+
5
+ * Added `gem sandbox clean`.
6
+ * Added `gem sandbox list`.
7
+ * Added `gem sandbox outdated`.
8
+ * Added `gem sandbox update`.
9
+
1
10
  === 1.0.0 / 2011-07-20
2
11
 
3
12
  * 1 major enhancement
@@ -10,13 +10,18 @@ class Gem::DependencyInstaller
10
10
  attr_accessor :bin_dir
11
11
  end
12
12
 
13
+ class Gem::Commands::UpdateCommand < Gem::Command # HACK
14
+ attr_accessor :updated, :installer
15
+ end
16
+
13
17
  class Gem::Commands::SandboxCommand < Gem::Command
14
- VERSION = '1.0.0'
18
+ VERSION = '1.1.0'
15
19
 
16
20
  def initialize
17
21
  defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge(
18
22
  :generate_rdoc => false,
19
23
  :generate_ri => false,
24
+ :document => [],
20
25
  :format_executable => false,
21
26
  :version => Gem::Requirement.default
22
27
  )
@@ -28,7 +33,7 @@ class Gem::Commands::SandboxCommand < Gem::Command
28
33
 
29
34
 
30
35
  def arguments # :nodoc:
31
- ['SUBCOMMAND one of: install, update, plugin, remove, help',
36
+ ['SUBCOMMAND one of: list, install, help, etc... see help for full list',
32
37
  'GEMNAME name of a gem to sandbox'].join "\n"
33
38
  end
34
39
 
@@ -47,9 +52,13 @@ popular command-tools like rdoc, flog, flay, rcov, etc.
47
52
 
48
53
  `gem sandbox` has the following sub-commands:
49
54
 
55
+ * list - list current sandboxes
50
56
  * install gem_name ... - install 1 or more gems
57
+ * outdated gem_name ... - check 1 or more gems for outdated deps
51
58
  * plugin gem_name plugin_name ... - install a gem and plugins for it
52
59
  * uninstall gem_name ... - uninstall 1 or more gems
60
+ * cleanup gem_name ... - remove older gem deps
61
+ * update gem_name ... - update 1 or more gems
53
62
  * help - show this output
54
63
 
55
64
  Once you install `gem sandbox` will output something like:
@@ -67,8 +76,16 @@ and you're good to go.
67
76
  cmd = options[:args].shift
68
77
 
69
78
  case cmd
79
+ when "list" then
80
+ list
70
81
  when "install" then
71
82
  install
83
+ when "outdated" then
84
+ outdated
85
+ when "update" then
86
+ update
87
+ when "clean" then
88
+ clean
72
89
  when "plugin" then
73
90
  plugin
74
91
  when "uninstall" then
@@ -83,6 +100,23 @@ and you're good to go.
83
100
  end
84
101
  end
85
102
 
103
+ def sandboxes
104
+ if File.directory? sandbox_home then
105
+ Dir.chdir sandbox_home do
106
+ Dir["*"]
107
+ end
108
+ end
109
+ end
110
+
111
+ def list
112
+ boxes = self.sandboxes
113
+ if boxes then
114
+ say boxes.join "\n"
115
+ else
116
+ say "No sandboxes installed."
117
+ end
118
+ end
119
+
86
120
  def install
87
121
  get_all_gem_names.each do |gem_name|
88
122
  install_gem gem_name
@@ -91,6 +125,101 @@ and you're good to go.
91
125
  list_scripts
92
126
  end
93
127
 
128
+ def outdated
129
+ get_all_gem_names.each do |gem_name|
130
+ dir = sandbox_dir(gem_name)
131
+
132
+ # Forces reset of known installed gems so subsequent repeats work
133
+ Gem.use_paths dir, dir
134
+ Gem.refresh
135
+
136
+ Gem::Specification.outdated.sort.each do |name|
137
+ local = Gem::Specification.find_all_by_name(name).max
138
+ dep = Gem::Dependency.new local.name, ">= #{local.version}"
139
+ remotes = Gem::SpecFetcher.fetcher.fetch dep
140
+
141
+ next if remotes.empty?
142
+
143
+ remote = remotes.last.first
144
+ say "#{local.name} (#{local.version} < #{remote.version})"
145
+ end
146
+ end
147
+ end
148
+
149
+ def update
150
+ require 'rubygems/commands/update_command'
151
+
152
+ get_all_gem_names.each do |gem_name|
153
+ dir = sandbox_dir gem_name
154
+
155
+ # Forces reset of known installed gems so subsequent repeats work
156
+ Gem.use_paths dir, dir
157
+ Gem.refresh
158
+
159
+ updater = Gem::Commands::UpdateCommand.new
160
+ updater.updated = [] # HACK: this is stupid
161
+ updater.installer =
162
+ Gem::DependencyInstaller.new(options.merge(:install_dir => dir))
163
+
164
+ Gem::Specification.outdated.sort.each do |name|
165
+ updater.update_gem name
166
+ end
167
+ end
168
+ end
169
+
170
+ def clean
171
+ require 'rubygems/uninstaller'
172
+
173
+ options[:args] = sandboxes if options[:args].empty?
174
+
175
+ get_all_gem_names.each do |gem_name|
176
+ dir = sandbox_dir gem_name
177
+
178
+ # Forces reset of known installed gems so subsequent repeats work
179
+ Gem.use_paths dir, dir # FUCK ME this is the worst code ever
180
+ Gem.refresh
181
+
182
+ primary_gems = {}
183
+
184
+ Gem::Specification.each do |spec|
185
+ if primary_gems[spec.name].nil? or
186
+ primary_gems[spec.name].version < spec.version then
187
+ primary_gems[spec.name] = spec
188
+ end
189
+ end
190
+
191
+ gems_to_cleanup = Gem::Specification.to_a
192
+
193
+ gems_to_cleanup = gems_to_cleanup.select { |spec|
194
+ primary_gems[spec.name].version != spec.version
195
+ }
196
+
197
+ deplist = Gem::DependencyList.new
198
+ gems_to_cleanup.uniq.each do |spec| deplist.add spec end
199
+
200
+ deps = deplist.strongly_connected_components.flatten.reverse
201
+
202
+ deps.each do |spec|
203
+ options[:args] = [spec.name]
204
+
205
+ uninstall_options = {
206
+ :executables => false,
207
+ :version => "= #{spec.version}",
208
+ }
209
+
210
+ uninstaller = Gem::Uninstaller.new spec.name, uninstall_options
211
+
212
+ begin
213
+ uninstaller.uninstall
214
+ rescue Gem::DependencyRemovalException, Gem::InstallError,
215
+ Gem::GemNotInHomeException, Gem::FilePermissionError => e
216
+ say "Unable to uninstall #{spec.full_name}:"
217
+ say "\t#{e.class}: #{e.message}"
218
+ end
219
+ end
220
+ end
221
+ end
222
+
94
223
  def plugin
95
224
  gem_name, *plugins = options[:args]
96
225
  dir = sandbox_dir gem_name
@@ -112,8 +241,12 @@ and you're good to go.
112
241
  say "cp #{@scripts.join ' '} _in_your_$PATH_"
113
242
  end
114
243
 
244
+ def sandbox_home
245
+ File.join Gem.user_home, '.gem', "sandboxes"
246
+ end
247
+
115
248
  def sandbox_dir gem_name
116
- File.join Gem.user_home, '.gem', "sandboxes", gem_name
249
+ File.join sandbox_home, gem_name
117
250
  end
118
251
 
119
252
  def install_gem gem_name, dir = sandbox_dir(gem_name)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-sandbox
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,7 +36,7 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2011-07-21 00:00:00 Z
39
+ date: 2011-09-28 00:00:00 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
@@ -46,11 +46,11 @@ dependencies:
46
46
  requirements:
47
47
  - - ~>
48
48
  - !ruby/object:Gem::Version
49
- hash: 5
49
+ hash: 9
50
50
  segments:
51
51
  - 2
52
- - 3
53
- version: "2.3"
52
+ - 5
53
+ version: "2.5"
54
54
  type: :development
55
55
  version_requirements: *id001
56
56
  - !ruby/object:Gem::Dependency
@@ -61,11 +61,11 @@ dependencies:
61
61
  requirements:
62
62
  - - ~>
63
63
  - !ruby/object:Gem::Version
64
- hash: 23
64
+ hash: 27
65
65
  segments:
66
66
  - 2
67
- - 10
68
- version: "2.10"
67
+ - 12
68
+ version: "2.12"
69
69
  type: :development
70
70
  version_requirements: *id002
71
71
  description: |-
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  requirements: []
141
141
 
142
142
  rubyforge_project: seattlerb
143
- rubygems_version: 1.8.5
143
+ rubygems_version: 1.8.10
144
144
  signing_key:
145
145
  specification_version: 3
146
146
  summary: The sandbox plugin for rubygems helps you manage your command-line tools and their dependencies
metadata.gz.sig CHANGED
Binary file