class InspecPlugins::Artifact::Base

def read_profile_metadata(path_to_profile)

def read_profile_metadata(path_to_profile)
  begin
    p = Pathname.new(path_to_profile)
    p = p.join('inspec.yml')
    if not p.exist?
      raise "#{path_to_profile} doesn't appear to be a valid InSpec profile"
    end
    yaml = YAML.load_file(p.to_s)
    yaml = yaml.to_hash
    if not yaml.key? 'name'
      raise 'Profile is invalid, name is not defined'
    end
    if not yaml.key? 'version'
      raise 'Profile is invalid, version is not defined'
    end
  rescue => e
    # rewrap it and pass it up to the CLI
    raise "Error reading InSpec profile metadata: #{e}"
  end
  yaml
end