Skip to content

Commit

Permalink
updating POD docs for a few more reactor plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
wu committed Aug 6, 2011
1 parent 1871c68 commit bf2281b
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Wubot.pm
Expand Up @@ -16,6 +16,8 @@ Wubot - personal distributed reactive automation
=head1 DESCRIPTION
Please see the README for a full description.
=cut

#_* End
Expand Down
61 changes: 61 additions & 0 deletions lib/Wubot/Reactor/CopyField.pm
Expand Up @@ -37,3 +37,64 @@ sub react {
}

1;


__END__
=head1 NAME
Wubot::Reactor::CopyField - copy the value from one field to another field
=head1 SYNOPSIS
- name: copy value in field 'a' to field 'b'
plugin: CopyField
config:
source_field: a
target_field: b
=head1 DESCRIPTION
The CopyField plugin can be used to copy values from one field to
another field. You can specify the name of the target field directly
in the reactor config, or you can specify the name of a field on the
message whose value is the name of the target field.
For example, consider the message:
myfield1: foo
myfield2: bar
The reactor rule:
- name: copy myfield1 to myfield3
plugin: CopyField
config:
source_field: myfield1
target_field: myfield3
Would result in:
myfield1: foo
myfield2: bar
myfield3: foo
If you want to use the value of a message field as the name of the
source or target fields, use source_field_name or target_field_name.
For example, this rule applied to the original data:
- name: copy myfield1 to myfield3
plugin: CopyField
config:
source_field: myfield1
target_field_name: myfield2
This would look up the value of myfield1 in the message (foo), and set
that to the field named in myfield2 (bar):
myfield1: foo
myfield2: bar
bar: foo
20 changes: 20 additions & 0 deletions lib/Wubot/Reactor/DeleteField.pm
Expand Up @@ -12,3 +12,23 @@ sub react {
}

1;

__END__
=head1 NAME
Wubot::Reactor::DeleteField - remove a field from the message
=head1 SYNOPSIS
- name: delete field 'x' from the message
plugin: DeleteField
config:
field: x
=head1 DESCRIPTION
Removes a field and its value from a message.
32 changes: 31 additions & 1 deletion lib/Wubot/Reactor/Dumper.pm
Expand Up @@ -19,7 +19,7 @@ sub react {
my ( $self, $message, $config ) = @_;

if ( $config->{field} ) {
$self->logger->warn( $message->{ $config->{field} } );
print YAML::Dump $message->{ $config->{field} };
}
else {
print YAML::Dump $message;
Expand All @@ -29,3 +29,33 @@ sub react {
}

1;

__END__
=head1 NAME
Wubot::Reactor::Dumper - display the contents of a field or an entire message
=head1 SYNOPSIS
- name: dump message contents to stdout
plugin: Dumper
- name: display contents of message field 'x'
plugin: Dumper
config:
field: x
=head1 DESCRIPTION
Display the contents of a message field to stdout. This is primary
intended as a debugging tool, e.g. to see how a message looks at some
point in the rule tree.
If no configuration is specified, then the entire message will be
displayed to stdout using YAML::Dump. If a field is specified in the
config, then the contents of that field will be dumped using
YAML::Dump.
40 changes: 40 additions & 0 deletions lib/Wubot/Reactor/HTMLStrip.pm
Expand Up @@ -34,3 +34,43 @@ sub react {
}

1;

__END__
=head1 NAME
Wubot::Reactor::HTMLStrip - strip HTML data from a field
=head1 SYNOPSIS
- name: strip HTML from 'title' field and store results in the field title_text
plugin: HTMLStrip
config:
field: title
- name: strip HTML from the title field in-situ
plugin: HTMLStrip
config:
field: title
newfield: title
=head1 DESCRIPTION
The HTMLStrip plugin uses the perl module HTML::Strip to remove HTML
from a field. The original field content is not overwritten by
default. If you do not specify a 'newfield', then the HTML-stripped
content will be stored in a new field that matches the original field
but ends in _text. If you specify a 'newfield' in the config, then
the HTML-stripped text will be stored in that field. If you want to
replace the contents of an existing field with the HTML-stripped
content, then use the same field for both 'field' and 'newfield'.
HTML::Strip can leave many \xA0 characters in the text which can be
difficult to deal with. So HTMLStrip replaces all such characters
with a single whitespace.
If the new field is utf8 (according to utf8::is_utf8), then the new
field will be passed to utf8::encode().
12 changes: 12 additions & 0 deletions lib/Wubot/Reactor/IRC.pm
Expand Up @@ -117,3 +117,15 @@ sub close {
}

1;

__END__
=head1 NAME
Wubot::Reactor::IRC - public and private IRC notifications
=head1 DESCRIPTION
For more info, please see the irc.txt document in the docs directory.
33 changes: 33 additions & 0 deletions lib/Wubot/Reactor/ImageStrip.pm
Expand Up @@ -28,3 +28,36 @@ sub react {
}

1;


__END__
=head1 NAME
Wubot::Reactor::ImageStrip - strip image tags from a field
=head1 SYNOPSIS
- name: strip images from 'body' field and store results in the field body_text
plugin: ImageStrip
config:
field: body
- name: strip images from the body field in-situ
plugin: ImageStrip
config:
field: body
newfield: body
=head1 DESCRIPTION
The ImageStrip plugin attempts to remove any img or iframe tags from a
message field. The original field content is not overwritten by
default. If you do not specify a 'newfield', then the image-stripped
content will be stored in a new field that matches the original field
but ends in _text. If you specify a 'newfield' in the config, then
the image-stripped text will be stored in that field. If you want to
replace the contents of an existing field with the image-stripped
content, then use the same field for both 'field' and 'newfield'.

0 comments on commit bf2281b

Please sign in to comment.