Class Gem::Commands::EnvironmentCommand
In: lib/rubygems/commands/environment_command.rb
Parent: Gem::Command

Methods

execute   new  

Public Class methods

[Source]

   # File lib/rubygems/commands/environment_command.rb, line 5
5:   def initialize
6:     super 'environment', 'Display information about the RubyGems environment'
7:   end

Public Instance methods

[Source]

     # File lib/rubygems/commands/environment_command.rb, line 66
 66:   def execute
 67:     out = ''
 68:     arg = options[:args][0]
 69:     case arg
 70:     when /^packageversion/ then
 71:       out << Gem::RubyGemsPackageVersion
 72:     when /^version/ then
 73:       out << Gem::VERSION
 74:     when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
 75:       out << Gem.dir
 76:     when /^gempath/, /^path/, /^GEM_PATH/ then
 77:       out << Gem.path.join(File::PATH_SEPARATOR)
 78:     when /^remotesources/ then
 79:       out << Gem.sources.join("\n")
 80:     when /^platform/ then
 81:       out << Gem.platforms.join(File::PATH_SEPARATOR)
 82:     when nil then
 83:       out = "RubyGems Environment:\n"
 84: 
 85:       out << "  - RUBYGEMS VERSION: #{Gem::VERSION}\n"
 86: 
 87:       out << "  - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
 88:       out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
 89:       out << ") [#{RUBY_PLATFORM}]\n"
 90: 
 91:       out << "  - INSTALLATION DIRECTORY: #{Gem.dir}\n"
 92: 
 93:       out << "  - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
 94: 
 95:       out << "  - RUBY EXECUTABLE: #{Gem.ruby}\n"
 96: 
 97:       out << "  - EXECUTABLE DIRECTORY: #{Gem.bindir}\n"
 98: 
 99:       out << "  - RUBYGEMS PLATFORMS:\n"
100:       Gem.platforms.each do |platform|
101:         out << "    - #{platform}\n"
102:       end
103: 
104:       out << "  - GEM PATHS:\n"
105:       out << "     - #{Gem.dir}\n"
106: 
107:       path = Gem.path.dup
108:       path.delete Gem.dir
109:       path.each do |p|
110:         out << "     - #{p}\n"
111:       end
112: 
113:       out << "  - GEM CONFIGURATION:\n"
114:       Gem.configuration.each do |name, value|
115:         value = value.gsub(/./, '*') if name == 'gemcutter_key'
116:         out << "     - #{name.inspect} => #{value.inspect}\n"
117:       end
118: 
119:       out << "  - REMOTE SOURCES:\n"
120:       Gem.sources.each do |s|
121:         out << "     - #{s}\n"
122:       end
123: 
124:     else
125:       raise Gem::CommandLineError, "Unknown environment option [#{arg}]"
126:     end
127:     say out
128:     true
129:   end

[Validate]