| 1 | package Riji::Model::Tag; | ||||||||||
| 2 | 9 | ▶ | use feature ':5.10'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 9 | ▶ | use Encode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 9 | ▶ | use MIME::Base32 1.301 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 9 | ▶ | use Mouse; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 9 | has name => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | isa => 'Str', | ||||||||||
| 14 | required => 1, | ||||||||||
| 15 | ); | ||||||||||
| 16 | |||||||||||
| 17 | has entries => ( | ||||||||||
| 18 | is => 'rw', | ||||||||||
| 19 | isa => 'ArrayRef[Riji::Model::Entry]', | ||||||||||
| 20 | lazy => 1, | ||||||||||
| 21 | 4 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 9 | ); | |||||||||
| 23 | |||||||||||
| 24 | has count => ( | ||||||||||
| 25 | is => 'ro', | ||||||||||
| 26 | lazy => 1, | ||||||||||
| 27 | 4 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 4 | scalar @{ shift->entries }; | |||||||||
| 29 | }, | ||||||||||
| 30 | 9 | ); | |||||||||
| 31 | |||||||||||
| 32 | has _encoded_name => ( | ||||||||||
| 33 | is => 'ro', | ||||||||||
| 34 | 4 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 35 | 4 | my $name = shift->name; | |||||||||
| 36 | 4 | ▶ | return $name unless $name =~ /[^-_a-zA-Z0-9]/ms; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 1 | 'b32.'.MIME::Base32::encode_rfc3548(encode_utf8 $name); | |||||||||
| 39 | } | ||||||||||
| 40 | 9 | ); | |||||||||
| 41 | |||||||||||
| 42 | has site_path => ( | ||||||||||
| 43 | is => 'ro', | ||||||||||
| 44 | 4 | ▶ | default => sub { '/tag/' . shift->_encoded_name . '.html' }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 45 | 9 | ); | |||||||||
| 46 | |||||||||||
| 47 | 9 | ▶ | no Mouse; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 48 | |||||||||||
| 49 | 8 | ▶ | sub normalize_tag { | ||||||||
|
Subroutine
normalize_tag: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 50 | 8 | my ($class, $tag) = @_; | |||||||||
| 51 | |||||||||||
| 52 | 8 | ▶ | if ($tag =~ s/^b32\.//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 1 | return decode_utf8 MIME::Base32::decode_rfc3548($tag); | |||||||||
| 54 | } | ||||||||||
| 55 | 7 | $tag; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 9 | 1; | |||||||||