The RubyGem Cheat gives command-line access to user-written "cheat sheets" on any topic. A cheat sheet gives notes and other quick information about a Ruby topic. It's helpful to think of cheat sheets as wiki pages. Not only can you read them, but you can add new ones and edit existing ones--and there's no authentication or log in required. The objective is to give total freedom in sharing useful information about Ruby topics.
Installing cheat is the same as installing any other Ruby gem.
$ sudo gem install cheat
The Cheat Sheet on Cheat
One of the first cheat sheets you should look at is the cheat sheet about the Cheat gem itself. To view a cheat sheet, run the cheat command with the name of the cheat sheet you want to see.
$ cheat cheat
The cheat sheet on Cheat gives a list of useful commands you can use with the Cheat gem. Since this is not a full manual page, cheat sheets are often more useful if you already understand the concepts.
Add a New Cheat Sheet
You aren't restricted to viewing and editing existing cheat sheets, you can also create your own. Be aware that any cheat sheets you submit will appear on a public website, do not include any personal information or passwords in the cheat sheet. Also be sure not to flood the cheat database with useless or uninteresting cheat sheets.
To add a new cheat sheet, append the --add parameter to your cheat command.
$ cheat ruby_about_com_example --add
This will launch an editor in which you can insert the text of your cheat sheet. When you save the file and exit the editor, the new cheat sheet will be saved in your cheat cache. At this point, the cheat sheet is stored locally on your computer and not yet uploaded so others can see it. To upload it, run the --new command on the cheat sheet.
$ cheat ruby_about_com_example --new
Edit a Cheat Sheet
Since cheat sheets are wiki-like, you can edit any of them to add information, correct mistakes or make other improvements. Since there is no moderation, care must be taken to ensure all edits are beneficial and factual . In a wiki environment, it is the user's responsibility to maintain the articles, not an editor or moderator. This serves as a double-edged sword: Do not assume all information you read in a wiki or the cheat sheets are correct! If you suspect a problem, refer to the manuals.
Editing a cheat sheet is as easy as adding the --edit switch to the command-line to view a cheat sheet. As with the --add command, an editor is launched, but this time it contains the existing content of the cheat sheet. Make whatever changes you wish to the cheat sheet, proofread for mistakes, save the file and exit the editor. The new changes will be uploaded to the cheat sheet on the server.
$ cheat ruby_about_com_example --edit
Flush Your Cache
As you download and view cheat sheets, the sheets are stored in your local cache. In order to get updated cheat sheets, it's a good idea to clear that cache from time to time. After your cheat sheet cache has been cleared, any future attempts to access cheat sheets will be sure to download them from the server once again. Clearing your cache is necessary for viewing changes made to cheat sheets by other users. To clear your entire cheat sheet cache, simple run the --new command with no cheat sheet name.
$ cheat --new
Changing Your Default Editor
On Linux and other systems, the default editor used by cheat is Vim. While Vim is very powerful, if you don't know how to use it it's a very frustrating experience. To change your editor to a more friendly editor, pass the command of the editor to cheat with the EDITOR environment variable. For instance, a more friendly editor available on Ubuntu Linux is gedit. You can edit cheat sheets with gedit by using the following command.
$ EDITOR=gedit cheat ruby_about_com_example --edit