NAME
Acme::Text::Shorten::ForTwitter - Shorten text for use in tweets
SYNOPSIS
# Use all available plugins
my
$shortener
= Acme::Text::Shorten::ForTwitter->new;
$shortener
->shorten(
"I am happy to see you"
);
# I'm happy to see u
# Only load specific plugins:
# Load all plugins except a few
# Add a base rule
$shortener
->add_rule(
'texting'
);
# Add a custom rule
$shortener
->add_rule(
'/dev/null'
=>
sub
{
my
$text
=
shift
;
$$text
=
''
; });
# Remove a rule
$shortener
->remove_rule(
'contractoins'
);
DESCRIPTION
This module makes writing content-rich tweets easier by helping you shorten things as much as possible while still maintaining the original content's meaning.
Various plugins are shipped with this module by default, and you can write your own or install more from CPAN (if any are available.)
See "Writing Plugins" below for information on writing plugins.
Class Methods
new
my
$shortener
= Acme::Text::Shorten::ForTwitter->new;
Creates a new shortener with all of the rules selected at import time.
Object Methods
shorten
$shortener
->shorten(
"What is going on?"
);
Takes text as input and transforms it to a shorter version if possible. It achieves this by running through all enabled rules and attempting to apply them to the input.
add_rule
$shortener
->add_rule(
"name"
);
$shortener
->add_rule(
"name"
,
sub
{
my
$text
=
shift
;
$$text
=~ s/hello/hi/;
});
In the first form, adds a named rule from one of the loaded plugins to the list of rules to use. Will die if the named rule cannot be found.
In the second form, adds a custom rule. The subroutine should take a reference to a scalar, and should modify the scalar as needed.
remove_rule
$shortener
->remove_rule(
"name"
);
Removes the named rule from the shortener. Will die if the named rule cannot be found.
Writing Plugins
A plugin should look like this:
It will automatically be loaded when Acme::Text::Shorten::ForTwitter is loaded.
AUTHOR
Matthew Horsfall (alh) - <wolfsage@gmail.com>