Class: AxeConfig
- Inherits:
-
Hash
- Object
- Hash
- AxeConfig
- Defined in:
- lib/myaxes/axeconfig.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
-
#initialize(options) ⇒ AxeConfig
constructor
A new instance of AxeConfig.
- #read(config) ⇒ Object
Constructor Details
#initialize(options) ⇒ AxeConfig
Returns a new instance of AxeConfig.
7 8 9 10 11 |
# File 'lib/myaxes/axeconfig.rb', line 7 def initialize() @config = Hash.new @options = @targets = Hash.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/myaxes/axeconfig.rb', line 5 def config @config end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
5 6 7 |
# File 'lib/myaxes/axeconfig.rb', line 5 def targets @targets end |
Instance Method Details
#read(config) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/myaxes/axeconfig.rb', line 13 def read(config) user = @options['user'] ip = @options['ip'] #password = @options['password'] group = @options['group'] puts "Configfile (#{config}) not found" unless File.readable?(config) begin @config = YAML.load_file(File.(config)) rescue Exception => errmsg puts "Configfile format error: #{errmsg}" end @config['Targets'].each_key do |target| if @config['Targets'][target]['query'].include? group @config['Targets'][target]['query'][group].each do |query| query.to_s.gsub!('{ip}', ip).gsub!('{user}', user) end @targets["#{@config['Targets'][target]['hostname']}"] = @config['Targets'][target]['query'][group] end end self.config end |