| 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
| |||||||||||||||||||||||||||||
| 15 | 966 | chomp $line; | |||||||||||||||||||||||||||
| 16 | 966 | $line =~ s/^\s+//; $line =~ s/\s+$//; | |||||||||||||||||||||||||||
| 17 | 966 | ▶ | next if !$line || $line =~ /^#/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $line or $line =~ /^#/
MC/DC100%2/2
not $line or $line =~ /^#/
not $line
$line =~ /^#/
Truth table100%3/3
not(A) or B
A= not $lineB= $line =~ /^#/
| |||||||||||||||||||||||||||||
| 18 | 848 | $line =~ s/\s*#.*//; | |||||||||||||||||||||||||||
| 19 | 848 | $line =~ s/\s*;.*//; | |||||||||||||||||||||||||||
| 20 | 848 | ▶ | if ($line !~ /\s+/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 231 | my @point; | |||||||||||||||||||||||||||
| 22 | 231 | ▶ | if ($line =~ /^([0-9A-F]+)\.\.([0-9A-F]+)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||