| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## WebSocket Client & Server - ~/lib/WebSocket/Version.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2021/09/24 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2021/09/24 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## You can use, copy, modify and redistribute this package and associated | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## files under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | package WebSocket::Version; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use warnings::register; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | ▶ | use vars qw( $VERSION $IETF_VERSIONS ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | use Module::Generic::Number (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | '""' => \&as_string, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | '0+' => \&numify, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | '-' => sub { return( shift->_compute( @_, { op => '-', return_object => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | '+' => sub { return( shift->_compute( @_, { op => '+', return_object => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | '*' => sub { return( shift->_compute( @_, { op => '*', return_object => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | '/' => sub { return( shift->_compute( @_, { op => '/', return_object => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | '%' => sub { return( shift->_compute( @_, { op => '%', return_object => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | '<' => sub { return( shift->_compute( @_, { op => '<', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | '<=' => sub { return( shift->_compute( @_, { op => '<=', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | '>' => sub { return( shift->_compute( @_, { op => '>', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | '>=' => sub { return( shift->_compute( @_, { op => '>=', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | '<=>' => sub { return( shift->_compute( @_, { op => '<=>', return_object => 0 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | '==' => sub { return( shift->_compute( @_, { op => '==', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | '!=' => sub { return( shift->_compute( @_, { op => '!=', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | ▶ | 'eq' => sub { return( shift->_compute( @_, { op => 'eq', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | 'ne' => sub { return( shift->_compute( @_, { op => 'ne', boolean => 1 }) ); }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 8 | 'cmp' => \&_compare, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 'bool' => \&as_string, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | fallback => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | our $IETF_VERSIONS = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'draft-ietf-hybi-17' => { serial => 17, issued => '2011-09-30', expires => '2012-04-02', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-17', version => 13, offset => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'draft-ietf-hybi-16' => { serial => 16, issued => '2011-09-27', expires => '2012-03-30', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-16', version => 13, offset => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'draft-ietf-hybi-15' => { serial => 15, issued => '2011-09-17', expires => '2012-03-20', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-15', version => 13, offset => 2 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 'draft-ietf-hybi-14' => { serial => 14, issued => '2011-09-08', expires => '2012-03-11', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-14', version => 13, offset => 3 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'draft-ietf-hybi-13' => { serial => 13, issued => '2011-08-31', expires => '2012-03-03', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-13', version => 13, offset => 4 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'draft-ietf-hybi-12' => { serial => 12, issued => '2011-08-24', expires => '2012-02-25', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-12', version => 8, offset => 5 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # "Although drafts -09, -10 and -11 were published, as they were mostly comprised of editorial changes and clarifications and not changes to the wire protocol, values 9, 10 and 11 were not used as valid values for Sec-WebSocket-Version." | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # <https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-11> section 5.1, page 30 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'draft-ietf-hybi-11' => { serial => 11, issued => '2011-08-23', expires => '2012-02-24', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-11', version => 8, offset => 6 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'draft-ietf-hybi-10' => { serial => 10, issued => '2011-07-11', expires => '2012-01-12', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-10', version => 8, offset => 7 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'draft-ietf-hybi-09' => { serial => 9, issued => '2011-06-13', expires => '2011-12-15', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-09', version => 8, offset => 8 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'draft-ietf-hybi-08' => { serial => 8, issued => '2011-06-07', expires => '2011-12-09', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-08', version => 8, offset => 9 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 'draft-ietf-hybi-07' => { serial => 7, issued => '2011-04-22', expires => '2011-10-24', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-07', version => 7, offset => 10 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 'draft-ietf-hybi-06' => { serial => 6, issued => '2011-02-25', expires => '2011-08-29', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-06', version => 6, offset => 11 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'draft-ietf-hybi-05' => { serial => 5, issued => '2011-02-08', expires => '2011-08-12', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-05', version => 5, offset => 12 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 'draft-ietf-hybi-04' => { serial => 4, issued => '2011-01-11', expires => '2011-07-15', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-04', version => 4, offset => 13 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 'draft-ietf-hybi-03' => { serial => 3, issued => '2010-10-17', expires => '2011-04-20', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-03', version => 2, offset => 14 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'draft-ietf-hybi-02' => { serial => 2, issued => '2010-09-24', expires => '2011-03-28', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-02', version => 2, offset => 15 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # v8 of the rfc says hybi0 and hybi are versions 0 and 1 respectively | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # <https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-08#section-11.12> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 'draft-ietf-hybi-01' => { serial => 1, issued => '2010-08-31', expires => '2011-03-04', status => 'draft', type => 'hybi', draft => 'draft-ietf-hybi-01', version => 1, offset => 16 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 'draft-ietf-hybi-00' => { serial => 0, issued => '2010-05-23', expires => '2010-11-24', status => 'obsolete', type => 'hybi', draft => 'draft-ietf-hybi-00', version => 0, offset => 17 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 'draft-hixie-76' => { serial => -1, issued => '2010-05-06', expires => '2010-11-08', status => 'obsolete', type => 'hixie', draft => 'draft-hixie-76', version => undef, offset => 18 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 'draft-hixie-75' => { serial => -2, issued => '2010-02-04', expires => '2010-08-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-75', version => undef, offset => 19 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 'draft-hixie-74' => { serial => -3, issued => '2010-02-02', expires => '2010-08-06', status => 'draft', type => 'hixie', draft => 'draft-hixie-74', version => undef, offset => 20 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 'draft-hixie-73' => { serial => -4, issued => '2010-02-02', expires => '2010-08-06', status => 'draft', type => 'hixie', draft => 'draft-hixie-73', version => undef, offset => 21 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 'draft-hixie-72' => { serial => -5, issued => '2010-02-01', expires => '2010-08-05', status => 'draft', type => 'hixie', draft => 'draft-hixie-72', version => undef, offset => 22 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 'draft-hixie-71' => { serial => -6, issued => '2010-02-01', expires => '2010-08-05', status => 'draft', type => 'hixie', draft => 'draft-hixie-71', version => undef, offset => 23 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 'draft-hixie-70' => { serial => -7, issued => '2010-01-31', expires => '2010-08-04', status => 'draft', type => 'hixie', draft => 'draft-hixie-70', version => undef, offset => 24 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'draft-hixie-69' => { serial => -8, issued => '2010-01-30', expires => '2010-08-03', status => 'draft', type => 'hixie', draft => 'draft-hixie-69', version => undef, offset => 25 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'draft-hixie-68' => { serial => -9, issued => '2009-12-16', expires => '2010-06-19', status => 'draft', type => 'hixie', draft => 'draft-hixie-68', version => undef, offset => 26 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'draft-hixie-67' => { serial => -10, issued => '2009-12-16', expires => '2010-06-19', status => 'draft', type => 'hixie', draft => 'draft-hixie-67', version => undef, offset => 27 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'draft-hixie-66' => { serial => -11, issued => '2009-12-09', expires => '2010-06-12', status => 'draft', type => 'hixie', draft => 'draft-hixie-66', version => undef, offset => 28 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'draft-hixie-65' => { serial => -12, issued => '2009-12-09', expires => '2010-06-12', status => 'draft', type => 'hixie', draft => 'draft-hixie-65', version => undef, offset => 29 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'draft-hixie-64' => { serial => -13, issued => '2009-12-07', expires => '2010-06-10', status => 'draft', type => 'hixie', draft => 'draft-hixie-64', version => undef, offset => 30 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'draft-hixie-63' => { serial => -14, issued => '2009-12-07', expires => '2010-06-10', status => 'draft', type => 'hixie', draft => 'draft-hixie-63', version => undef, offset => 31 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'draft-hixie-62' => { serial => -15, issued => '2009-12-07', expires => '2010-06-10', status => 'draft', type => 'hixie', draft => 'draft-hixie-62', version => undef, offset => 32 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 'draft-hixie-61' => { serial => -16, issued => '2009-12-04', expires => '2010-06-07', status => 'draft', type => 'hixie', draft => 'draft-hixie-61', version => undef, offset => 33 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 'draft-hixie-60' => { serial => -17, issued => '2009-12-04', expires => '2010-06-07', status => 'draft', type => 'hixie', draft => 'draft-hixie-60', version => undef, offset => 34 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 'draft-hixie-59' => { serial => -18, issued => '2009-12-04', expires => '2010-06-07', status => 'draft', type => 'hixie', draft => 'draft-hixie-59', version => undef, offset => 35 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'draft-hixie-58' => { serial => -19, issued => '2009-12-03', expires => '2010-06-06', status => 'draft', type => 'hixie', draft => 'draft-hixie-58', version => undef, offset => 36 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 'draft-hixie-57' => { serial => -20, issued => '2009-12-03', expires => '2010-06-06', status => 'draft', type => 'hixie', draft => 'draft-hixie-57', version => undef, offset => 37 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 'draft-hixie-56' => { serial => -21, issued => '2009-12-03', expires => '2010-06-06', status => 'draft', type => 'hixie', draft => 'draft-hixie-56', version => undef, offset => 38 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 'draft-hixie-55' => { serial => -22, issued => '2009-11-02', expires => '2010-05-06', status => 'draft', type => 'hixie', draft => 'draft-hixie-55', version => undef, offset => 39 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 'draft-hixie-54' => { serial => -23, issued => '2009-10-23', expires => '2010-04-26', status => 'draft', type => 'hixie', draft => 'draft-hixie-54', version => undef, offset => 40 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 'draft-hixie-53' => { serial => -24, issued => '2009-10-23', expires => '2010-04-26', status => 'draft', type => 'hixie', draft => 'draft-hixie-53', version => undef, offset => 41 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'draft-hixie-52' => { serial => -25, issued => '2009-10-23', expires => '2010-04-26', status => 'draft', type => 'hixie', draft => 'draft-hixie-52', version => undef, offset => 42 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 'draft-hixie-51' => { serial => -26, issued => '2009-10-21', expires => '2010-04-24', status => 'draft', type => 'hixie', draft => 'draft-hixie-51', version => undef, offset => 43 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 'draft-hixie-50' => { serial => -27, issued => '2009-10-21', expires => '2010-04-24', status => 'draft', type => 'hixie', draft => 'draft-hixie-50', version => undef, offset => 44 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 'draft-hixie-49' => { serial => -28, issued => '2009-10-17', expires => '2010-04-20', status => 'draft', type => 'hixie', draft => 'draft-hixie-49', version => undef, offset => 45 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 'draft-hixie-48' => { serial => -29, issued => '2009-10-13', expires => '2010-04-16', status => 'draft', type => 'hixie', draft => 'draft-hixie-48', version => undef, offset => 46 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 'draft-hixie-47' => { serial => -30, issued => '2009-10-13', expires => '2010-04-16', status => 'draft', type => 'hixie', draft => 'draft-hixie-47', version => undef, offset => 47 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 'draft-hixie-46' => { serial => -31, issued => '2009-10-06', expires => '2010-04-09', status => 'draft', type => 'hixie', draft => 'draft-hixie-46', version => undef, offset => 48 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 'draft-hixie-45' => { serial => -32, issued => '2009-10-05', expires => '2010-04-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-45', version => undef, offset => 49 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 'draft-hixie-44' => { serial => -33, issued => '2009-09-28', expires => '2010-04-01', status => 'draft', type => 'hixie', draft => 'draft-hixie-44', version => undef, offset => 50 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 'draft-hixie-43' => { serial => -34, issued => '2009-09-21', expires => '2010-03-25', status => 'draft', type => 'hixie', draft => 'draft-hixie-43', version => undef, offset => 51 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 'draft-hixie-42' => { serial => -35, issued => '2009-09-17', expires => '2010-03-21', status => 'draft', type => 'hixie', draft => 'draft-hixie-42', version => undef, offset => 52 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 'draft-hixie-41' => { serial => -36, issued => '2009-09-17', expires => '2010-03-21', status => 'draft', type => 'hixie', draft => 'draft-hixie-41', version => undef, offset => 53 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 'draft-hixie-40' => { serial => -37, issued => '2009-09-04', expires => '2010-03-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-40', version => undef, offset => 54 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 'draft-hixie-39' => { serial => -38, issued => '2009-09-04', expires => '2010-03-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-39', version => undef, offset => 55 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 'draft-hixie-36' => { serial => -39, issued => '2009-09-02', expires => '2010-03-06', status => 'draft', type => 'hixie', draft => 'draft-hixie-36', version => undef, offset => 56 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 'draft-hixie-35' => { serial => -40, issued => '2009-08-16', expires => '2010-02-17', status => 'draft', type => 'hixie', draft => 'draft-hixie-35', version => undef, offset => 57 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 'draft-hixie-34' => { serial => -41, issued => '2009-08-15', expires => '2010-02-16', status => 'draft', type => 'hixie', draft => 'draft-hixie-34', version => undef, offset => 58 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 'draft-hixie-33' => { serial => -42, issued => '2009-08-14', expires => '2010-02-15', status => 'draft', type => 'hixie', draft => 'draft-hixie-33', version => undef, offset => 59 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 'draft-hixie-32' => { serial => -43, issued => '2009-08-14', expires => '2010-02-15', status => 'draft', type => 'hixie', draft => 'draft-hixie-32', version => undef, offset => 60 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 'draft-hixie-31' => { serial => -44, issued => '2009-08-07', expires => '2010-02-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-31', version => undef, offset => 61 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 'draft-hixie-30' => { serial => -45, issued => '2009-08-07', expires => '2010-02-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-30', version => undef, offset => 62 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 'draft-hixie-29' => { serial => -46, issued => '2009-08-04', expires => '2010-02-05', status => 'draft', type => 'hixie', draft => 'draft-hixie-29', version => undef, offset => 63 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 'draft-hixie-28' => { serial => -47, issued => '2009-07-30', expires => '2010-01-31', status => 'draft', type => 'hixie', draft => 'draft-hixie-28', version => undef, offset => 64 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 'draft-hixie-27' => { serial => -48, issued => '2009-07-29', expires => '2010-01-30', status => 'draft', type => 'hixie', draft => 'draft-hixie-27', version => undef, offset => 65 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 'draft-hixie-26' => { serial => -49, issued => '2009-07-28', expires => '2010-01-29', status => 'draft', type => 'hixie', draft => 'draft-hixie-26', version => undef, offset => 66 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 'draft-hixie-25' => { serial => -50, issued => '2009-07-28', expires => '2010-01-29', status => 'draft', type => 'hixie', draft => 'draft-hixie-25', version => undef, offset => 67 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 'draft-hixie-24' => { serial => -51, issued => '2009-07-28', expires => '2010-01-29', status => 'draft', type => 'hixie', draft => 'draft-hixie-24', version => undef, offset => 68 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 'draft-hixie-23' => { serial => -52, issued => '2009-07-27', expires => '2010-01-28', status => 'draft', type => 'hixie', draft => 'draft-hixie-23', version => undef, offset => 69 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 'draft-hixie-22' => { serial => -53, issued => '2009-07-13', expires => '2010-01-14', status => 'draft', type => 'hixie', draft => 'draft-hixie-22', version => undef, offset => 70 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 'draft-hixie-21' => { serial => -54, issued => '2009-07-08', expires => '2010-01-09', status => 'draft', type => 'hixie', draft => 'draft-hixie-21', version => undef, offset => 71 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 'draft-hixie-20' => { serial => -55, issued => '2009-07-08', expires => '2010-01-09', status => 'draft', type => 'hixie', draft => 'draft-hixie-20', version => undef, offset => 72 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 'draft-hixie-19' => { serial => -56, issued => '2009-07-07', expires => '2010-01-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-19', version => undef, offset => 73 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 'draft-hixie-18' => { serial => -57, issued => '2009-07-07', expires => '2010-01-08', status => 'draft', type => 'hixie', draft => 'draft-hixie-18', version => undef, offset => 74 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 'draft-hixie-17' => { serial => -58, issued => '2009-06-16', expires => '2009-12-18', status => 'draft', type => 'hixie', draft => 'draft-hixie-17', version => undef, offset => 75 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 'draft-hixie-16' => { serial => -59, issued => '2009-06-05', expires => '2009-12-07', status => 'draft', type => 'hixie', draft => 'draft-hixie-16', version => undef, offset => 76 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 'draft-hixie-15' => { serial => -60, issued => '2009-06-05', expires => '2009-12-07', status => 'draft', type => 'hixie', draft => 'draft-hixie-15', version => undef, offset => 77 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 'draft-hixie-13' => { serial => -61, issued => '2009-06-01', expires => '2009-12-01', status => 'draft', type => 'hixie', draft => 'draft-hixie-13', version => undef, offset => 78 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 'draft-hixie-12' => { serial => -62, issued => '2009-05-30', expires => '2009-12-01', status => 'draft', type => 'hixie', draft => 'draft-hixie-12', version => undef, offset => 79 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'draft-hixie-11' => { serial => -63, issued => '2009-04-24', expires => '2009-10-26', status => 'draft', type => 'hixie', draft => 'draft-hixie-11', version => undef, offset => 80 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 'draft-hixie-10' => { serial => -64, issued => '2009-04-24', expires => '2009-10-26', status => 'draft', type => 'hixie', draft => 'draft-hixie-10', version => undef, offset => 81 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 'draft-hixie-07' => { serial => -65, issued => '2009-03-23', expires => '2009-09-24', status => 'draft', type => 'hixie', draft => 'draft-hixie-07', version => undef, offset => 82 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 'draft-hixie-06' => { serial => -66, issued => '2009-03-23', expires => '2009-09-24', status => 'draft', type => 'hixie', draft => 'draft-hixie-06', version => undef, offset => 83 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 'draft-hixie-05' => { serial => -67, issued => '2009-03-23', expires => '2009-09-24', status => 'draft', type => 'hixie', draft => 'draft-hixie-05', version => undef, offset => 84 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 'draft-hixie-03' => { serial => -68, issued => '2009-02-25', expires => '2009-08-29', status => 'draft', type => 'hixie', draft => 'draft-hixie-03', version => undef, offset => 85 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 'draft-hixie-02' => { serial => -69, issued => '2009-02-17', expires => '2009-08-21', status => 'draft', type => 'hixie', draft => 'draft-hixie-02', version => undef, offset => 86 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 'draft-hixie-01' => { serial => -70, issued => '2009-01-09', expires => '2009-07-13', status => 'draft', type => 'hixie', draft => 'draft-hixie-01', version => undef, offset => 87 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 'draft-hixie-00' => { serial => -71, issued => '2009-01-09', expires => '2009-07-13', status => 'draft', type => 'hixie', draft => 'draft-hixie-00', version => undef, offset => 88 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 8 | our $VERSION = 'v0.1.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 100 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=12 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 100 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 100 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 100 | ▶ | return( $self->error( "No version numeric or string was provided." ) ) if( !defined( $this ) || !length( $this ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $this and length $this
MC/DC0%0/2
defined $this and length $this
defined $this
length $this
Truth table33%1/3
A and B
A= defined $thisB= length $this
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 100 | ▶ | $self->{_exception_class} = 'WebSocket::Exception' unless( defined( $self->{_exception_class} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 100 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 100 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 100 | my $dict; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 100 | ▶ | if( $this =~ /^\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 19 | ▶ | $dict = $self->get_dictionary( version => $this ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->get_dictionary('version', $this) || (return $self->pass_error)
MC/DC0%0/1
$self->get_dictionary('version', $this) || (return $self->pass_error)
$self->get_dictionary('version', $this)
Truth table50%1/2
A
A= $self->get_dictionary('version', $this)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 19 | ▶ | return( $self->error({code => 404, message => "No data found for version \"$this\"." }) ) if( !scalar( keys( %$dict ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ▶ | elsif( ref( $this ) eq 'HASH' && exists( $this->{serial} ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $this eq "HASH" and exists $this->{"serial"}
MC/DC50%1/2
ref $this eq "HASH" and exists $this->{"serial"}
ref $this eq "HASH"
exists $this->{"serial"}
Truth table66%2/3
A and B
A= ref $this eq "HASH"B= exists $this->{"serial"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 7 | $dict = $this; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 74 | ▶ | $dict = $self->get_dictionary( draft => $this ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->get_dictionary('draft', $this) || (return $self->pass_error)
MC/DC0%0/1
$self->get_dictionary('draft', $this) || (return $self->pass_error)
$self->get_dictionary('draft', $this)
Truth table50%1/2
A
A= $self->get_dictionary('draft', $this)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 74 | ▶ | return( $self->error({code => 404, message => "No data found for draft \"$this\"." }) ) if( !scalar( keys( %$dict ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 100 | my @k = keys( %$dict ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 100 | @$self{ @k } = @$dict{ @k }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 100 | $self->{revision} = int( $self->draft->match( qr/\-(\d+)$/ )->capture->first ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 100 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 165 | ▶ | sub as_string { return( shift->{version} ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 102 | ▶ | sub draft { return( shift->_set_get_scalar_as_object( 'draft', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
draft: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | ▶ | sub expires { return( shift->_set_get_datetime( 'expires', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expires: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | sub get_dictionary | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 98 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_dictionary: called CC=23 SCAR=37.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 98 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 98 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 98 | ▶ | return( $self->error( "No argument provided. Use either 'version' or 'draft'" ) ) if( !length( $opts->{version} ) && !length( $opts->{draft} ) && !length( $opts->{serial} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
length $opts->{"version"} or length $opts->{"draft"} or length $opts->{"serial"}
length $opts->{"version"} or length $opts->{"draft"}
MC/DC0%0/3
length $opts->{"version"} or length $opts->{"draft"} or length $opts->{"serial"}
length $opts->{"version"}
length $opts->{"draft"}
length $opts->{"serial"}
Truth table75%3/4
A or B or C
A= length $opts->{"version"}B= length $opts->{"draft"}C= length $opts->{"serial"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 98 | ▶ | if( exists( $opts->{version} ) && length( $opts->{version} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
exists $opts->{"version"} and length $opts->{"version"}
MC/DC50%1/2
exists $opts->{"version"} and length $opts->{"version"}
exists $opts->{"version"}
length $opts->{"version"}
Truth table66%2/3
A and B
A= exists $opts->{"version"}B= length $opts->{"version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 19 | ▶ | return( $self->error( "version option value provided is not an integer." ) ) if( $opts->{version} !~ /^\d+$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 19 | ▶ | for( my $i = 0; $i < scalar( @$IETF_VERSIONS ); $i += 2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 76 | my $dict = $IETF_VERSIONS->[ $i + 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 76 | ▶ | next if( !exists( $dict->{version} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 76 | ▶ | if( $dict->{version} == $opts->{version} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # Return a copy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 19 | return( { %$dict } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ▶ | elsif( exists( $opts->{draft} ) && length( $opts->{draft} ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $opts->{"draft"} and length $opts->{"draft"}
MC/DC50%1/2
exists $opts->{"draft"} and length $opts->{"draft"}
exists $opts->{"draft"}
length $opts->{"draft"}
Truth table66%2/3
A and B
A= exists $opts->{"draft"}B= length $opts->{"draft"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 74 | ▶ | return( $self->error( "draft option value contains illegal characters." ) ) if( $opts->{draft} !~ /^[\w\-]+$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 74 | my $draft = lc( $opts->{draft} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 74 | ▶ | for( my $i = 0; $i < scalar( @$IETF_VERSIONS ); $i += 2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 233 | ▶ | if( $IETF_VERSIONS->[$i] eq $draft ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # Return a copy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 74 | return( { %{$IETF_VERSIONS->[ $i + 1 ]} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ▶ | elsif( $opts->{type} && $opts->{revision} ) | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"type"} and $opts->{"revision"}
MC/DC0%0/2
$opts->{"type"} and $opts->{"revision"}
$opts->{"type"}
$opts->{"revision"}
Truth table33%1/3
A and B
A= $opts->{"type"}B= $opts->{"revision"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | return( $self->error( "Unknow draft type \"$opts->{type}\"." ) ) if( $opts->{type} !~ /^(hixie|hybi)$/i ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | my $draft = lc( $opts->{type} ) eq 'hybi' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ? sprintf( 'draft-ietf-hybi-%02d', $opts->{revision} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | : sprintf( 'draft-hixie-%02d', $opts->{revision} ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return( $self->get_dictionary( draft => $draft ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | elsif( $opts->{serial} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | ▶ | return( $self->error( "Serial option provided is not an integer." ) ) if( $opts->{serial} !~ /^\d+$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | ▶ | for( my $i = 0; $i < scalar( @$IETF_VERSIONS ); $i += 2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 37 | my $dict = $IETF_VERSIONS->[ $i + 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 37 | ▶ | if( $dict->{serial} == $opts->{serial} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 5 | return( { %$dict } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return( $self->error( "Unknown arguments: '", join( "', '", @_ ), "'" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | sub issued { return( shift->_set_get_datetime( 'issued', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
issued: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | sub new_from_request | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_from_request: called CC=25 SCAR=34.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 8 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 8 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 8 | ▶ | my $req = shift( @_ ) || return( $self->error( "No WebSocket::Request object was provided." ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return $self->error('No WebSocket::Request object was provided.'))
MC/DC0%0/1
shift @_ || (return $self->error('No WebSocket::Request object was provided.'))
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 8 | ▶ | return( $self->error( "Object provided (", overload::StrVal( $req ), ") is not a WebSocket::Request object." ) ) if( !$self->_is_a( $req, 'WebSocket::Request' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 8 | ▶ | my $h = $req->headers || return( $self->error( "Unable to find the WebSocket::Headers object." ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$req->headers || (return $self->error('Unable to find the WebSocket::Headers object.'))
MC/DC0%0/1
$req->headers || (return $self->error('Unable to find the WebSocket::Headers object.'))
$req->headers
Truth table50%1/2
A
A= $req->headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | ▶ | unless( ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 8 | $self = bless( {} => $class )->SUPER::init( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 8 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # From version 4 onward | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 8 | ▶ | if( $h->header( 'Sec-WebSocket-Version' )->length || | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$h->header("Sec-WebSocket-Version")->length or $h->header("Sec-WebSocket-Key")->length
MC/DC50%1/2
$h->header("Sec-WebSocket-Version")->length or $h->header("Sec-WebSocket-Key")->length
$h->header("Sec-WebSocket-Version")->length
$h->header("Sec-WebSocket-Key")->length
Truth table66%2/3
A or B
A= $h->header("Sec-WebSocket-Version")->lengthB= $h->header("Sec-WebSocket-Key")->length
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | $h->header( 'Sec-WebSocket-Key' )->length ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | ▶ | if( $h->header( 'Sec-WebSocket-Version' )->length && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$h->header("Sec-WebSocket-Version")->length and $h->header("Sec-WebSocket-Version")->match(qr/^\d{1,2}$/)
MC/DC0%0/2
$h->header("Sec-WebSocket-Version")->length and $h->header("Sec-WebSocket-Version")->match(qr/^\d{1,2}$/)
$h->header("Sec-WebSocket-Version")->length
$h->header("Sec-WebSocket-Version")->match(qr/^\d{1,2}$/)
Truth table33%1/3
A and B
A= $h->header("Sec-WebSocket-Version")->lengthB= $h->header("Sec-WebSocket-Version")->match(qr/^\d{1,2}$/)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | $h->header( 'Sec-WebSocket-Version' )->match( qr/^\d{1,2}$/ ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | $new = $self->new( $h->header( 'Sec-WebSocket-Version' )->scalar, debug => $self->debug ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->new($h->header('Sec-WebSocket-Version')->scalar, 'debug', $self->debug) || (return $self->pass_error)
MC/DC0%0/1
$self->new($h->header('Sec-WebSocket-Version')->scalar, 'debug', $self->debug) || (return $self->pass_error)
$self->new($h->header('Sec-WebSocket-Version')->scalar, 'debug', $self->debug)
Truth table50%1/2
A
A= $self->new($h->header('Sec-WebSocket-Version')->scalar, 'debug', $self->debug)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # Version 10 or lower; From version 11, it uses 'Origin' only; but from version 0 to 3, it uses also Origin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | elsif( $h->header( 'Sec-WebSocket-Origin' )->length ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | ▶ | $new = $self->new( 'draft-ietf-hybi-10', debug => $self->debug ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->new('draft-ietf-hybi-10', 'debug', $self->debug) || (return $self->pass_error)
MC/DC0%0/1
$self->new('draft-ietf-hybi-10', 'debug', $self->debug) || (return $self->pass_error)
$self->new('draft-ietf-hybi-10', 'debug', $self->debug)
Truth table50%1/2
A
A= $self->new('draft-ietf-hybi-10', 'debug', $self->debug)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # Sec-WebSocket-Key has started to be used since version 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # We default to the latest version 17 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | ▶ | $new = $self->new( 'draft-ietf-hybi-17', debug => $self->debug ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->new('draft-ietf-hybi-17', 'debug', $self->debug) || (return $self->pass_error)
MC/DC0%0/1
$self->new('draft-ietf-hybi-17', 'debug', $self->debug) || (return $self->pass_error)
$self->new('draft-ietf-hybi-17', 'debug', $self->debug)
Truth table50%1/2
A
A= $self->new('draft-ietf-hybi-17', 'debug', $self->debug)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # From version 2 to 3 for Sec-WebSocket-Draft and from version Hixie 76 for Sec-WebSocket-Key1 and Sec-WebSocket-Key2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ▶ | elsif( $h->header( 'Sec-WebSocket-Draft' )->length || | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$h->header("Sec-WebSocket-Draft")->length or $h->header("Sec-WebSocket-Key1") and $h->header("Sec-WebSocket-Key2")
$h->header("Sec-WebSocket-Key1") and $h->header("Sec-WebSocket-Key2")
MC/DC66%2/3
$h->header("Sec-WebSocket-Draft")->length or $h->header("Sec-WebSocket-Key1") and $h->header("Sec-WebSocket-Key2")
$h->header("Sec-WebSocket-Draft")->length
$h->header("Sec-WebSocket-Key1")
$h->header("Sec-WebSocket-Key2")
Truth table75%3/4
A or B and C
A= $h->header("Sec-WebSocket-Draft")->lengthB= $h->header("Sec-WebSocket-Key1")C= $h->header("Sec-WebSocket-Key2")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ( $h->header( 'Sec-WebSocket-Key1' ) && $h->header( 'Sec-WebSocket-Key2' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | ▶ | if( $h->header( 'Sec-WebSocket-Draft' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | $new = $self->new( $h->header( 'Sec-WebSocket-Draft' )->scalar, debug => $self->debug ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->new($h->header('Sec-WebSocket-Draft')->scalar, 'debug', $self->debug) || (return $self->pass_error)
MC/DC0%0/1
$self->new($h->header('Sec-WebSocket-Draft')->scalar, 'debug', $self->debug) || (return $self->pass_error)
$self->new($h->header('Sec-WebSocket-Draft')->scalar, 'debug', $self->debug)
Truth table50%1/2
A
A= $self->new($h->header('Sec-WebSocket-Draft')->scalar, 'debug', $self->debug)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # draft version 3 is the latest one using key1 and key2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | $new = $self->new( 'draft-ietf-hybi-03', debug => $self->debug ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->new('draft-ietf-hybi-03', 'debug', $self->debug) || (return $self->pass_error)
MC/DC0%0/1
$self->new('draft-ietf-hybi-03', 'debug', $self->debug) || (return $self->pass_error)
$self->new('draft-ietf-hybi-03', 'debug', $self->debug)
Truth table50%1/2
A
A= $self->new('draft-ietf-hybi-03', 'debug', $self->debug)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # No Sec-WebSocket-Key1? then it is Hixie75 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | ▶ | if( $h->header( 'Sec-WebSocket-Protocol' )->length ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # $new would stringify to undef since there is no version in the WebSocket protocol for those early drafts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | $new = $self->new( 'draft-hixie-76', debug => $self->debug ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ▶ | return( $self->pass_error ) if( !defined( $new ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | elsif( $h->header( 'WebSocket-Protocol' )->length ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | $new = $self->new( 'draft-hixie-75', debug => $self->debug ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | ▶ | return( $self->pass_error ) if( !defined( $new ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # No WebSocket headers found, so this looks like a draft version 7 when there was only | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # Connect, Upgrade, Host and Origin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | $new = $self->new( 'draft-hixie-07', debug => $self->debug ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | ▶ | return( $self->pass_error ) if( !defined( $new ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 8 | return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | sub next | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=7 SCAR=31.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | ▶ | return( $self->error( "Somehow this version lost its offset number !" ) ) if( !defined( $self->{offset} ) || !length( $self->{offset} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"offset"} and length $self->{"offset"}
MC/DC0%0/2
defined $self->{"offset"} and length $self->{"offset"}
defined $self->{"offset"}
length $self->{"offset"}
Truth table33%1/3
A and B
A= defined $self->{"offset"}B= length $self->{"offset"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | my $offset = $self->{offset}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # Reached the end | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | ▶ | return if( $offset == 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my $next_def = $IETF_VERSIONS->[ $offset - 3 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | return( $self->error( "No data found in data at offset ", $offset - 3 ) ) if( !ref( $next_def ) || !scalar( keys( %$next_def ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $next_def and scalar keys %$next_def
MC/DC0%0/2
ref $next_def and scalar keys %$next_def
ref $next_def
scalar keys %$next_def
Truth table0%0/3
A and B
A= ref $next_defB= scalar keys %$next_def
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | my $new = $self->new( $next_def ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->new($next_def) || (return $self->pass_error)
MC/DC0%0/1
$self->new($next_def) || (return $self->pass_error)
$self->new($next_def)
Truth table0%0/2
A
A= $self->new($next_def)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | sub numify | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numify: called CC=4 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | ▶ | return( $self->new_number( $self->{version} ) ) if( defined( $self->{version} ) && length( $self->{version} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"version"} and length $self->{"version"}
MC/DC0%0/2
defined $self->{"version"} and length $self->{"version"}
defined $self->{"version"}
length $self->{"version"}
Truth table33%1/3
A and B
A= defined $self->{"version"}B= length $self->{"version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if( Want::want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return( $self->new_null( wants => 'object' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub offset { return( shift->{offset} ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | ▶ | sub prev { return( shift->previous( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prev: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | sub previous | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
previous: called CC=7 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | ▶ | return( $self->error( "Somehow this version lost its offset number !" ) ) if( !defined( $self->{offset} ) || !length( $self->{offset} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"offset"} and length $self->{"offset"}
MC/DC0%0/2
defined $self->{"offset"} and length $self->{"offset"}
defined $self->{"offset"}
length $self->{"offset"}
Truth table33%1/3
A and B
A= defined $self->{"offset"}B= length $self->{"offset"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | my $offset = $self->{offset}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | my $serial = $self->{serial}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # Reached the end | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | ▶ | return if( $offset == int( $#$IETF_VERSIONS / 2 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | my $prev_def = $IETF_VERSIONS->[ $offset + 3 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | ▶ | return( $self->error( "No data found in data at offset ", $offset + 3 ) ) if( !ref( $prev_def ) || !scalar( keys( %$prev_def ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $prev_def and scalar keys %$prev_def
MC/DC0%0/2
ref $prev_def and scalar keys %$prev_def
ref $prev_def
scalar keys %$prev_def
Truth table33%1/3
A and B
A= ref $prev_defB= scalar keys %$prev_def
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | ▶ | my $new = $self->new( $prev_def ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->new($prev_def) || (return $self->pass_error)
MC/DC0%0/1
$self->new($prev_def) || (return $self->pass_error)
$self->new($prev_def)
Truth table50%1/2
A
A= $self->new($prev_def)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 155 | ▶ | sub revision { return( shift->_set_get_number( 'revision', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revision: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | ▶ | sub serial { return( shift->_set_get_number( 'serial', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serial: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | ▶ | sub status { return( shift->_set_get_scalar_as_object( 'status', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 296 | ▶ | sub type { return( shift->_set_get_scalar_as_object( 'type', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 13 | ▶ | sub version { return( shift->_set_get_number( 'version', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | sub _compare | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my( $other, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # If both are our objects, we use our internal serial to compare | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if( $self->_is_a( $other => ( ref( $self ) || $self ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return( "$self->{serial}" cmp "$other->{serial}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | #... otherwise we use the draft name such as draft-ietf-hybi-17 to compare | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | return( $swap ? "$other" cmp "$self->{draft}" : "$self->{draft}" cmp "$other" ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | sub _compute | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compute: called CC=25 SCAR=40.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 22 | my( $self, $other, $swap, $opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | my $other_val = $self->_is_a( $other => ( ref( $self ) || $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ? $other->{serial} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 22 | ▶ | : ( defined( $other ) && "$other" =~ /^\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
ref $self || $self
defined $other and "$other" =~ /^\d+$/
MC/DC0%0/2
ref $self || $self
ref $self
$self
MC/DC50%1/2
defined $other and "$other" =~ /^\d+$/
defined $other
"$other" =~ /^\d+$/
Truth table33%1/3
A || B
A= ref $selfB= $self
Truth table66%2/3
A and B
A= defined $otherB= "$other" =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ? "$other" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | : "\"$other\""; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 22 | my $serial = "$self->{serial}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 22 | ▶ | my $operation = $swap ? "${other_val} $opts->{op} \$serial" : "\$serial $opts->{op} ${other_val}"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 22 | ▶ | if( $opts->{return_object} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 7 | my $new_serial = eval( $operation ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 8 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 7 | ▶ | warn( "Error with return formula \"$operation\" using object $self having serial '$self->{serial}' and version '$self->{version}': $@" ) if( $@ && $self->_warnings_is_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $self->_warnings_is_enabled
MC/DC0%0/2
$@ and $self->_warnings_is_enabled
$@
$self->_warnings_is_enabled
Truth table33%1/3
A and B
A= $@B= $self->_warnings_is_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 7 | ▶ | return if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 7 | ▶ | if( $new_serial !~ /^\-?\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | ▶ | warn( "Resulting value '$new_serial' is not an integer." ) if( $self->_warnings_is_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # Lower than -71? Not good | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 6 | ▶ | if( $new_serial < $IETF_VERSIONS->[ $#$IETF_VERSIONS ]->{serial} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | warn( "Resulting value '$new_serial' is lower than 0" ) if( $self->_warnings_is_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # Greater than 17? Not good either | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 6 | ▶ | if( $new_serial > $IETF_VERSIONS->[1]->{serial} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | ▶ | warn( "Resulting value '$new_serial' is out of bound, exceeds total entries in the IETF draft repository." ) if( $self->_warnings_is_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | my $dict = $self->get_dictionary( serial => $new_serial ) || do | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->get_dictionary('serial', $new_serial) || do {
warn "Unable to get dictionary for resulting serial '${new_serial}': ", $self->error if $self->_warnings_is_enabled;
return
}
MC/DC0%0/2
$self->get_dictionary('serial', $new_serial) || do {
warn "Unable to get dictionary for resulting serial '${new_serial}': ", $self->error if $self->_warnings_is_enabled;
return
}
$self->get_dictionary('serial', $new_serial)
do {
warn "Unable to get dictionary for resulting serial '${new_serial}': ", $self->error if $self->_warnings_is_enabled;
return
}
Truth table33%1/3
A || B
A= $self->get_dictionary('serial', $new_serial)B= do {
warn "Unable to get dictionary for resulting serial '${new_serial}': ", $self->error if $self->_warnings_is_enabled;
return
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | warn( "Unable to get dictionary for resulting serial '$new_serial': ", $self->error ) if( $self->_warnings_is_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 5 | ▶ | if( !scalar( keys( %$dict ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | my $new = $self->new( $dict ) || do | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->new($dict) || do {
warn $self->error if $self->_warnings_is_enabled;
return
}
MC/DC0%0/2
$self->new($dict) || do {
warn $self->error if $self->_warnings_is_enabled;
return
}
$self->new($dict)
do {
warn $self->error if $self->_warnings_is_enabled;
return
}
Truth table33%1/3
A || B
A= $self->new($dict)B= do {
warn $self->error if $self->_warnings_is_enabled;
return
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | warn( $self->error ) if( $self->_warnings_is_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 5 | return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | elsif( $opts->{boolean} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 12 | my $res = eval( $operation ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 8 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 12 | ▶ | warn( "Error with boolean formula \"$operation\" using object $self having serial '$self->{serial}' and version '$self->{version}': $@" ) if( $@ && $self->_warnings_is_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $self->_warnings_is_enabled
MC/DC0%0/2
$@ and $self->_warnings_is_enabled
$@
$self->_warnings_is_enabled
Truth table33%1/3
A and B
A= $@B= $self->_warnings_is_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 12 | ▶ | return if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # return( $res ? $self->true : $self->false ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 12 | return( $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # like <=> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | return( eval( $operation ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||