lib/Finance/Robinhood/Utilities.pm

filter: Statementstmt 100% 15 / 15 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 95.2% 20 / 21 CC 2 SCAR 4.1
CC
2
Cov
94%
gen_uuid
2.0
BEGIN
1.0
_test__gen_uuid
1.0
CRAP 1.5
« lib/Finance/Robinhood/Forex/Quote.pm ↑ Summary lib/Finance/Robinhood/Options/Chain/Ticks.pm »
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 1 our $VERSION = '0.92_003';
20 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 our @EXPORT_OK = ('gen_uuid');
22  
23 =head1 FUNCTIONS
24  
25  
26 =head2 C<gen_uuid( )>
27  
28 Returns a UUID.
29  
30 =cut
31  
32 1 ▶sub gen_uuid() {
Subroutine gen_uuid: called CC=2 SCAR=7.0
Pod documented
33 1 CORE::state $srand;
34 1 ▶ $srand = srand() if !$srand;
Branch: 1 branch
BranchTrueFalseTotal
unless $srand 1 0 1
35 my $retval = join '', map {
36 1 pack 'I',
37 (int(rand(0x10000)) % 0x10000 << 0x10)
38 | int(rand(0x10000)) % 0x10000
39 } 1 .. 4;
40 1 substr $retval, 6, 1, chr(ord(substr($retval, 6, 1)) & 0x0f | 0x40); # v4
41 return join '-',
42 5 map { unpack 'H*', $_ }
43 1 map { substr $retval, 0, $_, '' } (4, 2, 2, 2, 6);
44 }
45  
46 1 ▶sub _test__gen_uuid {
Subroutine _test__gen_uuid: called CC=1 SCAR=0.0
47 1 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<LEGAL> section.
70  
71 =head1 AUTHOR
72  
73 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
74  
75 =cut
76  
77 1 1;
« lib/Finance/Robinhood/Forex/Quote.pm ↑ Summary lib/Finance/Robinhood/Options/Chain/Ticks.pm »