Class: ProfileLoader
Instance Method Summary collapse
-
#initialize(rules_registry) ⇒ ProfileLoader
constructor
A new instance of ProfileLoader.
-
#load(profile_definition:) ⇒ Object
Load rules from a profile definition.
Constructor Details
#initialize(rules_registry) ⇒ ProfileLoader
Returns a new instance of ProfileLoader.
6 7 8 |
# File 'lib/cfn-nag/profile_loader.rb', line 6 def initialize(rules_registry) @rules_registry = rules_registry end |
Instance Method Details
#load(profile_definition:) ⇒ Object
Load rules from a profile definition
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cfn-nag/profile_loader.rb', line 11 def load(profile_definition:) # coerce falsy profile_definition into empty string for # empty profile check profile_definition ||= '' raise 'Empty profile' if profile_definition.strip == '' new_profile = RuleIdSet.new profile_definition.each_line do |line| next unless (rule_id = rule_line_match(line)) check_valid_rule_id rule_id new_profile.add_rule rule_id end new_profile end |