Class Gem::Commands::GenerateIndexCommand
In: lib/rubygems/commands/generate_index_command.rb
Parent: Gem::Command

Generates a index files for use as a gem server.

See `gem help generate_index`

Methods

execute   new  

Public Class methods

[Source]

    # File lib/rubygems/commands/generate_index_command.rb, line 11
11:   def initialize
12:     super 'generate_index',
13:           'Generates the index files for a gem server directory',
14:           :directory => '.', :build_legacy => true, :build_modern => true
15: 
16:     add_option '-d', '--directory=DIRNAME',
17:                'repository base dir containing gems subdir' do |dir, options|
18:       options[:directory] = File.expand_path dir
19:     end
20: 
21:     add_option '--[no-]legacy',
22:                'Generate Marshal.4.8' do |value, options|
23:       unless options[:build_modern] or value then
24:         raise OptionParser::InvalidOption, 'no indicies will be built'
25:       end
26: 
27:       options[:build_legacy] = value
28:     end
29: 
30:     add_option '--[no-]modern',
31:                'Generate indexes for RubyGems newer',
32:                'than 1.2.0' do |value, options|
33:       unless options[:build_legacy] or value then
34:         raise OptionParser::InvalidOption, 'no indicies will be built'
35:       end
36: 
37:       options[:build_modern] = value
38:     end
39: 
40:     add_option '--update',
41:                'Update modern indexes with gems added',
42:                'since the last update' do |value, options|
43:       options[:update] = value
44:     end
45: 
46:     add_option :RSS, '--rss-gems-host=GEM_HOST',
47:                'Host name where gems are served from,',
48:                'used for GUID and enclosure values' do |value, options|
49:       options[:rss_gems_host] = value
50:     end
51: 
52:     add_option :RSS, '--rss-host=HOST',
53:                'Host name for more gems information,',
54:                'used for RSS feed link' do |value, options|
55:       options[:rss_host] = value
56:     end
57: 
58:     add_option :RSS, '--rss-title=TITLE',
59:                'Set title for RSS feed' do |value, options|
60:       options[:rss_title] = value
61:     end
62:   end

Public Instance methods

[Source]

     # File lib/rubygems/commands/generate_index_command.rb, line 102
102:   def execute
103:     if options[:update] and
104:        (options[:rss_host] or options[:rss_gems_host]) then
105:       alert_error '--update not compatible with RSS generation'
106:       terminate_interaction 1
107:     end
108: 
109:     if not File.exist?(options[:directory]) or
110:        not File.directory?(options[:directory]) then
111:       alert_error "unknown directory name #{directory}."
112:       terminate_interaction 1
113:     else
114:       indexer = Gem::Indexer.new options.delete(:directory), options
115: 
116:       if options[:update] then
117:         indexer.update_index
118:       else
119:         indexer.generate_index
120:       end
121:     end
122:   end

[Validate]