Class: Facter::YamlFactFormatter
- Inherits:
 - 
      Object
      
        
- Object
 - Facter::YamlFactFormatter
 
 
- Defined in:
 - lib/facter/framework/formatters/yaml_fact_formatter.rb
 
Instance Method Summary collapse
- #format(resolved_facts) ⇒ Object
 - 
  
    
      #initialize  ⇒ YamlFactFormatter 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of YamlFactFormatter.
 
Constructor Details
#initialize ⇒ YamlFactFormatter
Returns a new instance of YamlFactFormatter.
      5 6 7  | 
    
      # File 'lib/facter/framework/formatters/yaml_fact_formatter.rb', line 5 def initialize @log = Log.new(self) end  | 
  
Instance Method Details
#format(resolved_facts) ⇒ Object
      9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  | 
    
      # File 'lib/facter/framework/formatters/yaml_fact_formatter.rb', line 9 def format(resolved_facts) user_queries = resolved_facts.uniq(&:user_query).map(&:user_query) facts_to_display = if user_queries.count == 1 && user_queries.first.empty? FormatterHelper.retrieve_fact_collection(resolved_facts) else FormatterHelper.retrieve_facts_to_display_for_user_query(user_queries, resolved_facts) end facts_to_display = Psych.parse_stream(facts_to_display.to_yaml) facts_to_display.children[0].tag_directives = [] yaml_pretty = quote_special_strings(facts_to_display) @log.debug('Replace --- from yaml beginning, to keep it compatible with C facter') yaml_pretty.gsub(/^---[\r\n]+/, '') end  |