wikigen 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/usr/bin/env ruby

=begin
require 'simplecov'
SimpleCov.start
=end

$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'wiki_generator'
require 'generators/cpu_parameters'
require 'generators/disk_reservation'
require 'generators/hardware'
require 'generators/oar_properties'
require 'generators/site_hardware'
require 'generators/site_network'

GLOBAL_GENERATORS = {
  'cpu_parameters' => {
    :gen => CPUParametersGenerator,
    :page => "Generated/CPUParameters"
  },
  'disk_reservation' => { 
    :gen => DiskReservationGenerator,
    :page => 'Generated/DiskReservation'
  },
  'hardware' => {
    :gen => G5KHardwareGenerator,
    :page => 'Hardware'
  },
  'oar_properties' => {
    :gen => OarPropertiesGenerator,
32
    :page => 'OAR_Properties'
33 34 35 36 37 38 39 40 41 42 43 44 45 46
  }
}
SITE_GENERATORS = {
  'site_hardware' => {
    :gen => SiteHardwareGenerator,
    :page_suffix => ':Hardware'
  },
  'site_network' => {
    :gen => SiteNetworkGenerator,
    :page_suffix => ':GeneratedNetwork'
  }
}
GENERATORS = GLOBAL_GENERATORS.merge(SITE_GENERATORS)

47
ret = true
48 49 50 51 52 53 54
options = WikiGenerator::parse_options
myopts = options.clone
options[:generators].each do |g|
  myopts[:generators] = [g]
  options[:sites].each do |s|
    myopts[:sites] = [s]
    if GLOBAL_GENERATORS.has_key?(g) and s == 'global'
55
      ret &= GLOBAL_GENERATORS[g][:gen].new(GLOBAL_GENERATORS[g][:page]).exec(myopts)
56
    elsif SITE_GENERATORS.has_key?(g) and s != 'global'
57
      ret &= SITE_GENERATORS[g][:gen].new(s.capitalize + SITE_GENERATORS[g][:page_suffix], s).exec(myopts)
58 59 60 61 62
    else
      puts "Nothing to do: #{g}/#{s}"
    end
  end
end
63
exit(ret)