Class: YamlBot::ValidationBot

Inherits:
Object
  • Object
show all
Defined in:
lib/yaml_bot/validation_bot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules = nil, yaml_file = nil) ⇒ ValidationBot

Returns a new instance of ValidationBot.



8
9
10
11
12
# File 'lib/yaml_bot/validation_bot.rb', line 8

def initialize(rules = nil, yaml_file = nil)
  @rules = rules || {}
  @yaml_file = yaml_file || {}
  @violations = 0
end

Instance Attribute Details

#rulesObject

Returns the value of attribute rules.



6
7
8
# File 'lib/yaml_bot/validation_bot.rb', line 6

def rules
  @rules
end

#violationsObject

Returns the value of attribute violations.



6
7
8
# File 'lib/yaml_bot/validation_bot.rb', line 6

def violations
  @violations
end

#yaml_fileObject

Returns the value of attribute yaml_file.



6
7
8
# File 'lib/yaml_bot/validation_bot.rb', line 6

def yaml_file
  @yaml_file
end

Instance Method Details

#scanObject



14
15
16
17
18
19
20
21
# File 'lib/yaml_bot/validation_bot.rb', line 14

def scan
  defaults = rules['defaults']
  rules['rules'].each do |item|
    key_bot = KeyBot.new(item, yaml_file, defaults)
    @violations += key_bot.validate
  end
  @violations
end