Parent

Methods

Class Index [+]

Quicksearch

Gem::Commands::GenerateIndexCommand

Generates a index files for use as a gem server.

See `gem help generate_index`

Public Class Methods

new() click to toggle 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

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.