File Coverage

blib/lib/Crypt/Role/GreekAlphabet.pm
Criterion Covered Total %
statement 37 37 100.0
branch n/a
condition 1 3 33.3
subroutine 12 12 100.0
pod 2 2 100.0
total 52 54 96.3


line stmt bran cond sub pod time code
1 1     1   827 use 5.008;
  1         4  
  1         41  
2 1     1   5 use strict;
  1         2  
  1         31  
3 1     1   6 use utf8;
  1         2  
  1         9  
4 1     1   23 use warnings;
  1         2  
  1         64  
5              
6             package Crypt::Role::GreekAlphabet;
7              
8             our $AUTHORITY = 'cpan:TOBYINK';
9             our $VERSION = '0.003';
10              
11 1     1   5 use Moo::Role;
  1         1  
  1         12  
12 1     1   346 use Const::Fast;
  1         2  
  1         8  
13 1     1   81 use Type::Params;
  1         2  
  1         10  
14 1     1   337 use Types::Standard qw(Str);
  1         2  
  1         29  
15 1     1   466 use namespace::sweep;
  1         2  
  1         10  
16              
17             const my $alphabet => [
18             qw( Α Î’ Γ Δ Ε Ζ Η Θ Ι Κ Λ Îœ Ν Ξ Ο Π Ρ Σ Τ Î¥ Φ Χ Ψ Ω )
19             ];
20              
21 2     2 1 15 sub alphabet { $alphabet }
22              
23             my $_check_preprocess;
24             sub preprocess
25             {
26 1   33 1 1 8 $_check_preprocess ||= compile(Str);
27            
28 1         738 my $self = shift;
29 1         4 my ($input) = $_check_preprocess->(@_);
30            
31 1         19 my $str = uc $input;
32 1     1   337 $str =~ tr/ΆΈΉΊΌΎΏΪΫ/ΑΕΗΙΟΥΩΙΥ/;
  1         2  
  1         16  
  1         21318  
33 1         8 $str;
34             }
35              
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding utf-8
43              
44             =for stopwords Unicode codepoints
45              
46             =head1 NAME
47              
48             Crypt::Role::GreekAlphabet - twenty-four letter Greek alphabet for classic cryptography
49              
50             =head1 DESCRIPTION
51              
52             This role provides a twenty-four letter alphabet for use in classic
53             cryptography. The letters are all uppercase.
54              
55             =head2 Object Methods
56              
57             =over
58              
59             =item C<< alphabet >>
60              
61             Returns the alphabet as an arrayref of letters.
62              
63             =item C<< preprocess($str) >>
64              
65             Perform pre-encipher processing on a string. The string is uppercased.
66             Common Unicode codepoints corresponding to Greek letters with diacritics
67             are replaced with the closest match from the alphabet.
68              
69             Punctuation characters, spaces, etc are I<not> removed from the string.
70             It is the choice of the cipher whether to, say, pass them through
71             unchanged, or strip them from the ciphertext.
72              
73             =back
74              
75             =head1 BUGS
76              
77             Please report any bugs to
78             L<http://rt.cpan.org/Dist/Display.html?Queue=Crypt-Polybius>.
79              
80             =head1 SEE ALSO
81              
82             L<Crypt::Polybius::Greek>.
83              
84             =head1 AUTHOR
85              
86             Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
87              
88             =head1 COPYRIGHT AND LICENCE
89              
90             This software is copyright (c) 2014 by Toby Inkster.
91              
92             This is free software; you can redistribute it and/or modify it under
93             the same terms as the Perl 5 programming language system itself.
94              
95             =head1 DISCLAIMER OF WARRANTIES
96              
97             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
98             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
99             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
100