blib/lib/Acme/CorpusScrambler.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 100% 42 / 42 CC 3 SCAR 5.6
CC
3
Cov
100%
scramble
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
↑ Summary
1 package Acme::CorpusScrambler;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Text::Greeking::zh_TW;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Acme::CorpusScrambler - An Acme way doing Lorem Ipsum.
11  
12 =head1 VERSION
13  
14 version 0.04
15  
16 =cut
17  
18 5 our $VERSION = '0.04';
19  
20 =head1 SYNOPSIS
21  
22 use Acme::CorpusScrambler;
23  
24 my $foo = Acme::CorpusScrambler->new();
25 my $text = $foo->scramble;
26  
27 =head1 FUNCTIONS
28  
29 =head2 new
30  
31 Object constructor, no parameters required.
32  
33 =cut
34  
35 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
36 3 my $class = shift;
37 3 bless {}, $class;
38 }
39  
40 =head2 feed( $keyword => $corpus )
41  
42 Feeds the $corpus to object, indexed by $keyword. The corpus is used latter as scrambling
43 material.
44  
45 =cut
46  
47 5 my %corpushash;
48 8 ▶sub feed {
Subroutine feed: called CC=1 SCAR=0.0
Pod documented
49 8 my ($self, $keyword, $corpus) = @_;
50 8 $corpushash{"$keyword"}="$corpus";
51 8 $self;
52 }
53  
54 =head2 scramble( @keyword )
55  
56 Generate a piece of lipsum text accroding to @keyword. If you didn't
57 feed any corpus before with feed() method, it will use
58 Text::Greeking::zh_TW's default corpus.
59  
60 =cut
61  
62 6 ▶sub scramble {
Subroutine scramble: called CC=3 SCAR=11.0
Pod documented
63 6 my ($self, @keyword) = @_;
64  
65 6 my $g = Text::Greeking::zh_TW->new;
66 6 $g->paragraphs(3,15);
67 6 $g->sentences(2,10);
68  
69 6 ▶ if (@keyword) {
Branch: 1 branch
BranchTrueFalseTotal
if (@keyword) { } 3 3 6
70 3 my $newcorpus = join("\n\n", @corpushash{ grep { exists $corpushash{$_} } @keyword });
71 3 ▶ if ($newcorpus) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newcorpus) 2 1 3
72 2 $g->add_source($newcorpus);
73 2 return $g->generate;
74 }
75 1 return ""
76 }else {
77 3 return $g->generate;
78 }
79 }
80  
81 =head1 AUTHOR
82  
83 Kang-min Liu <gugod at gugod.org>
84  
85 shelling <navyblueshellingford at gmail.com>
86  
87 =head1 BUGS
88  
89 Please report any bugs or feature requests to C<shelling at cpan.org> or C<gugod at gugod.org>
90  
91 =head1 SUPPORT
92  
93 You can find documentation for this module with the perldoc command.
94  
95 perldoc Acme::CorpusScrambler
96  
97 You can also look for information at:
98  
99 =over 4
100  
101 =item * AnnoCPAN: Annotated CPAN documentation
102  
103 L<http://annocpan.org/dist/Acme-CorpusScrambler>
104  
105 =item * CPAN Ratings
106  
107 L<http://cpanratings.perl.org/d/Acme-CorpusScrambler>
108  
109 =item * RT: CPAN's request tracker
110  
111 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Acme-CorpusScrambler>
112  
113 =item * Search CPAN
114  
115 L<http://search.cpan.org/dist/Acme-CorpusScrambler>
116  
117 =back
118  
119 =head1 COPYRIGHT & LICENSE
120  
121 Copyright @ 2007-2008 Kang-min Liu, shelling, all rights reserved.
122  
123 This program is free software; you can redistribute it and/or modify it
124 under the same terms as Perl itself.
125  
126 =cut
127  
128 5 1;
↑ Summary