File Coverage

lib/Finance/Robinhood/Utilities.pm
Criterion Covered Total %
statement 12 12 100.0
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 17 18 94.4


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Utilities;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls forex
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Utilities - Collection of Portable Utility Functions
10              
11             =head1 SYNOPSIS
12              
13             use Finance::Robinhood::Utilities qw[gen_uuid];
14              
15             my $device_id = gen_uuid();
16              
17             =cut
18              
19             our $VERSION = '0.92_003';
20 1     1   6 use Exporter 'import';
  1         3  
  1         230  
21             our @EXPORT_OK = ('gen_uuid');
22              
23             =head1 FUNCTIONS
24              
25              
26             =head2 C
27              
28             Returns a UUID.
29              
30             =cut
31              
32             sub gen_uuid() {
33 1     1 1 3 CORE::state $srand;
34 1 50       58 $srand = srand() if !$srand;
35             my $retval = join '', map {
36 1         7 pack 'I',
  4         27  
37             (int(rand(0x10000)) % 0x10000 << 0x10)
38             | int(rand(0x10000)) % 0x10000
39             } 1 .. 4;
40 1         8 substr $retval, 6, 1, chr(ord(substr($retval, 6, 1)) & 0x0f | 0x40); # v4
41             return join '-',
42 5         43 map { unpack 'H*', $_ }
43 1         4 map { substr $retval, 0, $_, '' } (4, 2, 2, 2, 6);
  5         11  
44             }
45              
46             sub _test__gen_uuid {
47 1     1   11595 like(gen_uuid(),
48             qr[^[0-9a-f]{8}(?:\-[0-9a-f]{4}){3}\-[0-9a-f]{12}$]i,
49             'generated uuid');
50             }
51              
52             =head1 LEGAL
53              
54             This is a simple wrapper around the API used in the official apps. The author
55             provides no investment, legal, or tax advice and is not responsible for any
56             damages incurred while using this software. This software is not affiliated
57             with Robinhood Financial LLC in any way.
58              
59             For Robinhood's terms and disclosures, please see their website at
60             https://robinhood.com/legal/
61              
62             =head1 LICENSE
63              
64             Copyright (C) Sanko Robinson.
65              
66             This library is free software; you can redistribute it and/or modify it under
67             the terms found in the Artistic License 2. Other copyrights, terms, and
68             conditions may apply to data transmitted through this module. Please refer to
69             the L section.
70              
71             =head1 AUTHOR
72              
73             Sanko Robinson Esanko@cpan.orgE
74              
75             =cut
76              
77             1;