gem of the week: cheat
October 13th, 2009
No comments
A couple of weeks ago I mentioned the “cheat” gem which has a plethora of useful quick docs on various topics such as regular expressions. I breezed through the install — and fix for Ruby 1.9.1 — here it is, for the record:
gem install cheat # NOTE: If you're on Linux or OS/X and have a standard install (rather than using the ruby_switch.sh script, you want to do sudo gem install cheat)
If you run it under 1.9.x, you should get an error like so:
cheat regexp /Users/jnorman/.gem/ruby/1.9.1/gems/cheat-1.2.1/lib/cheat.rb:150:in `cache_dir': uninitialized constant Cheat::PLATFORM (NameError) from /Users/jnorman/.gem/ruby/1.9.1/gems/cheat-1.2.1/lib/cheat.rb:16:in `sheets' from /Users/jnorman/.gem/ruby/1.9.1/gems/cheat-1.2.1/bin/cheat:4:in `<top (required)>' from /Users/jnorman/.gem/ruby/1.9.1/bin/cheat:19:in `load' from /Users/jnorman/.gem/ruby/1.9.1/bin/cheat:19:in `<main>'
What you want to do is edit the file producing the error (in my case, from the exception trace, /Users/jnorman/.gem/ruby/1.9.1/gems/cheat-1.2.1/lib/cheat.rb). Go to the line, and change the constant PLATFORM to RUBY_PLATFORM. Save the file.
And voila!
chelsea:~ jnorman$ cheat regexp regexp: A regexp's form is written /pattern/modifiers where "pattern" is the regular # much deleted
For help,
cheat cheat