Top Level Namespace

Defined Under Namespace

Modules: MySpace

Constant Summary collapse

REQUIRED =

External libs

{ 
  "oauth"     => "http://oauth.googlecode.com/svn/code/ruby/",
  # http://rubyforge.org/frs/download.php/22501/json-1.1.1-mswin32.gem
  "json/pure" => "http://json.rubyforge.org/",
}

Instance Method Summary collapse

Instance Method Details

#remote_install(load_failures) ⇒ Object

Try to remotely install libs based on our load failures



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/myspace/loader.rb', line 26

def remote_install(load_failures)
  puts "
We couldn't load all modules required for the MySpace API. You appear to need:"
  puts 
  load_failures.each {|lib| puts "'#{lib.gsub(/\/.*$/,'')}' (#{REQUIRED[lib]})" }
  print "
If you like, we can try to fetch what you need from the Internet, and install it.

Do you want to try and install from the net? [Y/n]: "
   answer = $stdin.getc.chr
   if answer.downcase == "y" || answer.chomp.empty?
     begin 
       require 'rubygems/remote_installer'
       installer = Gem::RemoteInstaller.new
       installed_gems = []
       load_failures.each {|lib|
         lib.gsub!(/\/.*$/,'')
         installed_gems << installer.install(lib,">0",false,$LOAD_PATH[0])
       }

       if installed_gems.compact.length == load_failures.compact.length
         installed_gems.compact.each {|spec| puts "installed #{spec.full_name}" }
       else
         remote_install_failed(load_failures)
       end
     rescue Exception => e
       remote_install_failed(load_failures)
     end
  else
    puts "
Ok, but you need to get the required libraries before you can continue.

Go to http://developer.myspace.com for more information or updates.
"
  end
end

#remote_install_failed(load_failures) ⇒ Object

Hard exit and describe what libraries failed



19
20
21
22
23
# File 'lib/myspace/loader.rb', line 19

def remote_install_failed(load_failures)
  puts "Installation failed, try to install the following modules manually:\n"
  load_failures.each {|lib| puts "'#{lib}' ('#{REQUIRED[lib]}')" }
  exit(1)
end