blib/lib/Acme/RandomEmoji.pm

filter: Statementstmt 100% 41 / 41 Branchbran 100% 10 / 10 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 96.8% 62 / 64 SCAR 20.8
CC
8
Cov
100%
load_emoji
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.0
↑ Summary
1 # THIS FILE IS AUTOMATICALLY GENERATED BY author/generate.pl
2 package Acme::RandomEmoji;
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our @EXPORT_OK = qw(random_emoji);
9 1 our $VERSION = '0.01';
10 1 our $EMOJI = load_emoji();
11  
12 sub load_emoji {
13 1 ▶ my @chr;
Subroutine load_emoji: called CC=8 SCAR=20.8
Pod undocumented
14 1 ▶ while (my $line = <DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline DATA)) 966 1 967
15 966 chomp $line;
16 966 $line =~ s/^\s+//; $line =~ s/\s+$//;
17 966 ▶ next if !$line || $line =~ /^#/;
Branch: 1 branch
BranchTrueFalseTotal
if not $line or $line =~ /^#/ 118 848 966
Condition100%3/3
not $line or $line =~ /^#/
l!l&&r!l&&!r
4573848
MC/DC100%2/2
not $line or $line =~ /^#/
not $line $line =~ /^#/
Truth table100%3/3
not(A) or B
A= not $lineB= $line =~ /^#/
ABresult
1X1
011
000
18 848 $line =~ s/\s*#.*//;
19 848 $line =~ s/\s*;.*//;
20 848 ▶ if ($line !~ /\s+/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $line =~ /\s+/) { } 231 617 848
21 231 my @point;
22 231 ▶ if ($line =~ /^([0-9A-F]+)\.\.([0-9A-F]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^([0-9A-F]+)\.\.([0-9A-F]+)$/) { } 118 113 231
23 118 @point = hex($1) .. hex($2);
24 } else {
25 113 @point = (hex($line));
26 }
27 231 for my $point (@point) {
28 1958 my $chr = chr $point;
29 1958 ▶ $chr .= "\N{U+FE0F}" if $point < 256;
Branch: 1 branch
BranchTrueFalseTotal
if $point < 256 14 1944 1958
30 1958 push @chr, $chr;
31 }
32 } else {
33 617 my @item = split /\s+/, $line;
34 617 my $chr = join "", map { chr hex $_ } @item;
35 617 push @chr, $chr
36 }
37 }
38 1 close DATA;
39 1 \@chr;
40 }
41  
42 10 ▶sub random_emoji { ${ $EMOJI }[ int rand @$EMOJI ] }
Subroutine random_emoji: called CC=1 SCAR=0.0
Pod undocumented
43  
44 =encoding utf-8
45  
46 =head1 NAME
47  
48 Acme::RandomEmoji - pick an emoji randomly
49  
50 =head1 SYNOPSIS
51  
52 =for html
53 <a href="https://raw.githubusercontent.com/shoichikaji/Acme-RandomEmoji/master/author/screenshot.png"><img src="https://raw.githubusercontent.com/shoichikaji/Acme-RandomEmoji/master/author/screenshot.png" alt="screenshot"></a>
54  
55 =head1 DESCRIPTION
56  
57 Acme::RandomEmoji picks an emoji randomly.
58  
59 Emoji data is taken from:
60  
61 =over 4
62  
63 =item L<http://unicode.org/Public/emoji/latest/emoji-data.txt>
64  
65 =item L<http://unicode.org/Public/emoji/latest/emoji-sequences.txt>
66  
67 =item L<http://unicode.org/Public/emoji/latest/emoji-zwj-sequences.txt>
68  
69 =back
70  
71 =head1 SEE ALSO
72  
73 Full Emoji Data L<http://unicode.org/emoji/charts/full-emoji-list.html>
74  
75 =head1 COPYRIGHT AND LICENSE
76  
77 Copyright 2016 Shoichi Kaji <skaji@cpan.org>
78  
79 This library is free software; you can redistribute it and/or modify
80 it under the same terms as Perl itself.
81  
82 Note that this library embed emoji-data.txt, emoji-sequences.txt and emoji-zwj-sequences.txt,
83 which have their own license. Please refer to L<http://www.unicode.org/copyright.html>
84  
85 =cut
86  
87 1 1;
88  
89 __DATA__
↑ Summary