Class Gem::Commands::ServerCommand
In: lib/rubygems/commands/server_command.rb
Parent: Gem::Command

Methods

execute   new  

Public Class methods

[Source]

    # File lib/rubygems/commands/server_command.rb, line 6
 6:   def initialize
 7:     super 'server', 'Documentation and gem repository HTTP server',
 8:           :port => 8808, :gemdir => [], :daemon => false
 9: 
10:     OptionParser.accept :Port do |port|
11:       if port =~ /\A\d+\z/ then
12:         port = Integer port
13:         raise OptionParser::InvalidArgument, "#{port}: not a port number" if
14:           port > 65535
15: 
16:         port
17:       else
18:         begin
19:           Socket.getservbyname port
20:         rescue SocketError
21:           raise OptionParser::InvalidArgument, "#{port}: no such named service"
22:         end
23:       end
24:     end
25: 
26:     add_option '-p', '--port=PORT', :Port,
27:                'port to listen on' do |port, options|
28:       options[:port] = port
29:     end
30: 
31:     add_option '-d', '--dir=GEMDIR',
32:                'directories from which to serve gems',
33:                'multiple directories may be provided' do |gemdir, options|
34:       options[:gemdir] << File.expand_path(gemdir)
35:     end
36: 
37:     add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
38:       options[:daemon] = daemon
39:     end
40: 
41:     add_option '-b', '--bind=HOST,HOST',
42:                'addresses to bind', Array do |address, options|
43:       options[:addresses] ||= []
44:       options[:addresses].push(*address)
45:     end
46: 
47:     add_option '-l', '--launch[=COMMAND]', 
48:                'launches a browser window',
49:                "COMMAND defaults to 'start' on Windows",
50:                "and 'open' on all other platforms" do |launch, options|
51:       launch ||= Gem.win_platform? ? 'start' : 'open'
52:       options[:launch] = launch
53:     end
54:   end

Public Instance methods

[Source]

    # File lib/rubygems/commands/server_command.rb, line 81
81:   def execute
82:     options[:gemdir] << Gem.dir if options[:gemdir].empty?
83:     Gem::Server.run options
84:   end

[Validate]