Custom OHAI plugin

I am using Ohai version 8.20.0 and trying to write a custom ohai plugin. I have been reading a few articles.
Most of them suggest copying the ohai cookbook from and defining it as ‘depends’ in your cookbook metadata.rb.

Is this the only way to do it? Is there any other options available?

The Chef Intermediate Topics class will teach you how to get started writing Ohai plugins.