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 26
26:   def execute
27:     out = ''
28:     arg = options[:args][0]
29:     case arg
30:     when /^packageversion/ then
31:       out << Gem::RubyGemsPackageVersion
32:     when /^version/ then
33:       out << Gem::RubyGemsVersion
34:     when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
35:       out << Gem.dir
36:     when /^gempath/, /^path/, /^GEM_PATH/ then
37:       out << Gem.path.join(File::PATH_SEPARATOR)
38:     when /^remotesources/ then
39:       out << Gem.sources.join("\n")
40:     when nil then
41:       out = "RubyGems Environment:\n"
42: 
43:       out << "  - RUBYGEMS VERSION: #{Gem::RubyGemsVersion}\n"
44: 
45:       out << "  - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
46:       out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
47:       out << ") [#{RUBY_PLATFORM}]\n"
48: 
49:       out << "  - INSTALLATION DIRECTORY: #{Gem.dir}\n"
50: 
51:       out << "  - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
52: 
53:       out << "  - RUBY EXECUTABLE: #{Gem.ruby}\n"
54: 
55:       out << "  - EXECUTABLE DIRECTORY: #{Gem.bindir}\n"
56: 
57:       out << "  - RUBYGEMS PLATFORMS:\n"
58:       Gem.platforms.each do |platform|
59:         out << "    - #{platform}\n"
60:       end
61: 
62:       out << "  - GEM PATHS:\n"
63:       out << "     - #{Gem.dir}\n"
64: 
65:       path = Gem.path.dup
66:       path.delete Gem.dir
67:       path.each do |p|
68:         out << "     - #{p}\n"
69:       end
70: 
71:       out << "  - GEM CONFIGURATION:\n"
72:       Gem.configuration.each do |name, value|
73:         out << "     - #{name.inspect} => #{value.inspect}\n"
74:       end
75: 
76:       out << "  - REMOTE SOURCES:\n"
77:       Gem.sources.each do |s|
78:         out << "     - #{s}\n"
79:       end
80: 
81:     else
82:       fail Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
83:     end
84:     say out
85:     true
86:   end

[Validate]