Class: SimpleConfig
- Inherits:
 - 
      Object
      
        
- Object
 - SimpleConfig
 
 
- Includes:
 - Inspec::Utils::CommentParser
 
- Defined in:
 - lib/inspec/utils/simpleconfig.rb
 
Instance Attribute Summary collapse
- 
  
    
      #groups  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute groups.
 - 
  
    
      #params  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute params.
 
Instance Method Summary collapse
- 
  
    
      #initialize(raw_data, opts = {})  ⇒ SimpleConfig 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of SimpleConfig.
 - 
  
    
      #parse(raw_data, opts = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Parse some data quotes: quoting characters, which are parsed, so everything inside it will be part of a string multiline: allow quoted text to span multiple lines comment_char: char which identifies comments standalone_comments: comments must appear alone in a line; if set to true, no comments can be added to the end of an assignment/statement line.
 
Methods included from Inspec::Utils::CommentParser
Constructor Details
#initialize(raw_data, opts = {}) ⇒ SimpleConfig
Returns a new instance of SimpleConfig.
      10 11 12  | 
    
      # File 'lib/inspec/utils/simpleconfig.rb', line 10 def initialize(raw_data, opts = {}) parse(raw_data, opts) end  | 
  
Instance Attribute Details
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
      9 10 11  | 
    
      # File 'lib/inspec/utils/simpleconfig.rb', line 9 def groups @groups end  | 
  
#params ⇒ Object (readonly)
Returns the value of attribute params.
      9 10 11  | 
    
      # File 'lib/inspec/utils/simpleconfig.rb', line 9 def params @params end  | 
  
Instance Method Details
#parse(raw_data, opts = nil) ⇒ Object
Parse some data quotes: quoting characters, which are parsed, so everything inside it will be part of a string multiline: allow quoted text to span multiple lines comment_char: char which identifies comments standalone_comments: comments must appear alone in a line; if set to true, no comments can be added to the end of an assignment/statement line
      21 22 23 24 25 26 27 28 29 30 31 32 33 34  | 
    
      # File 'lib/inspec/utils/simpleconfig.rb', line 21 def parse(raw_data, opts = nil) @params = {} @groups = [] @vals = @params = .merge(opts || {}) return if raw_data.nil? # prepare raw data if required unless [:line_separator].nil? raw_data = raw_data.tr([:line_separator], "\n") end rest = raw_data rest = parse_rest(rest, ) until rest.empty? end  |