Class Webgen::CheckCommand
In: lib/webgen/cli.rb
Parent: CmdParse::Command
RuntimeError PluginParamNotFound PluginNotFound ConfigurationFileInvalid CmdParse::CommandParser CommandParser DirectoryInfo GalleryStyle WebSiteStyle WebSiteTemplate SipttraStyle Test::Unit::TestCase TestCase PluginTestCase TagTestCase CmdParse::Command ShowCommand CheckCommand UseCommand CreateCommand TSort DependencyHash Hash Comparable Language ::Logger Logger Logger DEFAULT_WRAPPER_MODULE WebSite Qt::MainWindow MainWindow Qt::Dialog NewWebsiteDialog Qt::TextEdit LogWidget ::Rake::TaskLib WebgenTask ConfigurationFile Website PluginManager PluginLoader PluginParamValueNotFound Dummy Color CliUtils PluginDefs lib/webgen/languages.rb lib/webgen/website.rb lib/webgen/gui/common.rb lib/webgen/plugin.rb lib/webgen/test.rb lib/webgen/cli.rb ClassMethods PluginDefs LanguageManager lib/webgen/gui/new_website_dlg.rb lib/webgen/gui/main.rb GUI lib/webgen/rake/webgentask.rb Rake Webgen dot/m_60_1.png

Methods

new  

Public Class methods

[Source]

     # File lib/webgen/cli.rb, line 322
322:     def initialize( cmdparser )
323:       super( 'check', true )
324:       self.short_desc = "Checks things like validity of the config file or the availability of optional libraries"
325: 
326:       # Check configuration file command
327:       checkConfig = CmdParse::Command.new( 'config', false )
328:       checkConfig.short_desc = "Checks the validity of the configuration and outputs the used options"
329:       checkConfig.set_execution_block do |args|
330:         begin
331:           if File.exists?( File.join( cmdparser.directory, 'config.yaml' ) )
332:             print CliUtils.section( "Checking configuration file syntax...", 50, 0, :bold )
333:             config_file = ConfigurationFile.new( File.join( cmdparser.directory, 'config.yaml' ) )
334:             puts Color.green( 'OK' )
335: 
336:             puts CliUtils.section( "Checking parameters...", 0, 0, :bold )
337:             config_file.config.each do |plugin_name, params|
338:               params.each do |param_name, value|
339:                 print CliUtils.section( "#{plugin_name}:#{param_name}", 50, 2, :reset )
340:                 if cmdparser.website.manager.plugin_class_for_name( plugin_name ).nil?
341:                   puts Color.lred( 'NOT OK' ) + ': no such plugin'
342:                 else
343:                   begin
344:                     cmdparser.website.manager.param_for_plugin( plugin_name, param_name )
345:                     puts Color.green( 'OK' )
346:                   rescue PluginParamNotFound => e
347:                     puts Color.lred( 'NOT OK' ) + ': no such parameter'
348:                   end
349:                 end
350:               end
351:             end
352:           else
353:             print CliUtils.section( "No configuration file found!", 50, 0, :bold )
354:           end
355:         rescue ConfigurationFileInvalid => e
356:           puts Color.lred( 'NOT OK' ) + ': ' + e.message
357:         end
358:       end
359:       self.add_command( checkConfig, true )
360: 
361:       # Check optional libraries
362:       checkLibs = CmdParse::Command.new( 'libs', false )
363:       checkLibs.short_desc = "Checks the availability of optional libraries used by plugins"
364:       checkLibs.set_execution_block do |args|
365:         puts CliUtils.format( "List of optional libraries (the info line specifies which functionality will be available " +
366:                               "if the needed gems are installed):" ).join("\n")
367:         puts
368: 
369:         cmdparser.website.manager.plugin_loaders.each do |loader|
370:           loader.optional_parts.sort.each do |name, options|
371:             puts CliUtils.headline( name )
372:             puts CliUtils.section( 'Info', 25 ) + CliUtils.format( options[:info], 25 ).join("\n")
373:             puts CliUtils.section( 'Needed gems', 25 ) + options[:needed_gems].join( ', ' )
374:             puts CliUtils.section( 'Loaded', 25 ) + ( options[:loaded] ? Color.green( 'yes' ) : Color.lred( 'no' ) )
375:             puts CliUtils.section( 'Error message', 25 ) + CliUtils.format( options[:error_msg], 25 ).join("\n") unless options[:loaded]
376:             puts
377:           end
378:         end
379:       end
380:       self.add_command( checkLibs )
381:     end

[Validate]