GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: a tiny graphical app kit for ruby
Homepage: http://code.whytheluckystiff.net/shoes
Clone URL: git://github.com/why/shoes.git
 * lib/shoes/cache.rb: the shoes face for rubygems.
why (author)
Tue Mar 11 21:46:15 -0700 2008
commit  0985185e1ca0b11a26859014739477a7e67be186
tree    76918b2b4dba446fb5bdd5a5ade0a16e33bc36a1
parent  5cf5a33cf7b459cc34a2d1f0d38170b82bdadcc9
...
28
29
30
31
 
32
33
34
...
41
42
43
44
45
46
47
48
49
50
51
52
...
68
69
70
71
72
73
 
 
 
 
74
75
76
77
 
 
 
 
 
 
 
 
 
 
 
 
 
78
79
80
 
81
82
83
84
85
...
197
198
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
201
202
...
28
29
30
 
31
32
33
34
...
41
42
43
 
 
 
 
 
 
44
45
46
...
62
63
64
 
 
 
65
66
67
68
69
 
 
 
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
 
84
85
 
86
87
88
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
0
@@ -28,7 +28,7 @@ Config::CONFIG['libdir'] = GEM_DIR
0
 Config::CONFIG['sitelibdir'] = SITE_LIB_DIR
0
 
0
 require 'rubygems'
0
-require 'rubygems/installer'
0
+require 'rubygems/dependency_installer'
0
 class << Gem::Ext::ExtConfBuilder
0
   alias_method :make__, :make
0
   def self.make(dest_path, results)
0
@@ -41,12 +41,6 @@ class << Gem::Ext::ExtConfBuilder
0
     make__(dest_path, results)
0
   end
0
 end
0
-class Gem::Installer
0
- alias_method :install__, :install
0
- def install(*a)
0
- install__
0
- end
0
-end
0
 
0
 # STDIN.reopen("/dev/tty") if STDIN.eof?
0
 class NotSupportedByShoes < Exception; end
0
@@ -68,18 +62,27 @@ def libdir(path)
0
   puts "** Adding #{path} to the $LOAD_PATH..."
0
   $:.unshift path
0
 end
0
-def fetch_gem(name, version = nil, &blk)
0
- if Gem.source_index.find_name(name, version).empty?
0
- puts "** Fetching #{name} #{version}"
0
+def fetch_gems(gems, &blk)
0
+ ui = Gem::DefaultUserInteraction.ui
0
+ count, total = 0, gems.length
0
+ ui.progress count, total
0
 
0
- installer = Gem::Installer.new(:include_dependencies => true)
0
- installer.install(name, version || Gem::Requirement.default, true)
0
- gem_reset
0
+ gems.each do |name, version|
0
+ count += 1
0
+ ui.say "Looking for #{name}"
0
+ if Gem.source_index.find_name(name, version).empty?
0
+ ui.title "Installing #{name}"
0
+ installer = Gem::DependencyInstaller.new
0
+ installer.install(name, version || Gem::Requirement.default)
0
+ gem_reset
0
+ end
0
+ gem = Gem.source_index.find_name(name, version).first
0
+ Gem.activate(gem.name, true, "= #{gem.version}")
0
+ ui.say "Finished installing #{name}"
0
+ ui.progress count, total
0
   end
0
- gem = Gem.source_index.find_name(name, version).first
0
- Gem.activate(gem.name, true, "= #{gem.version}")
0
+
0
   if blk
0
- puts "** Entering #{gem.full_gem_path}..."
0
     Dir.chdir(gem.full_gem_path, &blk)
0
   end
0
 end
0
@@ -197,6 +200,58 @@ def install_sources
0
   Gem::Installer.new(sources_gem).install()
0
 end
0
 
0
+class Gem::ShoesFace
0
+ class ProgressReporter
0
+ attr_reader :count
0
+
0
+ def initialize(prog, size, initial_message,
0
+ terminal_message = "complete")
0
+ @prog = prog
0
+ @total = size
0
+ @count = 0.0
0
+ end
0
+
0
+ def updated(message)
0
+ @count += 1.0
0
+ @prog.fraction = @count / @total.to_f
0
+ end
0
+
0
+ def done
0
+ end
0
+ end
0
+
0
+ def initialize app
0
+ @title, @status, @prog, = app.contents[-1].contents
0
+ end
0
+ def title msg
0
+ @title.replace msg
0
+ end
0
+ def progress count, total
0
+ @prog.fraction = count.to_f / total.to_f
0
+ end
0
+ def ask_yes_no msg
0
+ Kernel.confirm(msg)
0
+ end
0
+ def ask msg
0
+ Kernel.ask(msg)
0
+ end
0
+ def say msg
0
+ @status.replace msg
0
+ end
0
+ def alert msg, quiz=nil
0
+ say(msg)
0
+ ask(quiz) if quiz
0
+ end
0
+ def progress_reporter(*args)
0
+ SilentProgressReporter.new(nil, *args)
0
+ # ProgressReporter.new(@prog, *args)
0
+ end
0
+ def method_missing(*args)
0
+ p args
0
+ nil
0
+ end
0
+end
0
+
0
 $stderr = StringIO.new
0
 Gem.manage_gems
0
 class << Gem; attr_accessor :loaded_specs end

Comments

    No one has commented yet.