Lovely Rufus

Lovely Rufus is an executable and a Ruby library for wrapping paragraphs of text in the spirit of Par.

usage

Lovely Rufus can be used from the command-line by piping text through the lovely-rufus executable:

$ echo 'The Ballyshannon foundered off the coast of Cariboo, And down in fathoms many went the captain and the crew;' | lovely-rufus
The Ballyshannon foundered off the coast of Cariboo,
And down in fathoms many went the captain and the crew;
$

Lovely Rufus can also be used from Ruby code through the Wrapper class:

$ irb
>> require 'lovely-rufus'
>> text = 'The Ballyshannon foundered off the coast of Cariboo, And down in fathoms many went the captain and the crew;'
>> puts LovelyRufus::Wrapper.new(text).wrapped
The Ballyshannon foundered off the coast of Cariboo,
And down in fathoms many went the captain and the crew;
>>

Note that Wrapper#wrapped can take optional desired width:

$ irb
>> require 'lovely-rufus'
>> text = 'The Ballyshannon foundered off the coast of Cariboo, And down in fathoms many went the captain and the crew;'
>> puts LovelyRufus::Wrapper.new(text).wrapped(15)
The
Ballyshannon
foundered off
the coast of
Cariboo, And
down in fathoms
many went the
captain and the
crew;
>>

features

Currently, Lovely Rufus sports the following features:

  • paragraphs are wrapped to the specified width,
  • one-letter words are not left at ends of lines,
  • email quotes (>) are handled properly and normalised (> > >>>>),
  • email-quoted paragraph breaks are cleared,
  • code comments (starting with # and //) are handled properly,
  • multiple paragraphs are wrapped independently.

name and history

Lovely Rufus was created as a Ruby Mendicant University project and is named after a certain Love Actually character who’s exceptionally good at wrapping.


© MMX-MMXII Piotr Szotkowski [email protected], licensed under AGPL 3 (see LICENCE)