class Inspec::Resources::PConfig

def initialize(content = nil, useropts = nil)

def initialize(content = nil, useropts = nil)
  @opts = {}
  @opts = useropts.dup unless useropts.nil?
  @files_contents = {}
  @content = content
  read_params unless @content.nil?
end

def method_missing(*name)

def method_missing(*name)
  # catch bahavior of rspec its implementation
  # @see https://github.com/rspec/rspec-its/blob/v1.2.0/lib/rspec/its.rb#L110
  name.shift if name.is_a?(Array) && name[0] == :[]
  read_params[name[0].to_s]
end

def params(*opts)

def params(*opts)
  opts.inject(read_params) do |res, nxt|
    res.respond_to?(:key) ? res[nxt] : nil
  end
end

def parse_file(conf_path)

def parse_file(conf_path)
  @conf_path = conf_path
  @content = read_file(conf_path).to_s
  read_params
end

def read_file(path)

def read_file(path)
  @files_contents[path] ||= read_file_content(path)
end

def read_params

def read_params
  @params ||= if content.nil?
                {}
              else
                SimpleConfig.new(content, @opts).params
              end
end

def resource_id

def resource_id
  @content || "parse_config"
end

def to_s

def to_s
  "Parse Config #{@conf_path}"
end