| 1 | package Inline::WebChat; | ||||||||||
| 2 | 1 | $VERSION = '0.62'; | |||||||||
| 3 | 1 | require Inline; | |||||||||
| 4 | 1 | @ISA = qw(Inline); | |||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use WWW::Chat::Processor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | # Register as in an Inline Language Support Module (ILSM) | ||||||||||
| 11 | 0 | ▶ | sub register { | ||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 12 | return { | ||||||||||
| 13 | 0 | language => 'WebChat', | |||||||||
| 14 | aliases => ['webchat'], | ||||||||||
| 15 | type => 'interpreted', | ||||||||||
| 16 | suffix => 'wc', | ||||||||||
| 17 | }; | ||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | # print out a warning | ||||||||||
| 21 | 0 | ▶ | sub usage_config { | ||||||||
|
Subroutine
usage_config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 22 | 0 | my $key = shift; | |||||||||
| 23 | 0 | "'$key' is not a valid config option for Inline::WebChat\n"; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | # validate the config options | ||||||||||
| 28 | 1 | ▶ | sub validate { | ||||||||
|
Subroutine
validate: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||
| 29 | 1 | my $o = shift; | |||||||||
| 30 | 1 | ▶ | while (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | my ($key, $value) = splice @_, 0, 2; | |||||||||
| 32 | 0 | croak usage_config($key); | |||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | # parse and process WebChat stuff | ||||||||||
| 37 | 1 | ▶ | sub build { | ||||||||
|
Subroutine
build: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||
| 38 | 1 | my $o = shift; | |||||||||
| 39 | |||||||||||
| 40 | # parse the code | ||||||||||
| 41 | 1 | my $code = WWW::Chat::Processor::parse($o->{API}{code}); | |||||||||
| 42 | 1 | ▶ | croak "Foo build failed:\n$@" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | |||||||||||
| 44 | # find the path | ||||||||||
| 45 | 1 | my $path = "$o->{API}{install_lib}/auto/$o->{API}{modpname}"; | |||||||||
| 46 | 1 | my $obj = $o->{API}{location}; | |||||||||
| 47 | |||||||||||
| 48 | # check to see it's valid and if not, make a new path | ||||||||||
| 49 | 1 | ▶ | $o->mkpath($path) unless -d $path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | # and dump the code ... | ||||||||||
| 52 | 1 | ▶ | open FOO_OBJ, "> $obj" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | or croak "Can't open $obj for output\n$!"; | ||||||||||
| 54 | 1 | print FOO_OBJ $code; | |||||||||
| 55 | 1 | close \*FOO_OBJ; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | # now load it back up again | ||||||||||
| 60 | 1 | ▶ | sub load { | ||||||||
|
Subroutine
load: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 61 | 1 | my $o = shift; | |||||||||
| 62 | |||||||||||
| 63 | # find out where it is | ||||||||||
| 64 | 1 | my $obj = $o->{API}{location}; | |||||||||
| 65 | |||||||||||
| 66 | # read it in | ||||||||||
| 67 | 1 | ▶ | open FOO_OBJ, "< $obj" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | or croak "Can't open $obj for output\n$!"; | ||||||||||
| 69 | 1 | my $code = join '', <FOO_OBJ>; | |||||||||
| 70 | 1 | close \*FOO_OBJ; | |||||||||
| 71 | |||||||||||
| 72 | # and run the code :) | ||||||||||
| 73 | 1 | ▶ | eval "package $o->{API}{pkg};\n$code"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 74 | 1 | ▶ | croak "Unable to load WebChat module $obj:\n$@" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub info { | ||||||||
|
Subroutine
info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | 0 | my $o = shift; | |||||||||
| 79 | 0 | my $text = <<'END'; | |||||||||
| 80 | This allows you to embed WebChat script in your | ||||||||||
| 81 | Perl scripts easily. WebChat is an Expect type | ||||||||||
| 82 | language that makes it easy to fetch and | ||||||||||
| 83 | manipulate web pages and their forms. See the | ||||||||||
| 84 | webchatpp or WWW::Chat man pages for more details | ||||||||||
| 85 | END | ||||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 1 | 1; | |||||||||
| 89 | |||||||||||
| 90 | __END__ | ||||||||||