lib/ronin/config.rb in ronin-0.1.2 vs lib/ronin/config.rb in ronin-0.1.3

- old
+ new

@@ -1,11 +1,11 @@ # #-- # Ronin - A Ruby platform designed for information security and data # exploration tasks. # -# Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com) +# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. @@ -23,38 +23,45 @@ require 'fileutils' module Ronin module Config + # The users home directory + HOME = File.expand_path(ENV['HOME'] || ENV['HOMEPATH']) + # Ronin home directory - PATH = FileUtils.mkdir_p(File.join(ENV['HOME'],'.ronin')) + PATH = FileUtils.mkdir_p(File.join(HOME,'.ronin')) # Path to static directory STATIC_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','..','static')) # Main configuration file - CONFIG_PATH = File.expand_path(File.join(PATH,'config.rb')) + CONFIG_PATH = File.join(PATH,'config.rb') # Configuration files directory - CONFIG_DIR = File.expand_path(File.join(PATH,'config')) + CONFIG_DIR = FileUtils.mkdir_p(File.join(PATH,'config')) # Temporary file directory TMP_DIR = FileUtils.mkdir_p(File.join(PATH,'tmp')) # # Require the Ronin configuration file with the given _name_ in the # Ronin configuration files directory. If _name_ is not given, than the # main Ronin configuration file will be loaded. # - # # Load the main config file at <tt>~/.ronin/config.rb</tt> - # Config.load # => true + # Load the main config file at <tt>~/.ronin/config.rb</tt> # - # # Load a specific config file in <tt>~/.ronin/config/</tt> - # Config.load 'sql' # => true + # Config.load + # # => true # + # Load a specific config file in <tt>~/.ronin/config/</tt> + # + # Config.load :sql + # # => true + # def Config.load(name=nil) if name - path = File.expand_path(File.join(CONFIG_DIR,name)) + path = File.expand_path(File.join(CONFIG_DIR,name.to_s)) else path = CONFIG_PATH end require path if File.file?(path)