Method: Onceover::Node#initialize
- Defined in:
- lib/onceover/node.rb
#initialize(name) ⇒ Node
Returns a new instance of Node.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/onceover/node.rb', line 14 def initialize(name) @name = name @beaker_node = nil # If we can't find the factset it will fail, so just catch that error and ignore it begin facts_file_index = Onceover::Controlrepo.facts_files.index {|facts_file| File.basename(facts_file, '.json') == name } @fact_set = Onceover::Node.clean_facts(Onceover::Controlrepo.facts[facts_file_index]) # First see if we can find a 'trusted' hash at the top level of our factset @trusted_set = Onceover::Controlrepo.trusted_facts[facts_file_index] # If we don't find it, attempt to find a 'trusted.extensions' hash nested in our fact_set @trusted_set = @fact_set.dig('trusted', 'extensions') if @trusted_set.nil? # If we still can't find any, return an empty hash so the following doesn't blow up user written tests: # let(:trusted_facts) { trusted_facts } @trusted_set = {} if @trusted_set.nil? # First see if we can find a 'trusted_external' hash at the top level of our factset @trusted_external_set = Onceover::Controlrepo.trusted_external_facts[facts_file_index] # If we don't find it, attempt to find a 'trusted.external' hash nested in our fact_set @trusted_external_set = @fact_set.dig('trusted', 'external') if @trusted_external_set.nil? # If we still can't find any, return an empty hash so the following doesn't blow up user written tests: # let(:trusted_external_data) { trusted_external_data } @trusted_external_set = {} if @trusted_external_set.nil? rescue TypeError @fact_set = {} @trusted_set = {} @trusted_external_set = {} end @@all << self end |