| 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
| |||||||||||
| 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; | |||||||||