github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

mudge / title_case

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A Ruby implementation of John Gruber's Title Case. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Update the README now that it is a module. 
mudge (author)
Wed Aug 13 10:41:28 -0700 2008
commit  19d031809d358509097e5b46139c9e6d59b40f9b
tree    0cab7c7036c246bc1ff733dcf92cf81240b5bf38
parent  7aadea889affca0818a8c0a450366da73427cbf6
title_case /
name age
history
message
file BSD-LICENSE.txt Loading commit data...
file GPL-LICENSE.txt
file README.markdown Wed Aug 13 10:41:28 -0700 2008 Update the README now that it is a module. [mudge]
file title_case.rb Wed Aug 13 10:38:08 -0700 2008 Convert to module and add all of David Gouch's ... [mudge]
file title_case_test.rb
README.markdown

Ruby Title Case

This is a Ruby implementation of John Gruber's Title Case by Paul Mucur.

Usage

Simply include the TitleCase module into your string class. For example, inside a Ruby script or an irb session:

require 'title_case'

class String
  include TitleCase
end

"Hello there".title_case

Alternatively, it can be used from the command-line:

ruby title_case.rb "Hello there"
echo "An amazing headline" | ruby title_case.rb

Known Issues

Unlike the original Perl implementation, this version does not correctly capitalise characters such as é and is therefore limited in scope to strings consisting only of ASCII printable characters. A workaround would be to stop relying on the Ruby regular expression patterns of [A-Z], \w and \W for detecting capital letters, alphanumeric characters and non-alphanumeric characters respectively.

While it will deal with most common usage where you need a reasonably-correctly-cased sentence to be made suitable for a title, it will not correct mistakes such as lowercase acronyms or errant capital letters:

"at&t"  => "At&t"
"HellO" => "HellO"
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server