Class | Webgen::ConfigurationFile |
In: |
lib/webgen/website.rb
|
Parent: | Object |
Represents the configuration file of a website.
config | [R] | Returns the whole configuration. |
Reads the content of the given configuration file and initialize a new object with it.
# File lib/webgen/website.rb, line 290 290: def initialize( config_file ) 291: if File.exists?( config_file ) 292: begin 293: @config = YAML::load( File.read( config_file ) ) 294: rescue ArgumentError => e 295: raise ConfigurationFileInvalid, e.message 296: end 297: else 298: @config = {} 299: end 300: check_config 301: end
See PluginManager#param_for_plugin .
# File lib/webgen/website.rb, line 304 304: def param_for_plugin( plugin_name, param ) 305: if @config.has_key?( plugin_name ) && @config[plugin_name].has_key?( param ) 306: @config[plugin_name][param] 307: else 308: PluginParamValueNotFound 309: end 310: end
# File lib/webgen/website.rb, line 316 316: def check_config 317: if !@config.kind_of?( Hash ) || !@config.all? {|k,v| v.kind_of?( Hash )} 318: raise ConfigurationFileInvalid.new( 'Structure of config file is not valid, has to be a Hash of Hashes' ) 319: end 320: 321: if !@config.has_key?( 'Core/FileHandler' ) || !@config['Core/FileHandler'].has_key?( 'defaultMetaInfo' ) 322: @config.each_key do |plugin_name| 323: next unless plugin_name =~ /File\// 324: if @config[plugin_name]['defaultMetaInfo'].kind_of?( Hash ) 325: ((@config['Core/FileHandler'] ||= {})['defaultMetaInfo'] ||= {})[plugin_name] = @config[plugin_name]['defaultMetaInfo'] 326: @config[plugin_name].delete( 'defaultMetaInfo' ) 327: end 328: end 329: end 330: 331: end