A ruby gem consisting of String methods to title case strings, including a command-line demonstration utility.
gem install title_case
or, if you want the latest and the greatest, or if you want the man page installed:
git clone https://github.com/nbirnel/titlecase
cd titlecase
rake install
(use sudo
as necessary)
ruby >= 1.9.2
rake
groff
This is partially inspired and informed by John Gruber's titlecase: http://daringfireball.net/2008/05/title_case and Sam Souder's ruby implementation: https://github.com/samsouder/titlecase
I didn't like a few of the rules in Gruber's version, though. Major differences are:
- don't ever downcase anything
- the last word doesn't get upcased if it is on the exclude list
- the exclude list is slightly different
- colons get no special treatment
© 2014 Noah Birnel MIT license
<title>titlecase</title>NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
SEE ALSO
BUGS
LICENSE
titlecase − capitalize a phrase like a newspaper editor would
titlecase [FILE]
titlecase converts a byte-stream to title-casing — the first letter of most words is converted to upper-case. Exceptions are:
words that already have some capitalization (Jones, AT&T, iPhone) or numbers (x0xb0x, left4dead)
a list of short (less than 4 characters) conjunctions, prepositions, and articles; unless they are at the beginning of the byte-stream
none
echo ’old McDonald had a farm’ | titlecase
Old McDonald Had a Farm
ruby(1)
http://daringfireball.net/2008/05/title_case
http://rubygems.org/gems/titlecase
Capitalizes Dutch abbreviations ’s, ’t, ’n. Probably others.
Copyright 2014 Noah Birnel
MIT license