Module: Qualys::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/qualys/config.rb

Defined Under Namespace

Classes: RequiredOptionMissing

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/qualys/config.rb', line 6

def password
  @password
end

#session_keyObject

Returns the value of attribute session_key.



6
7
8
# File 'lib/qualys/config.rb', line 6

def session_key
  @session_key
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/qualys/config.rb', line 6

def username
  @username
end

Instance Method Details

#from_hash(options = {}) ⇒ Object

Configure Qualys from a hash. This is usually called after parsing a yaml config file such as qualys.yaml.

Examples:

Configure Qualys.

config.from_hash({})

Parameters:

  • options (Hash) (defaults to: {})

    The settings to use.



15
16
17
18
19
# File 'lib/qualys/config.rb', line 15

def from_hash(options = {})
  options.each_pair do |name, value|
    send("#{name}=", value) if respond_to?("#{name}=")
  end
end

#load!(path) ⇒ Object

Load the settings from a compliant Qualys.yml file. This can be used for easy setup with frameworks other than Rails.

Examples:

Configure Qualys.

Qualys.load!("/path/to/qualys.yml")

Parameters:

  • path (String)

    The path to the file.



28
29
30
31
# File 'lib/qualys/config.rb', line 28

def load!(path)
  settings = YAML.safe_load(ERB.new(File.new(path).read).result)['api']
  from_hash(settings) if settings.is_a? Hash
end