/tools/Ruby/lib/ruby/site_ruby/1.8/rubygems/errors.rb

http://github.com/agross/netopenspace · Ruby · 35 lines · 22 code · 7 blank · 6 comment · 2 complexity · 0e60678c90200e0eea2a650afc9494c2 MD5 · raw file

  1. class Gem::ErrorReason; end
  2. # Generated when trying to lookup a gem to indicate that the gem
  3. # was found, but that it isn't usable on the current platform.
  4. #
  5. # fetch and install read these and report them to the user to aid
  6. # in figuring out why a gem couldn't be installed.
  7. #
  8. class Gem::PlatformMismatch < Gem::ErrorReason
  9. attr_reader :name
  10. attr_reader :version
  11. attr_reader :platforms
  12. def initialize(name, version)
  13. @name = name
  14. @version = version
  15. @platforms = []
  16. end
  17. def add_platform(platform)
  18. @platforms << platform
  19. end
  20. def wordy
  21. prefix = "Found #{@name} (#{@version})"
  22. if @platforms.size == 1
  23. "#{prefix}, but was for platform #{@platforms[0]}"
  24. else
  25. "#{prefix}, but was for platforms #{@platforms.join(' ,')}"
  26. end
  27. end
  28. end