File Coverage

lib/Finance/Robinhood/Equity/Tag.pm
Criterion Covered Total %
statement 22 34 64.7
branch n/a
condition 2 4 50.0
subroutine 9 10 90.0
pod 1 1 100.0
total 34 49 69.3


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Equity::Tag;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Tag - Represents a Single Categorized List of Equity
10             Instruments
11              
12             =head1 SYNOPSIS
13              
14             use Finance::Robinhood;
15             my $rh = Finance::Robinhood->new;
16             my $oil = $rh->tags('oil')->next;
17              
18             CORE::say sprintf '%d members of the tag named %s', $oil->membership_count, $oil->name;
19             CORE::say join ', ', map { $_->symbol } $oil->instruments;
20              
21             =head1 METHODS
22              
23             =cut
24              
25             our $VERSION = '0.92_001';
26              
27 1     1   7 use Mojo::Base-base, -signatures;
  1         3  
  1         6  
28 1     1   188 use Mojo::URL;
  1         2  
  1         6  
29 1     1   73 use Time::Moment;
  1         4  
  1         35  
30 1     1   449 use Finance::Robinhood::Equity::PriceMovement;
  1         3  
  1         6  
31              
32             sub _test__init {
33 1     1   12708 my $rh = t::Utility::rh_instance(1);
34 0         0 my $tag = $rh->tags('food')->current;
35 0         0 isa_ok( $tag, __PACKAGE__ );
36 0         0 t::Utility::stash( 'TAG', $tag ); # Store it for later
37             }
38              
39 1     1   121 use overload '""' => sub ( $s, @ ) { $s->{slug} }, fallback => 1;
  1     6   2  
  1         5  
  6         8  
  6         23  
  6         582  
  6         10  
40              
41             sub _test_stringify {
42 1   50 1   1924 t::Utility::stash('TAG') // skip_all();
43 0         0 like(
44             +t::Utility::stash('TAG'),
45             'food',
46             );
47             }
48             #
49             has _rh => undef => weak => 1;
50              
51             =head2 C
52              
53             If available, this returns a short blurb about what sort of instruments are
54             contained in this tag.
55              
56             =head2 C
57              
58             If available, this returns a full text description suited for display.
59              
60             =head2 C
61              
62             Returns the number of instruments are contained in this tag.
63              
64             =head2 C
65              
66             Returns the name of this tag in a format suited for display
67              
68             =head2 C
69              
70             Returns the internal string used to locate this tag.
71              
72             =cut
73              
74             has [ 'canonical_examples', 'description', 'membership_count', 'name', 'slug' ];
75              
76             =head2 C
77              
78             my $instruments = $mover->instruments();
79              
80             Returns a list of Finance::Robinhood::Equity::Instrument objects.
81              
82             =cut
83              
84 0     0 1 0 sub instruments ($s) {
  0         0  
  0         0  
85             $s->_rh->equity_instruments_by_id(
86 0         0 map {m/([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})\/$/i}
87 0         0 @{ $s->{instruments} } );
  0         0  
88              
89             }
90              
91             sub _test_instruments {
92 1   50 1   2029 t::Utility::stash('TAG') // skip_all();
93 0           my @instruments = t::Utility::stash('TAG')->instruments();
94 0           isa_ok( $instruments[0], 'Finance::Robinhood::Equity::Instrument' );
95             }
96              
97             =head1 LEGAL
98              
99             This is a simple wrapper around the API used in the official apps. The author
100             provides no investment, legal, or tax advice and is not responsible for any
101             damages incurred while using this software. This software is not affiliated
102             with Robinhood Financial LLC in any way.
103              
104             For Robinhood's terms and disclosures, please see their website at
105             https://robinhood.com/legal/
106              
107             =head1 LICENSE
108              
109             Copyright (C) Sanko Robinson.
110              
111             This library is free software; you can redistribute it and/or modify it under
112             the terms found in the Artistic License 2. Other copyrights, terms, and
113             conditions may apply to data transmitted through this module. Please refer to
114             the L section.
115              
116             =head1 AUTHOR
117              
118             Sanko Robinson Esanko@cpan.orgE
119              
120             =cut
121              
122             1;