Module: Ronin::Config

Defined in:
lib/ronin/config.rb

Overview

Configuration information for Ronin.

Constant Summary collapse

HOME =

The users home directory

Gem.user_home
PATH =

Ronin home directory

File.join(HOME,'.ronin')
CONFIG_DIR =

Configuration files directory

File.join(PATH,'config')
TMP_DIR =

Temporary file directory

File.join(PATH,'tmp')
BIN_DIRS =

Directories which contain binaries

ENV.fetch('PATH','').split(File::PATH_SEPARATOR)

Class Method Summary collapse

Class Method Details

.load(name = nil) ⇒ Object

Loads the Ronin configuration file.

Examples:

Load the config file at ~/.ronin/config.rb

Config.load
# => true

Load the config file at ~/.ronin/config/sql.rb

Config.load :sql
# => true

Parameters:

  • name (Symbol, String, nil) (defaults to: nil)

    The optional name of the file to load within CONFIG_DIR.



63
64
65
66
67
68
69
70
# File 'lib/ronin/config.rb', line 63

def self.load(name=nil)
  dir, file = if name then [CONFIG_DIR, "#{name}.rb"]
              else         [PATH, 'config.rb']
              end

  path = File.expand_path(File.join(dir,file))
  require path if File.file?(path)
end

.tmp_dir(sub_path = nil) ⇒ String

Auto-creates a directory within TMP_DIR.

Parameters:

  • sub_path (String) (defaults to: nil)

    The sub-path within TMP_DIR.

Returns:

  • (String)

    The full path within TMP_DIR.



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/ronin/config.rb', line 83

def self.tmp_dir(sub_path=nil)
  if sub_path
    sub_path = File.expand_path(File.join('',sub_path))
    path     = File.join(TMP_DIR,sub_path)

    FileUtils.mkdir_p(path) unless File.directory?(path)
    return path
  end

  return TMP_DIR
end